[R] dealing with random.walk in intervention analysis using TSA::arimax

r messages r@@t@t@@me@@@ge@ @end|ng |rom gm@||@com
Tue May 14 21:51:49 CEST 2019


Hi Listers,

    I am trying to do intervention analysis using arimax function,
typically on financial time series (random walk).

I found that the function can't handle raw random walk series unless we
supply an already differenced version of it.

example data:

random.walk <- ts(c(64.6100,64.8200,64.7600,64.6700,64.5300,64.6300,64.6400,64.8100,64.8500,64.8600,65.0400,65.0000,64.7200,65.0600,64.3100,64.4700,64.5400,64.4100,64.4100
,64.5200,64.5350,64.4900,64.2100,64.3600,64.5450,64.6100,64.7800,64.7050,64.6600,64.4600,64.5000,64.4700,64.4700,64.6400,64.6400,64.2900,64.4800,64.3100
,64.2500,64.2500,64.0300,64.1450,64.4500,64.0700,64.2500,64.2000,64.1150,64.3000,64.3600,64.4600,64.2300,64.1700,64.1800,63.9900,63.9000,64.0399,64.2600
,64.5050,64.6300,64.4100,64.4950,64.5100,64.5601,63.7300,64.1100,64.0500,64.1800,64.2700,64.3600,64.4500,64.9800,64.8400,65.0000,65.1500,65.3750,65.3650
,65.3500,65.9700,65.9600,65.6200,65.5600,65.6300,65.5900,65.6750,65.6650,65.4600,65.6000,65.5500,65.5250,65.4500,65.3200,65.2000,65.2500,65.5400,65.5400
,65.6850,65.9000,65.8950,65.5100,65.0900,65.3500,65.2300,65.2500,65.4400,65.6950,65.5899,65.6750,65.4800,65.3900,65.1400,65.3600,65.5200,65.5100,64.9050
,64.9300,64.9550,64.9000,64.9100,64.8800,65.1200,65.7100,65.6400,65.7100,65.7500,65.6350,65.6400,65.9100,66.2550,66.4750,66.3800,66.2900,66.3100,66.2100
,66.2300,66.3500,66.3800,66.1800,66.2800,66.2200,66.2800,66.7400,66.7450,66.6900,66.4900,66.5850,66.5600,66.5000,66.4200,66.6000,66.6300,66.6300,66.7400
,66.7100,66.5800,67.1900,67.9300,67.6100,67.5400,67.6900,67.4150,67.4600,67.6400,67.9600,68.2000,68.1600,67.8600,67.8800,68.0100,68.7300,68.4900,68.4100
,68.5300,68.5799,68.4300,68.1300,68.5600,68.2844,68.4393,68.5700,68.6200,68.4750,68.5900,68.2700,68.7600,68.7950,68.7093,68.6800,68.7000,68.6300,68.4800
,68.4150,68.4800,68.5300,68.3600,68.1750,68.4300,68.4200,68.1600,68.1900,68.3000,68.4300,68.2500,68.3850,68.5200,68.0800,67.8900,68.0664,67.8200,67.5100
,67.7200), frequency = 7)


step.function <- c(rep(0, 154), rep(1, 56))


e.g.

Below throws an exception saying the fixed length was wrong for
stats::arima.
Reason for this is because it calls stats::arima. it has an argument called
"fixed" which we use to fixed some parameters in the arima equation.
random walk typically has nothing to fix (if comes with no drift term)
however TSA::arimax force-feeds some "fixed" values, causing the exception
here.

arimax(random.walk, order=c(0,1,0), xtransf=step.function, transfer=c(1,0))

Following works, but we had to fit an extra arima(0,0,1) to our differenced
random walk. (note if we do auto.arima or we peruse acf and pacf, an extra
arima(0,0,1) isn't necessary or justified.

random.walk.diff <- diff(random.walk)
arimax(random.walk.diff, order=c(0,0,1), xtransf=step.function,
transfer=c(1,0))

It is either a bug or by design. I don't follow; I tried to debug the code
but it is hardly human readable for me, there are many acronyms which is
hard to make sense and easy to lose track of.

What do you guys think?

Thanks very much for your input.

Regards,

Qiuxiao

	[[alternative HTML version deleted]]



More information about the R-help mailing list