Many thanks to Nick Cox for writing egenmore. Minor comment. I have two series, Y and X, from years 1990-2015. I want to regress Y on lagged 5-year moving averages of X for the period 1995-2015. Data on Y is complete for the period. However, data on X is missing for 2015. I thought that could use egen filter (from Nick's suite egenmore) to create the 5-year moving averages as below:
. egen X_ma5 = filter(X), coef(1 1 1 1 1) lags(1/5)
and regress Y on X_ma5 for years up to and including 2015.
Note that the moving average command, lags(1/5), does not include the current observation. Still, because data for X is missing in the year 2015, egen would not create the X_ma5 for year 2015. I had to create a fake value,
. replace X = -10 if year == 2015
and then egen created the X_ma5 for year 2015 as well.
Note: I'm using Stata-15.
Question: Did I make a mistake or is their some option that I should set?
0 Response to egenmore: filter
Post a Comment