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
Related Posts with HP filter in panel data
Summing the values over specific range of variablesHello. I have a dataset on weekly hours that individuals worked for each week of the years. For exa…
npregress series: How can I fit an additively seperable model with more than one variable per additive function?Hey, Im trying to fit a semiparametric model with npregress series. The model I want to fit should …
Lambert functionHi everyone, I would need to compute the Lambert function W(a) in Stata, but I cannot find a command…
Margins postHi all, I have the following problem: using the margins plot command to look at the graph between my…
Lagged response modelDear Statalisters, I am using a longitudinall dataset in which my main outcome is "QI score" (measu…
Subscribe to:
Post Comments (Atom)
0 Response to HP filter in panel data
Post a Comment