[R] ARMAX model fitting with arima

Rafael Laboissiere rafael.laboissiere at inserm.fr
Mon Nov 16 08:44:04 CET 2009


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 Laboissiere




More information about the R-help mailing list