[R] Autoregressive Model with Independent Variable

Spencer Graves spencer.graves at pdf.com
Sun Mar 5 20:36:21 CET 2006


     Does the following example answer your "arima" question:

IntReg <- cbind(It=(1:48)>20, It.w=((1:48)>20)*(1:48),
               It.lh=((1:48)>20)*c(0, lh[-48]) )

arima(lh, order = c(1,0,0), xreg=IntReg)

       hope this helps.
       spencer graves

Jarrett Byrnes wrote:

> On Mar 1, 2006, at 8:35 PM, Dirk Eddelbuettel wrote:
> 
> 
>>On 1 March 2006 at 20:06, Jarrett Byrnes wrote:
>>| Hey, all, I may just be missing something, but I'm trying to 
>>construct
>>| a temporal autoregression with an independant variable other than 
>>just
>>| what is happened at a previous point in time.  So, the model 
>>structure
>>| would be something like
>>|
>>| y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a*x(t)
>>|
>>
>>Yes: arima(), see in particular the xreg argument.
>>
> 
> 
> Thanks so much!  arima() seems to mostly fit the bill.  I have data 
> from multiple sites to use, as well.  e.g.
> 
> Time		y1 	x1	y2	x2
> 1		4	6	7	10
> 2		5	10	5	20
> 3		10	1	7	15
> etc.
> 
> I would like to use all of the sites in creating a model - I realize 
> that the structure of the model would now be along the lines of:
> 
> y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a1*x(t)+a2*x(t-1)...+c
> 
> Where c is the site effect - I know this can get all wrapped up in the 
> intercept, but, how does one pass this data to arima() to make it work? 
>   I know that arima() takes a vector of y values - can it take a matrix 
> of y values and a corresponding matrix of x values, or is there some 
> other function that does this?
> 
> -Jarrett
> 
> ______________________________________________
> 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




More information about the R-help mailing list