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?
glm1. Moreover, the answer in the duplicate explicitly compares two models, exactly as you require. – whuber Dec 01 '20 at 21:43lrtestand my assignment didn't ask for that test. its asking forpchisq. I am also confuse on how its comparing two models. the first parameter to funcion pchisq is difference ofglm1null.devianceanddeviance. the second one isdf(degree of freedom?) ofglm1df.nullordf.residual. If i have to compare two models saymod.aandmod.bwhich parameters will bemod.aand which ones would bemod.b– Em Ae Dec 02 '20 at 02:12