[R] ARIMA xreg and factors

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jan 16 03:43:04 CET 2007


Try this:


set.seed(1)
sim.ar <- arima.sim(list(ar = c(0.4, 0.4)), n = 1000)
z<- gl(5, 1, 1000)
zm <- model.matrix(~z)[,-1]
arima(sim.ar, order=c(2,0,0), xreg = zm)



On 1/15/07, sj <ssj1364 at gmail.com> 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 at 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.
>



More information about the R-help mailing list