Dear Statalisters,
I have a panel data with 1500 id and 400 time. I'm trying to run Hodrick-Prescott filter for the time series for each id. The code that I'm currently running is:
This code works fine when I test it with small number of id, like 5. It just creates 2 new variables (trend and epsilon), for each id. However, when I run this with much higher number of id, this code takes forever to compute.
Is there a more efficient way of applying hpfilter on time series when my dataset is panel data? Ideally, I would just want 2 variables at the end, for trend and residuals of the trend for all id and all time.
I have seen another way of doing HP filter, through the command
but this did not allow me to use by() command.
Regards,
Hee Sung
I have a panel data with 1500 id and 400 time. I'm trying to run Hodrick-Prescott filter for the time series for each id. The code that I'm currently running is:
Code:
bys id (t): hprescott oldvar, stub(newvar) smooth(6.25)
Is there a more efficient way of applying hpfilter on time series when my dataset is panel data? Ideally, I would just want 2 variables at the end, for trend and residuals of the trend for all id and all time.
I have seen another way of doing HP filter, through the command
Code:
tsfilter hp newvar = oldvar, smooth()
Regards,
Hee Sung
Comment