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
Tabout+graph dummy variablesHi, I'd like to generate two, or three-way tables and graphs using tabout and graph, but without di…
Create change variable for timeseries data.Hi, my problem is twofold. I downloaded a database containing gvkey, sic code, year (1995 - 2005), y…
Omitted variable in logistic regressionHi , I have a problem with the Logit regression result in Stata. Some of the dummy variables have be…
combine Several observations to one observation in a given yearDear all, I need to get the SUM of Var 1. for each ID observation in 2016, for example, A person w…
How to do a special histogram like this in Stata?Hello, I saw a histogram by group like below. I want to use the classical Stata data auto.dta to mim…
Subscribe to:
Post Comments (Atom)
0 Response to First difference of a squared term
Post a Comment