Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have two time-series, x and y. I would like to prewhiten x by fitting an ARMA(p,q) (or in my case ARMA(1,1)) process and then use the coefficients to filter y. This seems like a pretty standard thing to want to do. However, the stats:::filter function does only MA or AR filtering it looks like. What is the appropriate way to do this? Also, should one use the arima function in R to do this or are there other ways?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I think this does what you want:

library(forecast)
fit <- Arima(x,order=c(1,0,1))
yfiltered <- residuals(Arima(y,model=fit))
share|improve this answer
    
could you please explain how Arima with model parameter works? in particular: if i filter x with $(1-aL)x_{t} = (1-bL)\varepsilon_{t}$, this can be accomplished by fit <- Arima(x,order=c(1,0,1)), correct? Then when I run residuals(Arima(y,model=fit)), does this produce $y_{t}-[(1-aL)y_{t} - (1-bL)u_{t}]$ where $u_{t}$ are residuals of $(1-aL)y_{t})$? –  Alex Nov 12 '12 at 21:03
    
Yes. See help file: "model: Output from a previous call to Arima. If model is passed, this same model is fitted to x without re-estimating any parameters." –  Rob Hyndman Nov 12 '12 at 22:51
    
yes, took a look. was having trouble udnerstanding what was meant by residuals. think i have it now. thanks! –  Alex Nov 12 '12 at 23:07
add comment

I suggest three different functions:

stats:::arima

forecast:::Arima

forecast:::auto.arima

forecast:::auto.arima will automatically seelct the p and q lags for you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.