Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have a linear regression model with some correlated errors: $Y_t=\beta_0+\beta_1X_1+\beta_2X_2+\epsilon_t$, where $\epsilon_t$ is a AR(1) i.e. $\epsilon_t=\phi\epsilon_{t-1}+\nu_t$ with $\nu_t$ as white noise terms. I want to obtain the joint maximum likelihood estimates of $\beta_j$'s for $j=0,1,2$ and $\phi$ as well as the residual standard error i.e. $\sigma$ for the white noise term. I guess it can be done with a time series package in R, maybe the forecast package. But I am not sure exactly how to write the code. My first guess is something like this:

library(forecast)   
Arima(dat[,c("Y")],order=c(1,0,0),xreg=dat[,c("X1","X2")],
      include.drift=TRUE,method=c("ML"))

Please let me know if there is any package available for this. Thanks.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You don't need the forecast package. The arima() command from the stats package will do it:

fit <- arima(dat[,"Y"],order=c(1,0,0),xreg=dat[,c("X1","X2")],method="ML")

But if you also want to do some forecasting, the forecast package makes it easier. In that case, use

fit <- Arima(dat[,"Y"],order=c(1,0,0),xreg=dat[,c("X1","X2")],method="ML")
share|improve this answer
    
Thank you so much Rob. –  Stat Dec 24 '12 at 7:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.