Reputation: 35
I am new to R and I am trying all possible model combination using Generalized Linear Models and logistic regression with a probit link. However, when I run the code, none of the model seems to be adequate I know that if one of the model is adequate it is the best model. This is my code, is there anything wrong with it ?
install.packages("glm2")
library(glm2)
data("heart")
attach(heart)
head(heart)
nondeath<-c(Patients - Deaths)
nondeath
logreg4<-glm(cbind(Deaths,nondeath)~AgeGroup+Severity+Delay+Region,family=binomial(link = probit))
summary(logreg4)
1-pchisq(109.02,69)##model is not adequate 0.001524977
logreg6<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity+Delay+Region,family=binomial(link = probit))
summary(logreg6)
1-pchisq(88.607,68)#0.04740388
logreg7<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity*Delay+Region,family=binomial(link = probit))
summary(logreg7)
1-pchisq(85.906,65)#0.04232451
logreg8<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity*Delay*Region,family=binomial(link = probit))
summary(logreg8)###model is not adequate 0.04740388
logreg5<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity+Delay+Region,family=quasibinomial(link = probit))
summary(logreg5)
1-pchisq(79.485,58)##model is not adequate 0.04740388
logreg9<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity*Delay+Region,family=quasibinomial(link = probit))
summary(logreg9)#0.04232451
logreg0<-glm(cbind(Deaths,nondeath)~AgeGroup*Severity*Delay*Region,family=quasibinomial(link = probit))
summary(logreg0)##model is not adequate 0.04740388
Upvotes: 0
Views: 129
Reputation: 2474
You are using a dataset in glm2 that is used to demonstrate problems in glm convergence, but you don't use glm2 but glm. You need to first transform variables into factors, here you have numerics, so use
logreg4<-
glm(cbind(Deaths,nondeath)~factor(AgeGroup)+factor(Severity)+factor(Delay)+factor(Region),family=binomial(link
= probit))
When looking at your residuals, there is something wrong, so it would probably be better to use a log link with your dataset. Check ? glm2 for some examples. You could select the model with the lowest AIC.
Upvotes: 0