This questino doesn't answer my question since it is asking about lrtest and pchisq comparison
I am simply asking that how to do likliehood test for 2 models using pchisq
.
I have a question in which it is asked that i have to do likelihood ratio test comparing the models. I have calculated models as
model1 <- glm (val ~ val2, family=binomial, data=xyz)
model1 <- glm (val ~ val2 + val3 + val4, family=binomial, data=xyz)
now how would i do the likli hood test on these 2? I see the formula is
1 - pchisq(glm1$null.deviance - glm1$deviance, df = (glm1$df.null - glm1$df.residual))
But this is doing only for 1 model (which is stored in glm1
variable).
Is the question asking me to do test independently and then compare the output of 2 models? Or there is a way in which i can input 2 models in a funciton to get the result?