chd.data <- importData("c:\\OldE\\M3S12\\Data\\CHD.xls") #Number of data points n<-nrow(chd.data) chd.y<-chd.data$CHD chd.x<-chd.data$AGRP chd.x[chd.data$AGRP <= 6]<-0 #NON EXPOSED, <= 55 chd.x[chd.data$AGRP > 6]<-1 #EXPOSED > 55 chd.data55<-data.frame(chd.x,chd.y) names(chd.data55)<-c("OVER.55","CHD") #OVER.55 = 1 if over 55, OVER.55 = 0 otherwise options(contrasts=c("contr.treatment","contr.poly")) #Fit the "null" GLM, where the linear predictor is constant fit.0_glm(CHD ~ 1,family=binomial,data=chd.data55) summary(fit.0) #Fit the model with OVER.55 as the only predictor fit.1_glm(CHD ~ factor(OVER.55),family=binomial,data=chd.data55) summary(fit.1)