Dear all,
Following the advice provided by Vince Wiggins in a post in the old statalist I am estimating marginal effects and their standard errors for a continuos*categorical interaction in a logistic model using the contrast feature of the margins command and I am comparing the results I obtain with the estimates obtained using the predictnl command as suggested by Karaca-Mandic et al (2012). The problem is that while the estimate of the "size" of the interaction effect is the same the standard errors that I obtain are different.
Here you have my code and results (I am replicating some of the analyses of Karaca-Mandic, Norton and Dowd (2012) paper "Interaction Terms in Nonlinear Models" published in the Health Services Research journal)
My questions are the following:
1) Why do I obtain a different result if I estimate the standard errors of the interaction using the contrast features in margins (Std. Err = .001313) than if I do it with the predictnl command (Std. Err = .0016307)?
My hunch is that the difference is due to the fact that the standard errors estimated by margins are Delta-method standard errors while predictnl estimates a different kind of standard errors, but I am not completely sure.
2) Given these differences what is the best (most accurate) way of estimating the standard errors of this type of interactions (margins or predictnl)?
Thank you very much
Enrique
Following the advice provided by Vince Wiggins in a post in the old statalist I am estimating marginal effects and their standard errors for a continuos*categorical interaction in a logistic model using the contrast feature of the margins command and I am comparing the results I obtain with the estimates obtained using the predictnl command as suggested by Karaca-Mandic et al (2012). The problem is that while the estimate of the "size" of the interaction effect is the same the standard errors that I obtain are different.
Here you have my code and results (I am replicating some of the analyses of Karaca-Mandic, Norton and Dowd (2012) paper "Interaction Terms in Nonlinear Models" published in the Health Services Research journal)
Code:
. webuse margex, clear (Artificial data for margins) . generate female = (sex==1) . generate agefem = age*female . . * Using margins contrast feature . quietly: logit outcome c.age##i.female, nolog . margins r.female, dydx(age) Contrasts of average marginal effects Model VCE : OIM Expression : Pr(outcome), predict() dy/dx w.r.t. : age ------------------------------------------------ | df chi2 P>chi2 -------------+---------------------------------- age | female | 1 9.61 0.0019 ------------------------------------------------ -------------------------------------------------------------- | Contrast Delta-method | dy/dx Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ age | female | (1 vs 0) | .0040705 .001313 .001497 .0066439 -------------------------------------------------------------- . . * Using predictnl . quietly: logit outcome age female agefem, nolog . predictnl phat = (_b[age]+_b[agefem])* /// > (1/(1+exp(-(_b[_cons]+_b[age]*age+_b[female]+_b[agefem]*age))))* /// > (1-(1/(1+exp(-(_b[_cons]+_b[age]*age+_b[female]+_b[agefem]*age))))) /// > -_b[age]*(1/(1+exp(-(_b[_cons]+_b[age]*age))))* /// > (1-(1/(1+exp(-(_b[_cons]+_b[age]*age))))), se(phat_se) . . sum phat* Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- phat | 3,000 .0040705 .0022295 -.0022299 .0069318 phat_se | 3,000 .0016307 .0012906 .0003856 .0039043 . end of do-file
1) Why do I obtain a different result if I estimate the standard errors of the interaction using the contrast features in margins (Std. Err = .001313) than if I do it with the predictnl command (Std. Err = .0016307)?
My hunch is that the difference is due to the fact that the standard errors estimated by margins are Delta-method standard errors while predictnl estimates a different kind of standard errors, but I am not completely sure.
2) Given these differences what is the best (most accurate) way of estimating the standard errors of this type of interactions (margins or predictnl)?
Thank you very much
Enrique
Comment