Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Likelihood ratio test between glm and gllamm models

    Hello, all,

    I'm trying to do a likelihood ratio test to compare glm and gllamm models, but get an error message. I've seen others report comparing these models (mostly in textbooks), but they never show code.

    Any help is appreciated.

    Thanks,
    DDT

  • #2
    Can you present a data example resulting in the error?

    Comment


    • #3
      Sure:

      Code:
      . eststo: glm collcareer, f(b) eform
      
      Iteration 0:   log likelihood = -4933.2867  
      Iteration 1:   log likelihood =  -4932.925  
      Iteration 2:   log likelihood =  -4932.925  
      
      Generalized linear models                         No. of obs      =      7,128
      Optimization     : ML                             Residual df     =      7,127
                                                        Scale parameter =          1
      Deviance         =  9865.850081                   (1/df) Deviance =   1.384292
      Pearson          =         7128                   (1/df) Pearson  =    1.00014
      
      Variance function: V(u) = u*(1-u)                 [Bernoulli]
      Link function    : g(u) = ln(u/(1-u))             [Logit]
      
                                                        AIC             =   1.384379
      Log likelihood   = -4932.925041                   BIC             =  -53363.37
      
      ------------------------------------------------------------------------------
                   |                 OIM
        collcareer |       Odds   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             _cons |   .9104798    .021592    -3.95   0.000     .8691286    .9537983
      ------------------------------------------------------------------------------
      (est1 stored)
      
      . eststo: gllamm collcareer, i(school_id) f(binomial) eform
      
      Iteration 0:   log likelihood = -4405.6689  
      Iteration 1:   log likelihood = -4390.8763  (not concave)
      Iteration 2:   log likelihood = -4384.6925  
      Iteration 3:   log likelihood = -4384.4694  
      Iteration 4:   log likelihood = -4384.4693  
       
      number of level 1 units = 7128
      number of level 2 units = 43
       
      Condition Number = 1.7360963
       
      gllamm model
       
      log likelihood = -4384.4693
       
      ------------------------------------------------------------------------------
        collcareer |     exp(b)   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             _cons |   1.408489   .0443982    10.87   0.000     1.324103    1.498252
      ------------------------------------------------------------------------------
      Note: Estimates are transformed only in the first equation.
       
       
      Variances and covariances of random effects
      ------------------------------------------------------------------------------
      
       
      ***level 2 (school_id)
       
          var(1): .61102282 (.0418296)
      ------------------------------------------------------------------------------
      
       
      (est2 stored)
      
      .
      end of do-file
      
      . lrtest est1 est2
      test involves different estimators: gllamm vs. glm
      r(498);

      Comment


      • #4
        Try

        Code:
        lrtest est1 est2, force
        If this does not work, present a minimal data example and I can provide a workaround.

        Comment


        • #5
          I thought of doing that, but didn't. It worked. Should have gone with my instinct.

          Thanks,
          DDT

          Comment

          Working...
          X