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
How to modify individual graph's title on combined graphDear Stata users, Suppose we have a combined graph that is composed of two individual graphs, let's …
tvgc - time-varying granger causalityHow can I solve this error in Stata? tvgc_cv(): 3499 mm_quantile() not found <istmt>: - funct…
Survival analysis with inverse probability weighting after multiple imputationDear Statalist-users, Hopefully, there is someone who can help me with the following: I'm trying to…
Plot of Interaction TermI am trying to use margins and marginsplot to plot the effect of X1 in a regression as follows: Y=a…
Creating a loop to count the weeks before and after a policyHi, I'm working on understanding the impact of a hospital policy on healthcare utilization. The pol…
Subscribe to:
Post Comments (Atom)
0 Response to HP filter in panel data
Post a Comment