I have a dataset which has 10000 observations. For each obs, I want to
create a regression model (based on variable x and y in the dataset) using
previous 20 observations and save the estimated slope as a new variable in
the dataset. Totally, I will have 9980 slopes.
Can someone show me how to do this efficiently?