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
In need of help with Survey data analysis, survey settings/svysetHello there I am trying to perform a multinominal logistic regression using survey data and having t…
Tempfile and error due to "spaces" at the end of a do-file lineHello to everyone. I really hope someone can help me with this. I have a dataset in which I am runni…
Edit graph with codeI've got 20 .gph files and I need to change the titles on all of them. Can I do that with Stata comm…
Fixed effects and instrumental variablesHello all, I have 3 years of cross sectional data of which 2 years have information on my independe…
Incorrect margins/pred. probabilities after ivprobit - instrument should be ignored?Hello, I am using the ivprobit command and want to calculate predicted probabilities with the margi…
Subscribe to:
Post Comments (Atom)
0 Response to First difference of a squared term
Post a Comment