I have a mixed-effects logistic model with two primary factors (two levels each) of interest; period and DMT_eff. I can calculate margins and pairwise comparisons simple enough:
But I also want to be able to calculate the marginal (probability) difference of differences (e.g. -.3060024 - -.3359608 = 0.0299584). I have tried the following:
The contrast command above reproduces the output from the regression model for the interaction term, but displays the estimate as the linear predictor. The margins command below it seems to display the correct probability estimate but the SE, p value, CI don't appear to be correct.
How do I do this?
Code:
. margins period#DMT_eff Predictive margins Number of obs = 2,410 Model VCE: OIM Expression: Marginal predicted mean, predict() -------------------------------------------------------------------------------- | Delta-method | Margin std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- period#DMT_eff | pre#low | .5094355 .0216589 23.52 0.000 .4669848 .5518862 pre#high | .2034331 .0158642 12.82 0.000 .1723399 .2345263 post#low | .4436992 .0230592 19.24 0.000 .398504 .4888943 post#high | .1077383 .0114164 9.44 0.000 .0853626 .1301141 -------------------------------------------------------------------------------- . margins period#DMT_eff, pwcompare(effects) Pairwise comparisons of predictive margins Number of obs = 2,410 Model VCE: OIM Expression: Marginal predicted mean, predict() -------------------------------------------------------------------------------------------- | Delta-method Unadjusted Unadjusted | Contrast std. err. z P>|z| [95% conf. interval] ---------------------------+---------------------------------------------------------------- period#DMT_eff | (pre#high) vs (pre#low) | -.3060024 .027144 -11.27 0.000 -.3592036 -.2528012 (post#low) vs (pre#low) | -.0657363 .0293404 -2.24 0.025 -.1232425 -.0082302 (post#high) vs (pre#low) | -.4016972 .0245983 -16.33 0.000 -.449909 -.3534854 (post#low) vs (pre#high) | .2402661 .0292099 8.23 0.000 .1830156 .2975165 (post#high) vs (pre#high) | -.0956948 .0191122 -5.01 0.000 -.133154 -.0582355 (post#high) vs (post#low) | -.3359608 .0259999 -12.92 0.000 -.3869198 -.2850019 --------------------------------------------------------------------------------------------
Code:
. contrast period#DMT_eff, effects Contrasts of marginal linear predictions Margins: asbalanced -------------------------------------------------- | df chi2 P>chi2 ---------------+---------------------------------- initiation_bin | period#DMT_eff | 1 5.23 0.0222 -------------------------------------------------- ------------------------------------------------------------------------------------------------ | Contrast Std. err. z P>|z| [95% conf. interval] -------------------------------+---------------------------------------------------------------- initiation_bin | period#DMT_eff | (post vs base) (high vs base) | -.5313962 .2324251 -2.29 0.022 -.9869412 -.0758513 ------------------------------------------------------------------------------------------------ . margins r.DMT_eff#r.period, contrast(effects) Contrasts of predictive margins Number of obs = 2,410 Model VCE: OIM Expression: Marginal predicted mean, predict() -------------------------------------------------- | df chi2 P>chi2 ---------------+---------------------------------- DMT_eff#period | 1 0.76 0.3833 -------------------------------------------------- ---------------------------------------------------------------------------------------------- | Delta-method | Contrast std. err. z P>|z| [95% conf. interval] -----------------------------+---------------------------------------------------------------- DMT_eff#period | (high vs low) (post vs pre) | -.0299584 .0343603 -0.87 0.383 -.0973034 .0373865 ----------------------------------------------------------------------------------------------
How do I do this?
Comment