我现在有某病检出率的数据,是从2016-2020年的,因为2020年疫情的关系,时序数据前后性质不一,如果直接用arima进行拟合,Box_test()残差检验通不过,预测值也不理想。用TSA包中的arimax进行时序数据干预模型分析,用forecast()进行预测时则会报错,请问各位大神应该如何处理。
library(tidyverse)
library(TSA)
tsII <- ts(c(0,
0 ,0 ,0 ,3.57 ,6.49 ,0 ,16.03 ,4.44 ,7.32 ,0 ,0 ,0 ,0 ,0 ,0 ,2.94 ,12.33 ,5 ,16.43 ,10.28 ,2.13 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,5.82 ,6.14 ,6.67 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,11.11 ,2.44 ,16 ,17 ,9.52 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,7.14 ,13.08 ,0 ,3.85 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,4.76 ,0 ,5.71 ,3.7 ,0 ,0 ,0 ),
start = c(2015, 1), frequency = 12)
fit_ts_1520 <- arimax(tsII,
order=c(0,0,0),
seasonal=list(order=c(2,1,1),period=12),
xtransf=data.frame(I2020=1*(seq(tsII) > 60),I2020=1*(seq(tsII) > 60)),
transfer=list(c(0,0),c(1,0)),
method='ML')
forecast(fit_ts_1520, 12)