假设您有一个时间序列数据 42 个观察值。观察 7 到 13 有步进(水平移位)干预,观察 29 到 35 有 5 个单位的步进干预。其余观察值为 0。例如,请参见下表,了解具有实际和实际 + 误差的模拟数据。
如果您想使用 arima 传递函数将此数据建模为干预分析,您只需创建一个虚拟编码变量,其中 1 代表 7 到 13,1 代表 29 到 35,然后通过这是 ARIMAX 模型中的一步干预。我不知道如何使用 R 进行传递函数建模,所以我使用了 SAS。请参阅下面的实际数据和预测数据。ARIMAX 非常接近数据。请参阅下面我用来创建数据的 SAS 代码以及 ARIMAX。
如果您的第二次干预有第一次干预有衰减效应,您需要做的就是在第一步函数结束时创建第二次干预变量并对其进行适当的编码。
希望这有帮助。

data temp;
input actual @@;
error = rand("NORMAL");
datalines;
0 0 0 0 0 0 5
5 5 5 5 5 5 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
5 5 5 5 5 5 5
0 0 0 0 0 0 0
;
run;
data temp;
set temp;
actual_error = actual+error; *add random error;
if 7 <= _n_ <= 14 or 29 <= _n_ <= 35 then step = 1; * First Intervention step;
else step = 0;
run;
ods graphics on;
proc arima data = temp plots = all;
identify var=actual_error crosscorr = (step);
estimate input = (step) method = ml outest = mm1; /*Estimate Model using Transfer Function*/
forecast out = out1 lead = 0;
run;
ods graphics off;
编辑:由于 b_miner 想知道如何使用具有线性衰减的临时电平移位来对此进行建模,因此我修改了示例。我只展示了第一个电平转换,第二个电平转换可以很容易地添加。如果您正在寻找线性衰减以外的衰减,那么这很容易做到,只需使用使用传递函数的步进+渐变永久衰减函数即可。干预建模与其说是科学,不如说是一门艺术。你假设一个形状,测试假设,如果可以接受,继续改变形状。干预建模本质上是确定性的。如果您有兴趣了解有关传递函数建模/干预检测的更多信息,我强烈推荐Forecasting-Dynamic-Regression-Models-Pankratz. 除了传递函数建模之外,本文还包含所有可能的不同类型的干预模型。
希望这可以帮助。
data temp;
input actual @@;
error = rand("NORMAL");
datalines;
0 0 0 0 0 0 5
5 5 5 5 5 5 4.1
4 3.5 3 2.5 2 1.75 1.25
0.75 0.25 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
;
run;
data temp;
set temp;
retain ramp 0;
actual_error = actual+error; *add random error;
if 7 <= _n_ <= 13 then step = 1;
else step = 0;
if 14 <= _n_ <= 23 then do;
step = (_n_ - 24)/(13-24);
end;
run;
ods graphics on;
proc arima data = temp plots = all;
identify var=actual_error crosscorr = (step);
estimate input = (step) method = ml outest = mm1; /*Estimate Model using Transfer Function*/
forecast out = out1 lead = 0;
run;
ods graphics off;
