Announcement

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

  • xthybrid and xtlogit produce slightly different results

    Dear statalisters,

    I am studying why people not use contraception in an unbalanced panel of 11 waves. As I am interested in comparing within and between effects I ran a within-between or hybrid model. I calculated the within- and between components for all time-varying variables "by hand". Then I used the xthybrid command by Schunk and Perales to see if they produce the same results. However, I find that coefficients are not exactly the same and I would like to understand why that is the case.

    I did several checks. I am sure I use exactly the same sample, I compared the within-and between components I created with those created by the xthybrid (using the keepvars-option), and I adjusted the integrationpoints to in the xtlogit command to 7 so they are comparable between models. Both commands use pseudomaximumlikelihood and the same integration-method.

    I use Stata/SE 16.0

    Syntax for creating within- and between components manually
    Code:
    foreach var of varlist partner_cohab1 partner_cohab2 partner_cohab3 reldur_re nkidsbio_cat1 nkidsbio_cat2 nkidsbio_cat3 nkidsbio_cat4 ///
    freqsex21 freqsex22 freqsex23 workstatus_1 workstatus_2 workstatus_3 workstatus_4 agegroup2_1 agegroup2_2 agegroup2_3 agegroup2_4 ///
    breastfeed21 breastfeed22 breastfeed23 subjhealth21 subjhealth22 subjhealth23 infert_1 infert_2 infert_3 depress_d ///
    kiwu_dk1 kiwu_dk2 kiwu_dk3 voc_benefits1 voc_costs1 womX* {
        bysort id (wave): egen m_`var'=mean(`var') if hsample1==1          // mean (within person)
        bysort id (wave): gen d_`var'=`var'-m_`var' if hsample1==1        // deviation of individual value from mean (within person)
    }
    Heres the commands and regression outputs

    Code:
    . cap drop B_*  W_*   
    
    . xthybrid inconsistency3c_d1 /*agegroup2_1*/ agegroup2_2 agegroup2_3 agegroup2_4  /*breastfeed21*/ breastfeed22 breastfeed23 if hsample1==
    > 1, vce(robust) clusterid(id) family(binomial) link(logit) full keepvars
    
    
    -------------------------------------------------------------------------------------------------------------------------------------------
    Model model
    -------------------------------------------------------------------------------------------------------------------------------------------
    
    Mixed-effects GLM                               Number of obs     =     18,084
    Family:                binomial
    Link:                     logit
    Group variable:              id                 Number of groups  =      5,035
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        3.6
                                                                  max =         10
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(10)     =     544.81
    Log pseudolikelihood = -6223.9484               Prob > chi2       =     0.0000
                                           (Std. Err. adjusted for 5,035 clusters in id)
    ------------------------------------------------------------------------------------
                       |               Robust
    inconsistency3c_d1 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------------+----------------------------------------------------------------
        W__agegroup2_2 |   1.154933   .2486763     4.64   0.000     .6675365     1.64233
        W__agegroup2_3 |   1.889027   .2985934     6.33   0.000     1.303795    2.474259
        W__agegroup2_4 |   2.295771   .3402473     6.75   0.000     1.628899    2.962644
       W__breastfeed22 |   3.257546   .2634088    12.37   0.000     2.741275    3.773818
       W__breastfeed23 |   1.344047   .2551749     5.27   0.000     .8439133     1.84418
        B__agegroup2_2 |   2.106907   .2580269     8.17   0.000     1.601184    2.612631
        B__agegroup2_3 |   3.521265   .2428555    14.50   0.000     3.045277    3.997253
        B__agegroup2_4 |    4.85516   .7315018     6.64   0.000     3.421443    6.288877
       B__breastfeed22 |   4.904525   .6305259     7.78   0.000     3.668717    6.140333
       B__breastfeed23 |   1.426821   .5580139     2.56   0.011     .3331338    2.520508
                 _cons |  -6.170052   .2564959   -24.06   0.000    -6.672774   -5.667329
    -------------------+----------------------------------------------------------------
    id                 |
             var(_cons)|   13.37639   1.321677                      11.02135    16.23467
    ------------------------------------------------------------------------------------
    Please remember to remove any variables beginning with the prefix B__, W__ or R__ from the data before executing xthybrid again
    
    .
    . xtlogit inconsistency3c_d1 /*d_agegroup2_1 d_breastfeed21*/ c.d_agegroup2_2 c.d_agegroup2_3 c.d_agegroup2_4 c.d_breastfeed22 c.d_breastfe
    > ed23 ///
    > c.m_agegroup2_2  c.m_agegroup2_3 c.m_agegroup2_4 /*m_agegroup2_1 m_breastfeed21 */ c.m_breastfeed22  c.m_breastfeed23  if hsample1==1, re
    >  vce(robust) i(id) intpoints(7)
    
    
    Calculating robust standard errors:
    
    Random-effects logistic regression              Number of obs     =     18,084
    Group variable: id                              Number of groups  =      5,035
    
    Random effects u_i ~ Gaussian                   Obs per group:
                                                                  min =          1
                                                                  avg =        3.6
                                                                  max =         10
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(10)     =     579.59
    Log pseudolikelihood  = -6221.4571              Prob > chi2       =     0.0000
    
                                           (Std. Err. adjusted for 5,035 clusters in id)
    ------------------------------------------------------------------------------------
                       |               Robust
    inconsistency3c_d1 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------------+----------------------------------------------------------------
         d_agegroup2_2 |   1.051203   .2299139     4.57   0.000     .6005804    1.501826
         d_agegroup2_3 |   1.753846   .2787489     6.29   0.000     1.207508    2.300184
         d_agegroup2_4 |    2.13603   .3182763     6.71   0.000      1.51222     2.75984
        d_breastfeed22 |   3.108342   .2433278    12.77   0.000     2.631428    3.585255
        d_breastfeed23 |   1.284743   .2434488     5.28   0.000     .8075924    1.761894
         m_agegroup2_2 |   1.959986    .249079     7.87   0.000       1.4718    2.448172
         m_agegroup2_3 |   3.296934    .234279    14.07   0.000     2.837756    3.756113
         m_agegroup2_4 |   4.511199   .7167888     6.29   0.000     3.106319    5.916079
        m_breastfeed22 |   4.366374   .5636822     7.75   0.000     3.261577    5.471171
        m_breastfeed23 |   1.330811    .544356     2.44   0.014     .2638933     2.39773
                 _cons |  -5.667056   .2271291   -24.95   0.000    -6.112221   -5.221891
    -------------------+----------------------------------------------------------------
              /lnsig2u |    2.28083   .0642219                      2.154957    2.406702
    -------------------+----------------------------------------------------------------
               sigma_u |   3.128066   .1004451                      2.937264    3.331262
                   rho |   .7483784   .0120935                      .7239439    .7713332
    ------------------------------------------------------------------------------------
    Once I understand what is going on I would like to include interactions of all variables by gender. Whats the appropriate way to do that using the xthybrid command since factor-variable notation is not allowed? Should create the interactions manually and include them in the syntax.

    Looking forward to your replies!
    Jasmin
Working...
X