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.

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.

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.

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.

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.

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.

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.