# One-sided HP filter

Hi,

I hope I’m posting the question in the right part of the forum. Johannes Pfeifer discusses the one-sided HP filter in his guide to observation equations (thanks Johannes, I found it very useful) and mentions that the resulting de-trended variable will always have a mean of zero.
I have been using the add-in from Eviews to carry this out as well as the Matlab file from the file exchange and both yield identical, but not mean-zero, output. I could of course de-mean the result but it’s somewhat puzzling.

Does anyone have any suggestions?
Many thanks

Which Matlab file are you talking about? Most HP filters provide the trend component as the first argument. This one is not mean zero. Only the cyclical component is mean zero.

Dear Johannes,

All I did was
[Ytrend, Yobs] = one_sided_hp_filter_serial(log(Y))

where Yobs gives the cyclical component. Alternatively, Yobs = 100*(log(Y)-Ytrend) still gives the same output, which has a non-zero mean.

The Matlab file came from (ideas.repec.org/c/dge/qmrbcd/181.html) and the Eviews add-in (from their website) gives identical results.
us_gdp1.xls (33.5 KB)
one_sided_hp_filter_kalman.m (5.38 KB)

Because of the Kalman filtering approach, the sample mean of the trend component is always approximately zero (and not exactly zero as for HP-filtering) and becomes closer to zero the longer the data series (asymptotically). I will update the guide accordingly. Thanks for pointing this out.

Continuing the discussion from One-sided HP filter:

Hello, I also meet with this problem. After the one-side hp filter, the de-trended series of log gdp isn’t stationary and the mean isn’t zero either. This may be due to the low number of observations in my datafile. So should i demean the de-trended series(that is the hpcycle series)? However, after I demean the HPcycle series, it is still non stationary. My model is Log-linearisation, so the gdp is the log deviation from steady state. The observation series should also be mean zero and stationary. so how can i solve this problem?

What do you mean? Having a small non-zero constant is normal and can usually be tolerated. But having the data not be stationary is (almost) impossible. How do you judge it is not stationary?

Thanks for your reply. First I have the gdp data. Then I do the seasonal adjustment. After that I take the log form. The log gdp is stationary by the test of ADF using eviews. Then I use the one side hp filter to filter the log gdp and keep the cycle term by eviews. However, when i do the ADF test of the cycle terms, It shows that the p value is 0.34. So it is non stationary.

The real gdp data is as following. Really hope for your kind help.

2000-03 213.299
2000-06 248.8002441
2000-09 261.3800708
2000-12 294.7115773
2001-03 242.1917786
2001-06 272.8245636
2001-09 287.798543
2001-12 321.525367
2002-03 266.3359632
2002-06 300.1913481
2002-09 319.5012579
2002-12 356.0297806
2003-03 299.4649475
2003-06 333.6591504
2003-09 356.9139348
2003-12 392.2881064
2004-03 336.7250932
2004-06 378.3854757
2004-09 402.764045
2004-12 450.6723996
2005-03 384.3338654
2005-06 431.1500558
2005-09 458.3462072
2005-12 512.8031906
2006-03 443.3769955
2006-06 489.2228305
2006-09 510.9572225
2006-12 569.5431871
2007-03 504.7745339
2007-06 568.7419709
2007-09 595.716941
2007-12 661.2175279
2008-03 565.4562047
2008-06 644.9199349
2008-09 675.8111695
2008-12 736.5438709
2009-03 610.6191933
2009-06 699.456999
2009-09 743.0006542
2009-12 824.0493984
2010-03 706.8870209
2010-06 807.0640416
2010-09 847.8062136
2010-12 933.1525321
2011-03 799.8676755
2011-06 906.5173585
2011-09 954.0361671
2011-12 1038.3629
2012-03 867.7099621
2012-06 981.4559715
2012-09 1022.922083
2012-12 1116.171519
2013-03 939.0780889
2013-06 1045.355007
2013-09 1095.073391
2013-12 1204.353416
2014-03 994.0573082
2014-06 1110.144512
2014-09 1167.786636
2014-12 1274.847824
2015-03 1052.869064
2015-06 1179.183594
2015-09 1225.736222
2015-12 1335.101762
2016-03 1100.201755
2016-06 1240.229301
2016-09 1295.344785
2016-12 1432.873049

Have you tried logging before doing the seasonal adjustment? Note also that a failure to reject the Null of a unit root does not mean there must be a unit root. It could be type 2 error.

Thanks for your kind reply. Yes, I tried taking the log form before doing the seasonal adjustment. However, the ADF test of the cycle term still shows a p value of 0.33. Then I
test the unit root in the first difference, the p value is 0.00000. I agree with your viewpoint of type 2 error. But in statistics it is often hard to identify this error. My sample size is limited. And I think the p value is so high, if we want to reject the null hypothesis, the significance level α would be very high. So is it in some sense unreasonable? This is just my own thinking. Do you have any good idea to solve this problem and the type 2 error?

Please provide a plot of the final data after filtering. But I would not worry too much about this. From theory you know that the HP-filter should induce stationarity unless your data has really crazy properties.

Thanks for your reply. I upload the graph. The first is the cycle term. The second is the trend term. The third is the log form of the real gdp after seasonal adjustment.

the plot.pdf (24.1 KB)

That does not look to bad. I would accept the series as stationary.

OK. Thank you. The mean is not zero either. so should I demean it?

How big is the mean? I would tend to say no

The mean is -0.00649401.

Besides, is it due to the small sample size about the non stationary cycle term? And if i just want to remove the long-term trend, is it acceptable to use two side hp filter? After all, from the perspective of data processing, it is just a measure to get the data disposed. And the seasonal adjustment also use the moving averaging process to remove the seasonal feature.

1. That is -0.6% and sufficiently small, so I would not remove it.
2. No, you cannot use the two-sided filter for estimation.
3. You are right that in principle the same issue applies to seasonal adjustment. But here we have no true alternative.

Ok, I got it. Thank you so much. By the way, I have another question about estimation. The calvo price stickiness parameter is 0.28. Is it too small to accept when estimation?

Not necessarily. If we knew the answer ex ante, we would not need to do estimation. However, if you think that this is a sign of other problems in the model, I would check again.

Ok, I will check the model again. Besides, after estimation, I should use the post mean or post mode to do stochastic simulation? I see some posts that say it is better to use the mode.

I would to the mode. But it is a lot more common to do the mean of the statistic over the posterior draws instead of evaluating the statistic at a particular parameter value.