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" and ran xtlogit, re. 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.
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 hope somebody can help me to understand why that is the case. Does this have something to do with the fact that xthybrid is based on meglm command?
I use Stata/SE 16.0.
Syntax for creating within- and between components manually
Code:
foreach var of varlist agegroup2_1 agegroup2_2 agegroup2_3 agegroup2_4 {
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)
}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)
Fitting comparison model:
Iteration 0: log pseudolikelihood = -8702.3206
Iteration 1: log pseudolikelihood = -8189.2047
Iteration 2: log pseudolikelihood = -8139.761
Iteration 3: log pseudolikelihood = -8138.7956
Iteration 4: log pseudolikelihood = -8138.7937
Iteration 5: log pseudolikelihood = -8138.7937
Fitting full model:
tau = 0.0 log pseudolikelihood = -8138.7937
tau = 0.1 log pseudolikelihood = -7873.8225
tau = 0.2 log pseudolikelihood = -7629.4166
tau = 0.3 log pseudolikelihood = -7405.2845
tau = 0.4 log pseudolikelihood = -7199.9321
tau = 0.5 log pseudolikelihood = -7012.9971
tau = 0.6 log pseudolikelihood = -6846.7976
tau = 0.7 log pseudolikelihood = -6707.9118
tau = 0.8 log pseudolikelihood = -6613.7677
Iteration 0: log pseudolikelihood = -6703.822
Iteration 1: log pseudolikelihood = -6309.7395
Iteration 2: log pseudolikelihood = -6252.9039
Iteration 3: log pseudolikelihood = -6225.7805
Iteration 4: log pseudolikelihood = -6225.5742
Iteration 5: log pseudolikelihood = -6225.5742 (backed up)
Iteration 6: log pseudolikelihood = -6221.5383
Iteration 7: log pseudolikelihood = -6221.4572
Iteration 8: log pseudolikelihood = -6221.4571
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
------------------------------------------------------------------------------------Looking forward to your replies!
Jasmin
0 Response to xthybrid and xtlogit produce slightly different results
Post a Comment