Re: [R] ARIMA xreg and factors

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 16 Jan 2007 - 07:50:56 GMT

>From the help page

     xreg: Optionally, a vector or matrix of external regressors, which
           must have the same number of rows as 'x'.

Note, not a factor. (It handles your factor like the integer vector it is internally.) If you want a design matrix you need to make one, something like

include.mean = FALSE, xreg = model.matrix(~z)

On Mon, 15 Jan 2007, sj wrote:

> I am using arima to develop a time series regression model, I am using arima
> b/c I have autocorrelated errors. Several of my independent variables are
> categorical and I have coded them as factors . When I run ARIMA I don't
> get any warning or error message, but I do not seem to get estimates for all
> the levels of the factor. Can/how does ARIMA handle factors in xreg?
>
>
> here is some example code:
>
> sim.ar <- arima.sim(list(ar = c(0.4, 0.4)), n = 1000)
> z<- factor(rep((1:5),200))
>
> arima(sim.ar,order=c(2,0,0),xreg=z)
>
>
> I only get a single estiamte for xreg. Am I thinking about this wrong (I
> expected 4).
>
> thank you,
>
>
> Spencer
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Jan 16 18:55:01 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 16 Jan 2007 - 09:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.