[R] Access column after hp filter

Pascal Oettli kridox at ymail.com
Sun Mar 16 07:42:59 CET 2014


Dear Sabina,

If you carefully read the help page (always a good idea), examples
show you that it is "object$cycle", not "object$Cycle". Also, you can
use names, i.e. names(e.hp$).

HTH,
Pascal

On Sun, Mar 16, 2014 at 12:56 AM, Liana-Sabina Luncasu
<lianasabinaluncasu at gmail.com> wrote:
> Dear all,
>
> I am working with some time series data and I applied an HP filter to it
> using the following code:
>
> e.hp = hpfilter(empl)
>
> Now I am trying to access the last column (Cycle), that is, to save it in a
> separate vector. I tried with both e.hp$Cycle and e.hp[ , 3] but none of
> them works. I get the following:
>
>> e.hp$Cycle
> NULL
>> e.hp[,3]
> Error in e.hp[, 3] : incorrect number of dimensions
>
>
> Does anyone have any solution?
>
> Thank you in advance.
>
> Sabina
>
> P.S. Below I provide the result of the hpfilter
>
>> e.hp
>
> Title:
>  Hodrick-Prescott Filter
>
> Call:
>  hpfilter(x = empl)
>
> Method:
>  hpfilter
>
> Filter Type:
>  lambda
>
> Series:
>  empl
>
>          empl Trend     Cycle
> 1980 Q1 929.6 929.9 -0.294800
> 1980 Q2 929.8 930.1 -0.255385
> 1980 Q3 930.3 930.2  0.105146
> 1980 Q4 931.4 930.4  1.061102
> 1981 Q1 932.7 930.5  2.142883
> 1981 Q2 933.6 930.7  2.879701
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan




More information about the R-help mailing list