Hello All,
I have data that, essentially, takes the following form:
Date var1 var2
x/x/xx 2 3
x/x/xx 2 2
x/x/xx 2 1
x/x/xx 3 5
x/x/xx 2 1
and so on. What I want to do is regress one variable on another for the previous y periods, and then have the regression beta be output as a variable in the dataset. For example, if I picked y = 5, I would take an observation, regress var1 on var2 for the past 5 periods, and then the code would return that regression coefficient as a variable in the dataset.
I may have done a bad job explaining this, but if you have any questions, please let me know.
Thanks,
John