Announcement

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

  • Test command not working after svy:melogit

    Hi,
    I am using svy:melogit to estimate a 2-level model with Stata 15. It has been suggested in previous threads that we can use the 'test' command to test svy models. But my test command is not working- I have tried using it in different ways. I was advised to use 'coeflegend' but that is not working and I am not sure how to use it for nested models. I will appreciate if someone can explain why this is happening and how to check my models.
    My commands are
    Code:
        svyset v021 , strata(v023) || _n, weight (pwt1) singleunit(missing)
    
        svy:melogit lbw ||v021:, cov(unstruct)
        est store b1
        svy:melogit lbw i.matgr i.educ i.anc ||v021:, cov(unstruct)
        est store b2    
        test [b1= b2]
        test [b1_lbw= b2_lbw]
        test [_est_b1 =_est_b2]
    
        drop b*
        svy:melogit lbw ||v021:, cov(unstruct)
        svy:melogit, coeflegend
        svy:melogit lbw i.matgr i.educ i.anc ||v021:, cov(unstruct) 
        svy:melogit, coeflegend
    I show my output with the following example
    Code:
          pweight: <none>
              VCE: linearized
      Single unit: missing
         Strata 1: v023
             SU 1: v021
            FPC 1: <zero>
         Weight 1: <none>
         Strata 2: <one>
             SU 2: <observations>
            FPC 2: <zero>
         Weight 2: pwt1
    
    .
    .         svy:melogit lbw ||v021:, cov(unstruct)
    (running melogit on estimation sample)
    
    Survey: Mixed-effects logistic regression
    
    Number of strata   =        14                  Number of obs     =      1,641
    Number of PSUs     =       366                  Population size   =      1,641
                                                    Design df         =        352
                                                    F(   0,    352)   =          .
                                                    Prob > F          =          .
    
    ------------------------------------------------------------------------------
                 |             Linearized
             lbw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |  -2.001612   .1050336   -19.06   0.000    -2.208185    -1.79504
    -------------+----------------------------------------------------------------
    v021         |
       var(_cons)|   .2487629   .1988702                      .0516364    1.198437
    ------------------------------------------------------------------------------
    
    .         est store b1
    
    .         svy:melogit lbw i.matgr i.educ i.anc ||v021:, cov(unstruct)
    (running melogit on estimation sample)
    
    Survey: Mixed-effects logistic regression
    
    Number of strata   =        14                  Number of obs     =      1,641
    Number of PSUs     =       366                  Population size   =      1,641
                                                    Design df         =        352
                                                    F(   4,    349)   =       9.42
                                                    Prob > F          =     0.0000
    
    -----------------------------------------------------------------------------------
                      |             Linearized
                  lbw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                matgr |
                 <20  |   .3802068   .1511276     2.52   0.012     .0829802    .6774334
                      |
                 educ |
                   1  |  -.5807697   .2355042    -2.47   0.014    -1.043942   -.1175974
                   2  |  -.6029564   .1936806    -3.11   0.002    -.9838731   -.2220397
                      |
                  anc |
    4 or more visits  |  -.7876988   .1817539    -4.33   0.000    -1.145159   -.4302387
                _cons |  -1.062004   .1935036    -5.49   0.000    -1.442573   -.6814354
    ------------------+----------------------------------------------------------------
    v021              |
            var(_cons)|    .317312   .2316642                      .0754909    1.333763
    -----------------------------------------------------------------------------------
    
    .         est store b2    
    
    .         test [b1= b2]
    
    Adjusted Wald test
    equation b1 not found
    
    .         test [b1_lbw= b2_lbw]
    
    Adjusted Wald test
    equation b1_lbw not found
    
    .         test [_est_b1 =_est_b2]
    
    Adjusted Wald test
    equation _est_b1 not found
    
    .         quietly svy:melogit lbw ||v021:, cov(unstruct) 
    .         svy:melogit, coeflegend
    last estimates not found
    r(301);
    Thanks for your help
    Last edited by Deepali godha; 26 Feb 2018, 20:23.
    Deepali Godha

  • #2
    test only works for a single model. You can still compare your two nested models, but to do soy ou need to find the constraints that would turn your second model into the first model and test those constraints. In your case that would be the constraints that the effects of i.matgr, i.educ and i.anc are all simultaneously equal to zero. You can do that with test, but more convenient is in this case testparm (it is the exact same test, but a more convenient syntax for this specific test):

    Code:
    testparm i.matgr i.educ i.anc
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Many thanks Maarten- this makes sense. But, what should I do when I add random effects to the model? How can I decide if this one is better than the fixed effects only?

      Thanks
      Deepali Godha

      Comment

      Working...
      X