1
$\begingroup$

How can I in R fit a time series, $x_t$, with external regressors, $v_t$, and an autoregressive error? This time series model is given as follows, $x_t = \beta v_t + \epsilon_t$ where $\epsilon_t = w_t + \sum_{i = 1}^p \gamma_i\epsilon_{t - i}$ and $w_t \sim N(0, \sigma^2)$.

$\endgroup$

2 Answers 2

3
$\begingroup$

Use the arima() function in the stats package:

fit <- arima(x, xreg=v, order=c(p,0,0))

If you want the autoregressive order selected automatically, use auto.arima() from the forecast package:

fit <- auto.arima(x, xreg=v, seasonal=FALSE, max.q=0)

If you are willing to have more general correlated error structures:

fit <- auto.arima(x, xreg=v)
$\endgroup$
2
  • $\begingroup$ I used this package but I was under the assumption that arima will fit an autocorrelated time series of the form, $$x_t = \beta v_t + \sum_{i = 1}^p \gamma_i x_{t-i}} + \epsilon_t$$? $\endgroup$
    – Stereo
    Oct 14, 2014 at 12:56
  • $\begingroup$ Read the help file. $\endgroup$ Oct 15, 2014 at 3:09
1
$\begingroup$

gls function in nlme package can do it, with gls(y~x, data=Data.Frame, correlation=corARMA(p=1,q=0))

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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