Hi Statalisters,
I would like to test the difference between interaction coefficients produced by the -margins- command and report that test in a marginsplot using Stata 13 (i.e. visualizing the difference as well as reporting a test in the same graph). I have used the suggested -test- postestimation command, but in many cases the Wald tests leave me with significant results where the confidence intervals calculated by -margins- are overlapping quite a bit.
The following code snippet illustrates what I have been trying to do using an example dataset.
This is the output from -margins- and -test-:
In the example above the upper bound for the year-union interaction for 1983 (1.90) is overlapping the lower bound for 1985 (1.88) while the Wald test is significant at the 95 percent level.
Any suggestions on how to reproduce the nonsignificant difference (according to the current -margins- setup)?
Thank you in advance!
Elias Markstedt
I would like to test the difference between interaction coefficients produced by the -margins- command and report that test in a marginsplot using Stata 13 (i.e. visualizing the difference as well as reporting a test in the same graph). I have used the suggested -test- postestimation command, but in many cases the Wald tests leave me with significant results where the confidence intervals calculated by -margins- are overlapping quite a bit.
The following code snippet illustrates what I have been trying to do using an example dataset.
Code:
use http://www.stata-press.com/data/r13/nlswork, clear xtset idcode year qui xtreg ln_wage i.year##union, fe vce(cl idcode) margins i.year##union if union==1 & (year==83 | year==85), post test _b[83.year#1.union]=_b[85.year#1.union] mat p=r(p) local p: di %4.2f p[1,1] marginsplot, note("Test of difference: p=`p'")
Code:
. margins i.year##union if union==1 & (year==83 | year==85), post Predictive margins Number of obs = 922 Model VCE : Robust Expression : Linear prediction, predict() Delta-method Margin Std. Err. z P>z [95% Conf. Interval] year 83 1.871275 .0137086 136.50 0.000 1.844407 1.898143 85 1.905756 .0132669 143.65 0.000 1.879754 1.931759 1.union 1.891021 .0108374 174.49 0.000 1.86978 1.912262 year#union 83 1 1.871275 .0137086 136.50 0.000 1.844407 1.898143 85 1 1.905756 .0132669 143.65 0.000 1.879754 1.931759 . test _b[83.year#1.union]=_b[85.year#1.union] ( 1) 83bn.year#1.union - 85.year#1.union = 0 chi2( 1) = 4.57 Prob > chi2 = 0.0325
Any suggestions on how to reproduce the nonsignificant difference (according to the current -margins- setup)?
Thank you in advance!
Elias Markstedt