0

我正在寻找ccf两个时间序列对象中的一个:能源消耗和 gdp。我已经为 gdp 时间序列拟合了一个 ARIMA 模型,并 prewhiten 作为解释ccf. 显示错误:

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

我正在使用以下代码:

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)

先感谢您。

4

1 回答 1

0

您的代码几乎是正确的。但是,为了实现您的目标,您不应该使用该功能arimaArima而是使用forecast包中的。

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)

model参数在函数中是这样描述的forecast::Arima

先前调用 Arima 的输出。如果传递了模型,则将同一模型拟合到 y 而不重新估计任何参数。

于 2021-09-10T10:03:42.653 回答