Dear all,
I am working with a panel dataset and am trying to run a non-linear (quadratic) regression using the first difference operator (D.). Specifically, my regressors should be the first difference of the linear and quadratic independent variable. My issue is independent of the specific data used, therefore I just name Y my dependent and X my independent variables. The code would be:
gen X_sqr = X^2
reg d.Y d.X d.X_sqr
However, I need to use the command margins and marginsplot to plot how the marginal effect of X on Y varies at different levels of X. Therefore, I though about the following code:
reg d.Y d.(c.X##c.X)
Unfortunately, the output is not the first difference of the square but it is the square of the first difference. The same as if I typed the following:
reg d.Y d.c.X##d.c.X
I have tried to find a solution but the only relevant page I have found is the following:
https://www.statalist.org/forums/for...ferent-results
Where Clyde Schechter pointed out that this relationship is "not expressible with factor-variable notation". However, since this post is from 2014, I am asking again in case something has changed in the last 8 years. I know the marginal effect can be computed manually, but it is worth checking whether margins could be applicable in this context.
I have read the FAQ and tried to be as precise as possible. Apologies for any mistakes.
Thank you in advance to whoever will read this post.
Related Posts with First difference of a squared term
How to include Fixed Effects in a Diff-in-diff specification?I'm doing a difference-in-difference report on whether the EU Industrial Emissions Directive (implem…
Regression Results with "If" StatementI am trying to run a simple regression for a school assignment. The question asks me to run a regres…
New versions of bspline and polyspline on SSCThanks as always to Kit Baum, new versions of the packages bspline and polyspline are now available …
Combining Heckman with 2SLSDear Statalisters, I am interested in measuring the performance of imitative products. These produc…
Validity and Reliability of Instrumental VariableHi, I run a conditional logistic model. Dependent Variable: Financial status (a binary variable), …
Subscribe to:
Post Comments (Atom)
0 Response to First difference of a squared term
Post a Comment