# Time series regression - ML estimation

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.

-

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