Hello,
I am working with panel data and I'd like to apply the Hodrick Prescott filter on a variable (v2x_polyarchy) for each country.
I have tried the following:
encode country_text_id, gen(countries)
xtset countries year
tsfilter hp cycle_dem = v2x_polyarchy, smooth(400) trend(hptrend_dem)
But it runs only for a couple of countries and this problem emerges:
Number of gaps in sample: 1 (gap count includes panel changes)
sample may not contain gaps
I have also tried to run a loop and that for each country the filter will be applied generating a different variable with each cycle.
encode country_text_id, gen(countries)
xtset countries year
foreach i in countries {
tsfilter hp cycle_dem_`i' = v2x_polyarchy, smooth(400) trend(hptrend_dem_`i')
}
But now the problem remains the same and only one variable is created (with the name cycle_dem_countries) instead of one for each country's cycle.
Could anyone please tell me what am I doing wrong?
Thnk you all
0 Response to HP filter in panel data
Post a Comment