# Filtering using a SARIMA model in R

I am not an expert in statistics, but I would like to work on a SARIMAX model representing power consumption. The exogeneous variable would be the temperature, but for now I found here I might need to do some cross-correlation study to go further.

It is also explained that in order to work on these correlated series I would need to "whiten" the temperature series. I did it by finding a SARIMA(0,1,1)(0,1,1) model for the series and collecting the residuals. As explained there, the goal is to now filter my power series with the coefficients found for the SARIMA model of the temperature series. My problem is, on this webpage there is only an example for an ARIMA(1,1,0) model. It leads to - with B being the backshift operator :

(1 - 0.7445B)(1 - B)(x_t - μ) = w_t.


And :

result = filter(y, filter = c(1,-1.7445,.7445), sides =1)


Thing is with my SARIMA model, I obtain something along :

x_t = (1 - a)(1 - b*B^144)w_t


So I would like to know how I can make the filterfunction work, or how I can input my coefficients into the Arima one since I didn't really understand what was explained in this topic.

Regards.

For a general ARIMA model you can follow the code in the link that you gave. You can apply what is discussed here by changing the line

newpwy = filter(y, filter = c(1,-1.7445,.7445), sides = 1)


by

require(forecast)
newpwy <- residuals(Arima(y, model = fitted.model))


where fitted.model is the model that you fitted (in the original code it is called ar1model but you may have given a different name to it).

• Hi, thanks for the answer, I had tried to do as you said but got an error. I tried it again and it worked. I took a sample of size 100 instead of 1100 the first time and the error was : Error in stats::arima(x = x, order = order, seasonal = seasonal, include.mean = include.mean, : too few non-missing observations I didn't realize what it was about then... Thanks anyway, I guess I can go back to work ! Regards. – Ahnonym Jul 23 '14 at 14:44
• Maybe you took a differencing filter or ARMA model of order larger than 100, in that case lagged values are missing because there aren't enough observations. – javlacalle Jul 23 '14 at 15:56
• Yeah the differencing order was 144 for the seasonal part of the SARIMA model, didn't notice I wrote 100 instead of 1100 the first time ! – Ahnonym Jul 24 '14 at 7:26