I want to get the cross-correlation of two time series
y in R.
I have calculated an ARIMA model, and I can get the
mod1$residuals from signal
x. These residuals almost have no autocorrelation, so that's great.
xts <- ts(x,start=1,frequency=12) #convert to a time series library(fpp) #load forecasting package mod1 <- auto.arima(xts)
I now did the same procedure on signal
My question is: is this correct? Or should I somehow deduct the
mod1 (based on
y to de-trend it?
Secondly, I am confused about the order of operations. Should I prewhiten the data before calculating the model?
I found this code:
prewhiten(x, y, x.model = ar.res,ylab="CCF", ...)
Should I estimate the
mod1 first and then supply it to the function
prewhiten? And are
y the two time series? Many thanks!