R code for likelihood test

-2

I have a dataset to do a logistic regression for the dependent variable "childbirth" which is qualitative binary.

With the command below I get the univariate logistic model:

GLM.1 <- glm(parto ~ serie, family=binomial(logit), data=Dataset)

With this other command below I get the p-value of the chi-square of the likelihood ratio test.

1-pchisq(GLM.1$null.deviance-GLM.1$deviance, GLM.1$df.null-GLM.1$df.residual)

What commands should I use to find each of the following components separately?

  • deviance
  • L (reduced model)
  • L (saturated model)
  • asked by anonymous 03.08.2017 / 18:50

    1 answer

    1

    Now it's easier to answer the question. Just see the Value section of the ?glm page.

    L_sat <- GLM.1$deviance/(-2)
    L_red <- GLM.1$null.deviance/(-2)
    

    Note also that it is possible to simplify the calculation of p-value , using the argument lower.tail that all distribution functions of R have. This may still be important because the rounding errors are minor.

    pchisq(GLM.1$null.deviance-GLM.1$deviance, GLM.1$df.null-GLM.1$df.residual, lower.tail = FALSE)
    
        
    04.08.2017 / 17:04