Dear all,
In the multilevel logistic regression that appears below there is an interaction between two categorical variables: gender ('female') and father's education ('fisced4'). I am interested in generating the contrast of the marginal effect of gender for the highest and lowest categories of father's education. The dependent variable in the model is the respondent's expectation of university graduation (yes/no)
I am interested in the difference of the marginal effect of gender for the highest (fisced4==1) and lowest (fisced4==1) category of father's education. Here I generate the marginal effect of gender for these two categories of father's education
The following command allows to get the contrast of the marginal effect of female for each category of father's education. It is easy to see that 0.0993029 (below) is the difference between 0.510501 and 0.6098038 (above), and so 0.0369504 is the difference between 0.7360576 and 0.7730081. But what I really want is the contrast between these two contrasts.
Quite unfortunately, I have not been able to see how I can get this contrast of contrasts. The closest I have got to my objective is the order the output below. But what appears there as the contrast between the difference in the marginal effect of gender for the two categories I am interested in (University and Lower secondary education or less) is -0.0755766, which is not the exactly the same as the difference between .0993029 and .0369504 in the output above, which is is -0,0623525
I would appreciate your help in guiding me to what I am doing wrong. Or just to tell me how could I proceed to generate the contrast of contrasts that I am looking for.
At any rate, many thanks for your attention
And my apologies for this post/question, if it sounds too silly
Kind regards
Luis
In the multilevel logistic regression that appears below there is an interaction between two categorical variables: gender ('female') and father's education ('fisced4'). I am interested in generating the contrast of the marginal effect of gender for the highest and lowest categories of father's education. The dependent variable in the model is the respondent's expectation of university graduation (yes/no)
HTML Code:
. xtmelogit expect_ISCED5A immig3 famstruc3 Above_mode Below_mode PV1MATH PV1READ positive_att media_educ media_socio i.female i.fisced4 female#fisced4 if fisced4! > =5 & country3==1 || schoolid:, variance Refining starting values: Iteration 0: log likelihood = -5389.6352 Iteration 1: log likelihood = -5317.5182 Iteration 2: log likelihood = -5313.6034 Performing gradient-based optimization: Iteration 0: log likelihood = -5313.6034 Iteration 1: log likelihood = -5313.5992 Iteration 2: log likelihood = -5313.5992 Mixed-effects logistic regression Number of obs = 10,951 Group variable: schoolid Number of groups = 318 Obs per group: min = 5 avg = 34.4 max = 50 Integration points = 7 Wald chi2(16) = 2030.96 Log likelihood = -5313.5992 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------------- expect_ISCED5A | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------------+---------------------------------------------------------------- immig3 | .8634354 .0683085 12.64 0.000 .7295532 .9973176 famstruc3 | -.1151503 .0531898 -2.16 0.030 -.2194003 -.0109002 Above_mode | -.3661431 .0679251 -5.39 0.000 -.4992739 -.2330123 Below_mode | .1379749 .0903702 1.53 0.127 -.0391474 .3150973 PV1MATH | .0051991 .0004413 11.78 0.000 .0043342 .006064 PV1READ | .0062065 .000444 13.98 0.000 .0053362 .0070768 positive_att | .2168908 .0127588 17.00 0.000 .1918841 .2418975 media_educ | .3444196 .1223408 2.82 0.005 .104636 .5842032 media_socio | .0089023 .0091878 0.97 0.333 -.0091055 .0269101 1.female | .5426424 .0962686 5.64 0.000 .3539595 .7313254 | fisced4 | Upper sec | .1404945 .0878903 1.60 0.110 -.0317673 .3127562 Upper vocational | .4624856 .1193588 3.87 0.000 .2285468 .6964245 University | 1.310903 .1008359 13.00 0.000 1.113269 1.508538 | female#fisced4 | 1#Upper sec | .2527055 .1218969 2.07 0.038 .013792 .4916191 1#Upper vocational | .0794333 .1683598 0.47 0.637 -.2505458 .4094124 1#University | -.2824504 .143058 -1.97 0.048 -.5628389 -.0020619 | _cons | -11.09274 .4027278 -27.54 0.000 -11.88207 -10.30341 ------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ schoolid: Identity | var(_cons) | .1779039 .0310618 .1263475 .250498 ------------------------------------------------------------------------------ LR test vs. logistic model: chibar2(01) = 83.24 Prob >= chibar2 = 0.0000
HTML Code:
. margins female, at(fisced4==(1 4)) predict(mu fixedonly) vsquish level(90) Predictive margins Number of obs = 10,951 Expression : Predicted mean, fixed portion only, predict(mu fixedonly) 1._at : fisced4 = 1 2._at : fisced4 = 4 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [90% Conf. Interval] -------------+---------------------------------------------------------------- _at#female | 1 0 | .510501 .0139698 36.54 0.000 .4875226 .5334793 1 1 | .6098038 .0123391 49.42 0.000 .5895078 .6300999 2 0 | .7360576 .0114656 64.20 0.000 .7171983 .7549169 2 1 | .7730081 .011907 64.92 0.000 .7534228 .7925933 ------------------------------------------------------------------------------
HTML Code:
. margins r.female, at(fisced4==(1 4)) predict(mu fixedonly) vsquish level(90) Contrasts of predictive margins Expression : Predicted mean, fixed portion only, predict(mu fixedonly) 1._at : fisced4 = 1 2._at : fisced4 = 4 ------------------------------------------------ | df chi2 P>chi2 -------------+---------------------------------- female@_at | (1 vs 0) 1 | 1 31.95 0.0000 (1 vs 0) 2 | 1 5.57 0.0183 Joint | 2 36.19 0.0000 ------------------------------------------------ -------------------------------------------------------------- | Delta-method | Contrast Std. Err. [90% Conf. Interval] -------------+------------------------------------------------ female@_at | (1 vs 0) 1 | .0993029 .0175684 .0704054 .1282003 (1 vs 0) 2 | .0369504 .01566 .011192 .0627089 --------------------------------------------------------------
HTML Code:
. margins, dydx(female) over(r.fisced4) predict(mu fixedonly) vsquish level (90) post Contrasts of average marginal effects Expression : Predicted mean, fixed portion only, predict(mu fixedonly) dy/dx w.r.t. : 1.female over : fisced4 ---------------------------------------------------------------------------- | df chi2 P>chi2 -----------------------------------------+---------------------------------- 0b.female | fisced4 | (Upper sec vs Lower sec or less) | (omitted) (Upper vocational vs Lower sec or less) | (omitted) (University vs Lower sec or less) | (omitted) Joint | (omitted) -----------------------------------------+---------------------------------- 1.female | fisced4 | (Upper sec vs Lower sec or less) | 1 4.13 0.0422 (Upper vocational vs Lower sec or less) | 1 0.04 0.8326 (University vs Lower sec or less) | 1 12.88 0.0003 Joint | 3 47.43 0.0000 ---------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ | Contrast Delta-method | dy/dx Std. Err. [90% Conf. Interval] -----------------------------------------+------------------------------------------------ 1.female | fisced4 | (Upper sec vs Lower sec or less) | .0464048 .0228389 .0088381 .0839715 (Upper vocational vs Lower sec or less) | .0063775 .0301635 -.043237 .055992 (University vs Lower sec or less) | -.0755766 .021062 -.1102204 -.0409327 ------------------------------------------------------------------------------------------ Note: dy/dx for factor levels is the discrete change from the base level.
At any rate, many thanks for your attention
And my apologies for this post/question, if it sounds too silly
Kind regards
Luis
Comment