I am trying to compare two models and check which is the best fit of our data. The R script is below:
# Models fit1<-glm(bp_target~gender+age, family=binomial(link = "logit")) fit2<-glm(bp_target~gender+age+tc+hdl+factor(smoking)+glucose, family=binomial(link="logit")) #Goodness of fit anova(fit1, fit2, test="Chisq")
And we got the warning:
Error in anova.glmlist(c(list(object), dotargs), dispersion = dispersion, :
models were not all fitted to the same size of dataset
I do understand anova() can only be used to check goodness of fit when two models have equal dataset. However, in my case, fit2 has more missing values than fit1.
How could I compare these two models and decide which is better?