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:


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


1 Answer 1


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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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