# ***** Problem S8 ***** birth<-read.table("http://www.uio.no/studier/emner/matnat/math/STK3100/data/Birth.txt",header=T,row.names=NULL) #models with different numer of covariates: mod10 <- glm(children~age+I(age^2) ,family=poisson,data=birth) # canonical link: log mod11 <- glm(children~age ,family=poisson,data=birth) # canonical link: log mod12 <- glm(children~1 ,family=poisson,data=birth) # canonical link: log summary(mod10) #beta_0, beta_1, beta_2 summary(mod11) #beta_0, beta_1 summary(mod12) #beta_0 #a) test H: beta_2=0 # likelihood ratio test anova.glm(mod11,mod10) # look under the variable called the "Deviance" 1-pchisq(0.19601,1) # p-value # Wald test b<-mod10$coeff # beta_hat C1<-c(0,0,1) # testing for the last beta W1<-t(C1%*%b)%*%solve(t(C1)%*%vcov(mod10)%*%C1)%*%(C1%*%b) # Wald statistic 1-pchisq(W1,1) # p-value #b) test H: beta_1=beta_2=0 # likelihood ratio test anova.glm(mod12,mod10) # look under the variable called the "Deviance" 1-pchisq(29.604,2) # p-value C2<-cbind(c(0,0),diag(c(1,1))) # testing for the last two betas W2<-t(C2%*%b)%*%solve(C2%*%vcov(mod10)%*%t(C2))%*%(C2%*%b) # Wald statistic 1-pchisq(W2,2) # p-value