I have panel data xtset across 3 waves of children's weight and parents employment status, I have continuous outcomes for continuous weight, and binary outcomes for binary weight. So I employ a linear and logit fixed effects regression, as necessary.
I xtset by id and year as standard:
Code:
xtset id year
Linear Regression without, and then with clustering:
Code:
. xtreg child_weight parental_unemployment i.C_region_y i.year i.C_Simplemotherage_y i.C_Simplemothereduca_y i.C_mothermar_y, fe Fixed-effects (within) regression Number of obs = 28,723 Group variable: id Number of groups = 10,998 R-sq: Obs per group: within = 0.0476 min = 1 between = 0.0001 avg = 2.6 overall = 0.0139 max = 3 F(12,17713) = 73.74 corr(u_i, Xb) = -0.0137 Prob > F = 0.0000 ---------------------------------------------------------------------------------------------------- child_weight | Coef. Std. Err. t P>|t| [95% Conf. Interval] -----------------------------------+---------------------------------------------------------------- parental_unemployment| .0446502 .0200392 2.23 0.026 .0053714 .0839291 1.C_region_y | .0057119 .0279776 0.20 0.838 -.0491269 .0605507 | year | 1 | .1893615 .0120075 15.77 0.000 .1658255 .2128974 2 | -.1486756 .0140992 -10.54 0.000 -.1763115 -.1210398 | C_Simplemotherage_y | 30-39 | .0065484 .0249831 0.26 0.793 -.0424209 .0555176 40 or more | -.0054981 .0365407 -0.15 0.880 -.0771215 .0661253 | C_Simplemothereduca_y | Leaving Certificate to Non Degree | .0795771 .0455652 1.75 0.081 -.0097351 .1688893 Primary Degree or greater | .067113 .055558 1.21 0.227 -.041786 .1760121 | C_mothermar_y | 2 | .0311255 .0577674 0.54 0.590 -.0821043 .1443553 3 | .0070032 .0835212 0.08 0.933 -.1567065 .170713 4 | -.0286678 .0350783 -0.82 0.414 -.0974247 .0400892 5 | -.1179898 .2767082 -0.43 0.670 -.6603651 .4243854 | _cons | .6588401 .0494201 13.33 0.000 .5619718 .7557083 -----------------------------------+---------------------------------------------------------------- sigma_u | .90804604 sigma_e | .75347921 rho | .59222892 (fraction of variance due to u_i) ---------------------------------------------------------------------------------------------------- F test that all u_i=0: F(10997, 17713) = 3.54 Prob > F = 0.0000 . xtreg child_weight parental_unemploymenti.C_region_y i.year i.C_Simplemotherage_y i.C_Simplemothereduca_y i.C_mothermar_y, cluster > (id) fe Fixed-effects (within) regression Number of obs = 28,723 Group variable: id Number of groups = 10,998 R-sq: Obs per group: within = 0.0476 min = 1 between = 0.0001 avg = 2.6 overall = 0.0139 max = 3 F(12,10997) = 101.16 corr(u_i, Xb) = -0.0137 Prob > F = 0.0000 (Std. Err. adjusted for 10,998 clusters in id) ---------------------------------------------------------------------------------------------------- | Robust child_weight | Coef. Std. Err. t P>|t| [95% Conf. Interval] -----------------------------------+---------------------------------------------------------------- parental_unemployment| .0446502 .019911 2.24 0.025 .0056211 .0836794 1.C_region_y | .0057119 .0286117 0.20 0.842 -.0503723 .061796 | year | 1 | .1893615 .0122001 15.52 0.000 .165447 .2132759 2 | -.1486756 .0151289 -9.83 0.000 -.178331 -.1190202 | C_Simplemotherage_y | 30-39 | .0065484 .02654 0.25 0.805 -.0454747 .0585715 40 or more | -.0054981 .037494 -0.15 0.883 -.0789932 .0679969 | C_Simplemothereduca_y | Leaving Certificate to Non Degree | .0795771 .048462 1.64 0.101 -.0154172 .1745714 Primary Degree or greater | .067113 .0577993 1.16 0.246 -.046184 .1804101 | C_mothermar_y | 2 | .0311255 .0577588 0.54 0.590 -.0820921 .1443432 3 | .0070032 .0815093 0.09 0.932 -.1527698 .1667762 4 | -.0286678 .0367906 -0.78 0.436 -.100784 .0434485 5 | -.1179898 .2688433 -0.44 0.661 -.6449709 .4089913 | _cons | .6588401 .0523982 12.57 0.000 .5561303 .7615499 -----------------------------------+---------------------------------------------------------------- sigma_u | .90804604 sigma_e | .75347921 rho | .59222892 (fraction of variance due to u_i) ----------------------------------------------------------------------------------------------------
Code:
. xtlogit child_overweight parental_unemployment i.C_region_y i.year i.C_Simplemotherage_y i.C_Simplemothereduca_y i.C_ > mothermar_y, fe nolog note: multiple positive outcomes within groups encountered. note: 9,053 groups (23,188 obs) dropped because of all positive or all negative outcomes. Conditional fixed-effects logistic regression Number of obs = 5,535 Group variable: id Number of groups = 1,945 Obs per group: min = 2 avg = 2.8 max = 3 LR chi2(12) = 238.71 Log likelihood = -1895.8084 Prob > chi2 = 0.0000 ---------------------------------------------------------------------------------------------------- child_overweight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -----------------------------------+---------------------------------------------------------------- parental_unemployment| .2703107 .1005604 2.69 0.007 .073216 .4674055 1.C_region_y | -.01998 .1507955 -0.13 0.895 -.3155338 .2755738 | year | 1 | .3139058 .0597481 5.25 0.000 .1968016 .43101 2 | -.5732491 .0756048 -7.58 0.000 -.7214318 -.4250664 | C_Simplemotherage_y | 30-39 | -.0116609 .1240282 -0.09 0.925 -.2547516 .2314298 40 or more | -.1112382 .1878247 -0.59 0.554 -.4793678 .2568914 | C_Simplemothereduca_y | Leaving Certificate to Non Degree | .4152802 .2192234 1.89 0.058 -.0143897 .8449501 Primary Degree or greater | .494528 .280466 1.76 0.078 -.0551753 1.044231 | C_mothermar_y | 2 | -.0497614 .2948567 -0.17 0.866 -.6276699 .5281471 3 | -.3611571 .4263245 -0.85 0.397 -1.196738 .4744236 4 | -.1193666 .1744257 -0.68 0.494 -.4612347 .2225015 5 | .7634075 1.06593 0.72 0.474 -1.325777 2.852592 ---------------------------------------------------------------------------------------------------- . margins, dydx(parental_unemployment) post Average marginal effects Number of obs = 5,535 Model VCE : OIM Expression : Pr(child_overweight |fixed effect is 0), predict(pu0) dy/dx w.r.t. : parental_unemployment --------------------------------------------------------------------------------------------- | Delta-method | dy/dx Std. Err. z P>|z| [95% Conf. Interval] ----------------------------+---------------------------------------------------------------- parental_unemployment| .0636173 .0236439 2.69 0.007 .017276 .1099585 --------------------------------------------------------------------------------------------- . clogit child_overweight parental_unemployment i.C_region_y i.year i.C_Simplemotherage_y i.C_Simplemothereduca_y i.C_mo > thermar_y, cluster (id) group(id) nolog note: multiple positive outcomes within groups encountered. note: 9,053 groups (23,188 obs) dropped because of all positive or all negative outcomes. Conditional (fixed-effects) logistic regression Number of obs = 5,535 Wald chi2(12) = 263.94 Prob > chi2 = 0.0000 Log pseudolikelihood = -1895.8084 Pseudo R2 = 0.0592 (Std. Err. adjusted for 1,945 clusters in id) ---------------------------------------------------------------------------------------------------- | Robust child_overweight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -----------------------------------+---------------------------------------------------------------- parental_unemployment | .2703107 .0994143 2.72 0.007 .0754623 .4651592 1.C_region_y | -.01998 .1528584 -0.13 0.896 -.3195769 .2796169 | year | 1 | .3139058 .0607449 5.17 0.000 .194848 .4329637 2 | -.5732491 .0784456 -7.31 0.000 -.7269997 -.4194985 | C_Simplemotherage_y | 30-39 | -.0116609 .1317873 -0.09 0.929 -.2699592 .2466374 40 or more | -.1112382 .1918091 -0.58 0.562 -.4871771 .2647007 | C_Simplemothereduca_y | Leaving Certificate to Non Degree | .4152802 .2267121 1.83 0.067 -.0290673 .8596277 Primary Degree or greater | .494528 .2943118 1.68 0.093 -.0823125 1.071368 | C_mothermar_y | 2 | -.0497614 .2919635 -0.17 0.865 -.6219994 .5224765 3 | -.3611571 .3862521 -0.94 0.350 -1.118197 .3958831 4 | -.1193666 .1801217 -0.66 0.508 -.4723987 .2336655 5 | .7634075 1.114672 0.68 0.493 -1.421309 2.948124 ---------------------------------------------------------------------------------------------------- . margins, dydx(parental_unemployment) post Average marginal effects Number of obs = 5,535 Model VCE : Robust Expression : Pr(child_overweight |fixed effect is 0), predict(pu0) dy/dx w.r.t. : parental_unemployment --------------------------------------------------------------------------------------------- | Delta-method | dy/dx Std. Err. z P>|z| [95% Conf. Interval] ----------------------------+---------------------------------------------------------------- parental_unemployment| .0636173 .0234081 2.72 0.007 .0177382 .1094963 ---------------------------------------------------------------------------------------------
Thanks for your help,
John
0 Response to Why doesn't clustering change anything?
Post a Comment