#Vorlesung Multivariate Analysen #=============================== # #Kapitel 3.2: Logistische Regression #=================================== # #Lego # # #Problemdarstellung als Streuungsdiagramm scatterplot(Attr2~Einspritztemp, reg.line=lm,ylim=c(-0.2,1.2),xlim=c(292.8,297.2), smooth=FALSE, boxplots=FALSE, span=0.5, cex=1.4, cex.axis=1.4, cex.lab=1.4, pch=16, ylab="Qualitaet: 0:gut 1:schlecht", data=Lego) # # # #Berechnung der Logistischen Regression für eine Einflussgröße #============================================================= # #Statistik/Regressionsmodelle/Generalisiertes Lineares Modell... GLM.1 <- glm(Qualitaet ~ Einspritztemp, family=binomial(logit), data=Lego) summary(GLM.1) # # #Darstellung der logistischen Funktion im Streuungsdiagramm GLM.1 <- glm(Attr2 ~ Einspritztemp, family=binomial(logit), data=Lego) Lego$fittedGLM<-fitted(GLM.1) scatterplot(fittedGLM~Einspritztemp|Qualitaet, reg.line=FALSE, smooth=FALSE, cex=1.4, cex.axis=1.2, cex.lab=1.2, data=Lego) # # # #Bestimmung des geschätzten Modells #================================== # #Bestimmung der Zuordnungen GLM.1 <- glm(Attr2 ~ Einspritztemp, family=binomial(logit), data=Lego) Lego$fittedGLM<-fitted(GLM.1) Lego$Attr2-round(Lego$fittedGLM,0) # # # #Prüfung der Modellvoraussetzungen #================================= # #Berchnung und Darstellung der Pearson-Residuen GLM.1 <- glm(Attr2 ~ Einspritztemp, family=binomial(logit), data=Lego) residuenp<-residuals(GLM.1,type="pearson") plot(residuenp,type="b",ylim=c(-2,2)) lines(c(0,16),c(1,1), lty=2, col=2) lines(c(0,16),c(-1,-1), lty=2, col=2) # # # Auswahl der wesentlichen Einflussgrößen #====================================== # #Vollständiges Model mit drei Einflussgrößen GLM.2 <- glm(Qualitaet ~ Einspritztemp + Haltedruck + Charge, family=binomial(logit), data=Lego) summary(GLM.2) # #Auswahl über das AIC-Kritierium mit backward-Strategie stepwise(GLM.2, direction='backward', criterion='AIC') # # ###