0

I am looking for the ccf of two time series objects: energy consumption and gdp. I have fitted an ARIMA model to gdp time series and prewhiten as an aid to interpreting the ccf. An error is shown:

Error in arima(energy$consumption, model = gdp.model) : 
  unused argument (model = gdp.model)

I am using the following code:

energy <- data.frame(consumption = c(3319,2986,3234,3362,4146,5355,8421,9163,4867,3668,3378,3409,3250,2867,3067,2965,3490,5557,8985,8693,5548,3786,3373,3369,3241,3107,3212,3067,3398,6010,9236,9059,5067,4104,3344,3460,3176,2910,3190,3241,4401,5489,7501,8714,5733,3810,3309,3387,3216,2282,3157,3398,3904,5537,8326,8384,4463,3797,3322,3417,3224,2797,3201,3055,4695,4939,7926,8690,5297,3826,3221,3311,3229,2802,3082,3594,3870,5493,8294,8718,4611,3799,3211,3303,3322,2828,2899,3210,4044,5393,7430,8748,5099,3116,3133,3196,3078,2768,2863,3418,4033,4938,6379,7845,5106,3679,3310,3337))
gdp <- data.frame(value = c(17751,17751,17751,18138,18138,18138,18092,18092,18092,18110,18110,18110,15833,15833,15833,16547,16547,16547,16696,16696,16696,15698,15698,15698,14500,14500,14500,15180,15180,15180,15451,15451,15451,15056,15056,15056,13726,13726,13726,14681,14681,14681,15229,15229,15229,14901,14901,14901,13846,13846,13846,14770,14770,14770,15413,15413,15413,14915,14915,14915,13823,13823,13823,14776,14776,14776,15119,15119,15119,14984,14984,14984,13583,13583,13583,14606,14606,14606,15362,15362,15362,14864,14864,14864,13633,13633,13633,14791,14791,14791,15846,15846,15846,14892,14892,14892,13850,13850,13850,15033,15033,15033,16091,16091,16091,15111,15111,15111,13896,13896,13896,15336,15336,15336,16680,16680,16680,15289,15289,15289,13694,13694,13694,12947,12947,12947,15119,15119,15119,14392,14392,14392))

gdp.model <- arima(gdp$value, order = c(0,1,0), seasonal = list(order = c(1,1,0), period = 12))
pwx <- residuals(gdp.model)
pwy <- residuals(arima(energy$consumption, model = gdp.model))
ccf(pwx,pwy,20)

Thank you in advance.

Edo
  • 7,567
  • 2
  • 9
  • 19
rdev
  • 1
  • 3
  • 1
    Please provide a [reproducible minimal example](https://stackoverflow.com/q/5963269/8107362). Especially, provide some sample data, e.g. with `dput()` and use the [reprex-package](https://reprex.tidyverse.org/). – mnist Sep 10 '21 at 08:54

1 Answers1

0

Your code is almost correct. However, to achieve your goal you shouldn't use the function arima, use Arima instead from the forecast package.

library(forecast)

gdp.model <- Arima(gdp$value, order = c(0,1,0), seasonal = list(order = c(1,1,0), period = 12))
pwx <- residuals(gdp.model)
pwy <- residuals(Arima(energy$consumption, model = gdp.model))
ccf(pwx,pwy,20)

The model argument is described in the forecast::Arima function this way:

Output from a previous call to Arima. If model is passed, this same model is fitted to y without re-estimating any parameters.

Edo
  • 7,567
  • 2
  • 9
  • 19
  • If this is the solution you're looking for you can accept the answer. It would be more useful for other users too. – Edo Sep 10 '21 at 10:41