Announcement

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

  • Test if variance on random intercepts are 0 (svy: melogit)

    I am using survey weighted data with two (nested) random intercepts. I would like to test if the variances of the random intercepts are 0.
    The lrtest command will not work, since I have used svy:melogit.

    I looked at this post but my context is different enough such that I don't know the correct code.

    Code:
    * Set weights
    svyset occ_group_cat, weight(weight_occ_cat) strata(state_abbr) || occ_cat, weight(weight_occ) strata(state_abbr)  || _n, weight(weight_respondent_rescale) strata(state_abbr)
    
    
    *(Nested) random intercept model
    svy: melogit t_tested_14d_dummy b1.gender b1.age_bucket b1.education b1.race_ethnicity b1.state_abbr ///
                                    comorbid_Type1D comorbid_Type2D comorbid_Cancer comorbid_HeartDis comorbid_HighBP ///
                                    comorbid_Asthma comorbid_ChronLungD comorbid_KidneyD comorbid_AutoImm comorbid_WeakImm ///
                                    comorbid_Missing ///
                                    b1.worry_catch_COVID_C9 ///
                                    c.perc_Rep_2020_sc c.incid_prop_7dma_jhu_sc c.PVI_pop_conc_density_sc ///
                                    || occ_group_cat: || occ_cat:, intpoints(2) startgrid(.11) intmethod(mcaghermite) iterate(5000)

    Without showing full results, the variance estimates are as follows:



    I want to perform two tests: whether the variances for the random intercepts (occ_group_cat and occ_cat) are equal to 0.

    My (wrong) code is as follows:

    Code:
    test _b[var(occ_group_cat:_cons)] = 0
    test _b[var(occ_cat:_cons)] = 0

    Thank you very much.

  • #2
    See the -coeflegend- option on how to refer to the coefficients.

    Code:
    webuse towerlondon, clear
    melogit dtlm difficulty i.group || family: || subject:, coeflegend
    test (_b[/var(_cons[family])]= 0) (_b[/var(_cons[family>subject])]=0)
    Res.:


    Code:
    . melogit dtlm difficulty i.group || family: || subject:, coeflegend
    
    Fitting fixed-effects model:
    
    Iteration 0:   log likelihood = -317.35042  
    Iteration 1:   log likelihood = -313.90007  
    Iteration 2:   log likelihood = -313.89079  
    Iteration 3:   log likelihood = -313.89079  
    
    Refining starting values:
    
    Grid node 0:   log likelihood = -310.28429
    
    Fitting full model:
    
    Iteration 0:   log likelihood = -310.28429  
    Iteration 1:   log likelihood = -307.36653  
    Iteration 2:   log likelihood = -305.19357  
    Iteration 3:   log likelihood = -305.12073  
    Iteration 4:   log likelihood = -305.12041  
    Iteration 5:   log likelihood = -305.12041  
    
    Mixed-effects logistic regression               Number of obs     =        677
    
            Grouping information
            -------------------------------------------------------------
                            |     No. of       Observations per group
             Group variable |     groups    Minimum    Average    Maximum
            ----------------+--------------------------------------------
                     family |        118          2        5.7         27
                    subject |        226          2        3.0          3
            -------------------------------------------------------------
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(3)      =      74.90
    Log likelihood = -305.12041                     Prob > chi2       =     0.0000
    --------------------------------------------------------------------------------
              dtlm | Coefficient  Legend
    ---------------+----------------------------------------------------------------
        difficulty |  -1.648505  _b[difficulty]
                   |
             group |
                2  |  -.2486841  _b[2.group]
                3  |  -1.052306  _b[3.group]
                   |
             _cons |  -1.485863  _b[_cons]
    ---------------+----------------------------------------------------------------
    family         |
         var(_cons)|   .5692105  _b[/var(_cons[family])]
    ---------------+----------------------------------------------------------------
    family>subject |
         var(_cons)|   1.137917  _b[/var(_cons[family>subject])]
    --------------------------------------------------------------------------------
    LR test vs. logistic model: chi2(2) = 17.54               Prob > chi2 = 0.0002
    
    Note: LR test is conservative and provided only for reference.
    
    . 
    . test (_b[/var(_cons[family])]= 0) (_b[/var(_cons[family>subject])]=0)
    
     ( 1)  [/]var(_cons[family]) = 0
     ( 2)  [/]var(_cons[family>subject]) = 0
    
               chi2(  2) =    6.43
             Prob > chi2 =    0.0402
    
    .

    Comment


    • #3
      Brilliant!! Thank you very much!

      Comment

      Working...
      X