## Aufgabe 2 ## (a) daten <- read.table("/home/wkarcher/Desktop/apprentice.dat", header=TRUE) attach(daten) glm.move1 <- glm(Apprentices ~ 1+Distance+Population+Urbanization+Location, family=poisson(link="log")) summary(glm.move1) ## (c) detach(daten) daten[daten[,5]=="West",5] <- "North" attach(daten) glm.move2 <- glm(Apprentices ~ 1+Distance+Population+Urbanization+Location, family=poisson(link="log")) summary(glm.move2) ## (d) glm.lqt <- glm(Apprentices ~ 1, family=poisson(link="log")) anova(glm.lqt, glm.move2, test="Chisq") ## (e) # mit gerundeten Koeffizienten exp(4.251947-0.033857*50+0.021342*40-0.033452*50+1.052247*1) # mit "exakten" Koeffizienten exp(glm.move2$coefficients[1]+glm.move2$coefficients[2]*50+glm.move2$coefficients[3]*40+glm.move2$coefficients[4]*50+glm.move2$coefficients[5]*1) # mit der R-Funktion predict() predict(glm.move2, data.frame(Distance=50,Population=40,Urbanization=50.0,Location="South"), type="response")