0

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?

Em Ae
  • 351
  • 1
    Unclear (to me anyhow) what you're asking. Please clarify. What are your null and alternative hypotheses? What makes you think your data are sampled from a chi-squared distribution? What is your goal? – BruceET Dec 01 '20 at 21:04
  • It's related to an assignment. The question just says that compare two models using likliehood ratio test. what i am confuse at what function/method to use. I looked on the notes and i saw pchisq function but that funciton takes in only one model. So not sure if the question is asking to use that function and compare the output of if for two models ... or there is an alternative way to do comparison by providing two models to a funciton. – Em Ae Dec 01 '20 at 21:15
  • Re "this is doing [it] only for 1 model:" Quite clearly that code is comparing two models: the null model and glm1. Moreover, the answer in the duplicate explicitly compares two models, exactly as you require. – whuber Dec 01 '20 at 21:43
  • but that answer is using lrtest and my assignment didn't ask for that test. its asking for pchisq. I am also confuse on how its comparing two models. the first parameter to funcion pchisq is difference of glm1 null.deviance and deviance. the second one is df (degree of freedom?) of glm1 df.null or df.residual. If i have to compare two models say mod.a and mod.b which parameters will be mod.a and which ones would be mod.b – Em Ae Dec 02 '20 at 02:12

0 Answers0