ARMAX model fitting with arima
This is a follow-up to my request of yesterday. Someone sent a private
reply indicating a chapter in the Shumway & Stoffer's book "Time Series
Analysis and Its Applications" [1], where some pitfalls of the arima
function are discussed.
In the meanwhile, I realized that the estVARXar function of the dse
package does estimate correctly the ARMAX parameters from my data. Here
is the code, if someone is interested:
################################################################
### First, the data as I posted previously:
x <- u <- c (rep (0, 50), rep (1, 50))
x [1] <- 0
set.seed (0)
for (i in 2 : length (x)) {
x [i] <- 0.3 * u [i] + 0.8 * x [i - 1] + 0.01 * rnorm (1)
}
### Second, the trivial DSE fitting:
library (dse1)
estVARXar (TSdata (input = u, output = x))
################################################################
[1] http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm
Cheers,
Rafael
* Rafael Laboissiere <rafael.laboissiere at inserm.fr> [2009-11-16 08:44]:
I am trying to understand how to fit an ARMAX model with the arima
function from the stats package. I tried the simple data below, where
the time series (vector x) is generated by filtering a step function
(vector u, the exogenous signal) through a lowpass filter with AR
coefficient equal to 0.8. The input gain is 0.3 and there is a 0.01
normal white noise added to the output:
x <- u <- c (rep (0, 50), rep (1, 50))
x [1] <- 0
set.seed (0)
for (i in 2 : length (x)) {
x [i] <- 0.3 * u [i] + 0.8 * x [i - 1] + 0.01 * rnorm (1)
}
Then, I fit the model:
arima (x, c (1, 0, 0), xreg = u, include.mean = FALSE, method = "ML")
Coefficients:
ar1 u
0.9988 0.2995
Why don't I get ar1 close to 0.8? If I use lm to regress the data, it works:
lm (x [2 : length (x)] ~ x [1 : (length (x) - 1)] + u [2 : length (u)] - 1)
Coefficients:
x[1:(length(x) - 1)] u[2:length(u)]
0.7989 0.3015
Any help will be appreciated.
Best,
Rafael