7

I have a couple weekly time series and an intervention occurred over several weeks and then for some, after a period of no intervention, began again. So, the pattern is off for a period of weeks, then on for a period of weeks, then off for a period of weeks and perhaps on again.

The image below tries to show the possible patterns:

enter image description here

When there is a single pulse, then as discussed here it is pretty simple to code the intervention as a pulse (1 or that period and zero elsewhere) and code the transfer function as one of several shapes - e.g. only effecting a single period (the pulse), a permanent level shift (a step) or perhaps with a lasting (but decaying) effect (a pulse but with decay transfer function).

In the situation described here though, is there the same flexibility or do we really only have the option to code the interventions as 10 separate interventions (for the top series) or 5 separate ones for the bottom series and only allow the intervention to effect the single period? I am not sure how to have any of the "pulses" have a decaying effect because where does one start and the other stop?

In my reading thus far for this type of analysis I have seen the pulse and step but nothing like this, where there is an "on" for a period of time, then "off" and then on again (maybe).

B_Miner
  • 7,560
  • 20
  • 81
  • 144
  • 1
    it is fairly simple temporary level shift. You can dummy code a single variable with 5 consecutive observation as 1 and the rest as 0. – forecaster Jul 26 '14 at 04:29
  • So, for the top series it would be two vectors coded each with 5 '1's in the appropriate positions? – B_Miner Jul 26 '14 at 13:53
  • This doesn't allow for delayed effects does it? Simply an effect just during the times the intervention is "on"? – B_Miner Jul 26 '14 at 13:55
  • 1
    yes you need two vectors. If you need decayed response, then you would need a transfer function $ \frac {\omega}{1-\delta B} P_t$ – forecaster Jul 26 '14 at 15:45
  • That goes to my question though - for transfer functions shown in textbooks that are shown either as a step ("1" from the time T to the end of the series) or pulse, can you use a step transfer function operating only on a vector that is a "1" for a portion of the time? – B_Miner Jul 26 '14 at 17:35
  • 1
    Yes you can have 1 portion of time. – forecaster Jul 26 '14 at 19:43
  • I think I am hung up too much on using only a (full) step or only a pulse. Is it your understanding that you have more flexibility than that then? I also may be thinking to literally about having the vector of 1s and 0s match exactly what occurred in the intervention, versus getting the matching effect. For example, if you have an intervention where something changed and that change is constant (a step with 1s from some point onward) but you need a decreasing decay function, than you can change it to a pulse, even though a continuous step is what actually occurred. Is this your understanding? – B_Miner Jul 26 '14 at 21:27
  • @forecaster what do you think? – B_Miner Jul 27 '14 at 16:14
  • B_Miner, if you have an step intervention for some time and then a decaying effect, what you need is a compound intervention transfer function. you just sum up the step and decaying intervention transfer function, you should be good. – forecaster Jul 27 '14 at 17:35
  • If you have an example of this in TSA, I would like to see it. Is it the following specification (using the top row of data I show above): xtransf = data.frame(intvertion=c(rep(0,6),rep(1,5),rep(0,7),rep(1,5),rep(0,3))), transfer = list(c(0,0), c(0,1))) – B_Miner Jul 27 '14 at 19:14
  • Oops I meant the following (just focusing on the first intervention from row 1 ): xtransf = data.frame(intvertionA=c(rep(0,6),rep(1,5),rep(0,15)), intvertionB=c(rep(0,6),rep(1,5),rep(0,15))), transfer = list(c(0,0), c(1,0))) – B_Miner Jul 27 '14 at 20:56
  • If one ran a statistical test, wouldn't it show something like a transient change has a higher statistical probability than a pulse at any of these locations? Are there statistical tests for a pattern of interventions, rather than just hypothesis testing one intervention at each location? – Frank Mar 01 '20 at 16:11

1 Answers1

3

Lets say you have a time series data 42 observations. Observation 7 to 13 have step(level shift) intervention and observations 29 to 35 have step intervention of 5 units. The remainder observations are 0. As an example, see below chart for simulated data with actual and actual + error.enter image description here

If you would like to model this data as a intervention analysis using arima transfer function, you simply need to create a dummy coded variable with 1's for 7 to 13 and 1's for 29 to 35 and pass this is a step intervention in ARIMAX model. I don't know how to use R for transfer function modeling, so I used SAS. See below the actual and predicted data. The ARIMAX approximated the data very well. See below the SAS code that I used to create the data and as well as the ARIMAX.

If your second intervention has a first intervention has a decaying effect, all you need to do is create a second intervention variable at the end of first step function and code it appropriately.

Hopefully this helped.

enter image description here

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;

EDIT: as b_miner would like to know how to model this with temporary level shift with a linear decay, I have modified the example. I have shown only the first level shift, the second level shift could be easily added. If you are looking for a decay other than a linear decay then it is fairly easy to do, just use a step+gradual permanent decay function using transfer function. Intervention modeling is more of an art than science. You assume a shape, test the hypothesis, if acceptable move on else change the shape. Intervention modeling is deterministic in nature. If you are interested in learning more about transfer function modeling/intervention detection, I would highly recommend Forecasting-Dynamic-Regression-Models-Pankratz. This text has all the different types of intervention models possible, in addition to transfer function modeling.

Hope this helps.

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;

enter image description here

forecaster
  • 7,349
  • 9
  • 43
  • 81
  • Lets say that there is a step intervention (mean level shifts upward) during the first set of 1s (#7 to #13) as you show, but that the effect then decays slowly back to the previous mean level. What would the other vector of 1's and 0's look like? Would it be a pulse at #13 or #14? – B_Miner Jul 28 '14 at 01:28
  • Done with an example. – forecaster Jul 29 '14 at 19:01
  • I'm reading the relevant chapters of the book. Thanks for the reference! – B_Miner Jul 31 '14 at 15:35
  • GREAT book, very helpful. There is another one by Yaffee (SAS and SPSS) that goes into good detail on intervention and transfer functions (crazy amount of errors though - luckily most are on the companion site). Also, I try to avoid SAS if possible since R seems like a more flexible option (wherever I am working) but in this case, the flexibility of proc arima is unmatched in any other open source product I can find. – B_Miner Aug 14 '14 at 13:36
  • @B_Miner Have you tried AUTOBOX as it is much more powerful than SAS or any other time series software to deal with this issue. – IrishStat Sep 04 '14 at 14:28