Kiwi - 1 year ago 187

R Question

I am trying to use prewhiten function(TSA package) in my time series forecasting model. But i am getting below error:

`Error in UseMethod("filter_") : no applicable method for 'filter_' applied to`

an object of class "c('double', 'numeric')"

I have no clue about this error. For example if i try to run example given in TSA package pdf(page number 50). I get the same error. Below is the code quoted from the same pdf:

`data(milk)`

data(electricity)

milk.electricity=ts.intersect(milk,log(electricity))

plot(milk.electricity,yax.flip=TRUE,main='')

ccf(as.numeric(milk.electricity[,1]),as.numeric(milk.electricity[,2]),

main='milk & electricity',ylab='CCF')

me.dif=ts.intersect(diff(diff(milk,12)),diff(diff(log(electricity),12)))

prewhiten(as.numeric(me.dif[,1]),as.numeric(me.dif[,2]),

,ylab='CCF')

Can anyone please help me with this error? Thanks!

Answer Source

The code above works for me.

However, I suspect that you have loaded another package before running this piece of code. In particular, if I load **dplyr** first

```
library(dplyr)
```

then I can reproduce your error.