Consider the following long-form panel data example:
Here, I want to regress Y[t] - Y[t-2] on X[t] - X[t-2] (I think, the meaning of Y[t] is clear)
That is, I need to conduct the second difference.
At the first time, I tried to use the D. operator like below:
But, you know, it is not what I want, because D2.Y is D.(D.Y) = Y[t] - 2Y[t-1] + Y[t-2].
So, is there any way to easily conduct the second (and higher order) difference in Stata?
Code:
mata: pid = (1::100) # J(3, 1, 1) period = J(100, 1, 1::3) Y = rnormal(300, 1, 0, 1) X = rnormal(300, 1, 0, 1) end getmata pid period Y X xtset pid period
That is, I need to conduct the second difference.
At the first time, I tried to use the D. operator like below:
Code:
reg D2.(Y X)
So, is there any way to easily conduct the second (and higher order) difference in Stata?
Comment