How one-step ahead forecast by using Hodrick-Prescott filter in r

by Hasi   Last Updated June 30, 2018 11:19 AM

library(mFilter)
data(unemp)
str(unemp)
Time-Series [1:168] from 1959 to 2001: 5.83 5.1 5.27 5.6 5.13 ...
fithp <- hpfilter(unemp, freq=12,type="frequency",drift=TRUE)
str(fithp)
List of 10 $ cycle : Time-Series [1:168] from 1959 to 2001: 0.436 -0.268 -0.103 0.185 -0.374 ... $ trend : Time-Series [1:168] from 1959 to 2001: 5.4 5.38 5.39 5.45 5.55 ...
$ fmatrix: num [1:168, 1:168] 0.4771 -0.3378 -0.187 -0.0804 -0.0147 ... $ title : chr "Hodrick-Prescott Filter"
$ xname : chr "unemp" $ call : language hpfilter(x = unemp, freq = 12, type = "frequency", drift = TRUE)
$ type : chr "frequency" $ lambda : num 13.9
$ method : chr "hpfilter" $ x : Time-Series [1:168] from 1959 to 2001: 5.83 5.11 5.29 5.63 5.18 ...
- attr(*, "class")= chr "mFilter"
predhp<-predict(fithp,n.ahead=1)
Error in is.constant(y) :(list) object cannot be coerced to type 'double'
Plz fix this problem..
Thanks in advance!



Related Questions



Predict future using machine learning

Updated June 27, 2017 17:19 PM

Time interval prediction

Updated February 17, 2018 14:19 PM