The ARIMAX model muddle

There is often con­fu­sion about how to include covari­ates in ARIMA mod­els, and the pre­sen­ta­tion of the sub­ject in var­i­ous text­books and in R help files has not helped the con­fu­sion. So I thought I’d give my take on the issue. To keep it sim­ple, I will only describe non-​​seasonal ARIMA mod­els although the ideas are eas­ily extended to include sea­sonal terms. I will include only one covari­ate in the mod­els although it is easy to extend the results to mul­ti­ple covari­ates. And, to start with, I will  assume the data are sta­tion­ary, so we only con­sider ARMA models.

Let the time series be denoted by y_1,\dots,y_n. First, we will define an ARMA(p,q) model with no covariates:

    \[ y_t = \phi_1 y_{t-1} + \cdots + \phi_p y_{t-p} - \theta_1 z_{t-1} - \dots - \theta_q z_{t-q} + z_t, \]

where z_t is a white noise process (i.e., zero mean and iid).

ARMAX mod­els

An ARMAX model sim­ply adds in the covari­ate on the right hand side:

    \[ y_t = \beta x_t + \phi_1 y_{t-1} + \cdots + \phi_p y_{t-p} - \theta_1 z_{t-1} - \dots - \theta_q z_{t-q} + z_t \]

where x_t is a covari­ate at time t and \beta is its coef­fi­cient. While this looks straight-​​forward, one dis­ad­van­tage is that the covari­ate coef­fi­cient is hard to inter­pret. The value of \beta is not the effect on y_t when the x_t is increased by one (as it is in regres­sion). The pres­ence of lagged val­ues of the response vari­able on the right hand side of the equa­tion mean that \beta can only be inter­preted con­di­tional on the value of pre­vi­ous val­ues of the response vari­able, which is hardly intuitive.

If we write the model using back­shift oper­a­tors, the ARMAX model is given by

    \[ \phi(B)y_t = \beta x_t + \theta(B)z_t \qquad\text{or}\qquad y_t = \frac{\beta}{\phi(B)}x_t + \frac{\theta(B)}{\phi(B)}z_t, \]

where \phi(B)=1-\phi_1B -\cdots - \phi_pB^p and \theta(B)=1-\theta_1B-\cdots-\theta_qB^q. Notice how the AR coef­fi­cients get mixed up with both the covari­ates and the error term.

Regres­sion with ARMA errors

For this rea­son, I pre­fer to use regres­sion mod­els with ARMA errors, defined as follows.

    \begin{align*} y_t &= \beta x_t + n_t\\ n_t &= \phi_1 n_{t-1} + \cdots + \phi_p n_{t-p} - \theta_1 z_{t-1} - \dots - \theta_q z_{t-q} + z_t \end{align*}

In this case, the regres­sion coef­fi­cient has its usual inter­pre­ta­tion. There is not much to choose between the mod­els in terms of fore­cast­ing abil­ity, but the addi­tional ease of inter­pre­ta­tion in the sec­ond one makes it attractive.

Using back­shift oper­a­tors, this model can be writ­ten as

    \[ y_t = \beta x_t + \frac{\theta(B)}{\phi(B)}z_t. \]

Trans­fer func­tion models

Both of these mod­els can be con­sid­ered as spe­cial cases of trans­fer func­tion mod­els, pop­u­lar­ized by Box and Jenkins:

    \[ y_t = \frac{\beta(B)}{v(B)} x_t + \frac{\theta(B)}{\phi(B)}z_t. \]

This allows for lagged effects of covari­ates (via the \beta(B) oper­a­tor) and for decay­ing effects of covari­ates (via the v(B) operator).

Some­times these are called “dynamic regres­sion mod­els”, although dif­fer­ent books use that term for dif­fer­ent models.

The method for select­ing the orders of a trans­fer func­tion model that is described in Box and Jenk­ins is cum­ber­some and dif­fi­cult, but con­tin­ues to be described in text­books. A much bet­ter pro­ce­dure is given in Pankratz (1991), and repeated in my 1998 fore­cast­ing text­book.

Non-​​stationary data

For ARIMA errors, we sim­ply replace \phi(B) with \nabla^d\phi(B) where \nabla=(1-B) denotes the dif­fer­enc­ing oper­a­tor. Notice that this is equiv­a­lent to dif­fer­enc­ing both y_t and x_t before fit­ting the model with ARMA errors. In fact, it is nec­es­sary to dif­fer­ence all vari­ables first as esti­ma­tion of a model with non-​​stationary errors is not con­sis­tent and can lead to “spu­ri­ous regression”.

R func­tions

The arima() func­tion in R (and Arima() and auto.arima() from the fore­cast pack­age) fits a regres­sion with ARIMA errors. Note that R reverses the signs of the mov­ing aver­age coef­fi­cients com­pared to the stan­dard para­me­ter­i­za­tion given above.

The arimax() func­tion from the TSA pack­age fits the trans­fer func­tion model (but not the ARIMAX model). This is a new pack­age and I have not yet used it, but it is nice to finally be able to fit trans­fer func­tion mod­els in R. Some­time I plan to write a func­tion to allow auto­mated order selec­tion for trans­fer func­tions as I have done with auto.arima() for regres­sion with ARMA errors (part of the fore­cast pack­age)


Related Posts:


  • http://www.twitter.com/BrockTibert Brock

    Hi Rob,

    I just started out in time series and R, and recently I have tried to fit a uni­vari­ate time series. The basic process was that I con­verted my data to a ts object and fit a model using auto.arima to a weekly dataset. A plot of my data shows my data are most likely non-​​stationary, but based on the post above, and if I under­stand this cor­rectly, I need to dif­fer­ence my dataset first? When look­ing at the help, it looks like the default option is to feed auto.arima a non-​​stationary process. I am new to time series and may be bit­ing off more than I can chew in some cases, but I just want to make sure I learn as much as I can. Thanks in advance.

    • http://robjhyndman.com Rob J Hyndman

      No, you do not need to dif­fer­ence the data first. auto.arima() will deter­mine the order of dif­fer­enc­ing required using a unit-​​root test.

      • Diet­mar

        Hi Rob,

        how can I rec­on­cile the state­ment in the arti­cle “The ARIMAX model muddle”

        Con­se­quently, you should do your own dif­fer­enc­ing when required.”

        with the statement

        No, you do not need to dif­fer­ence the data first. auto.arima() will
        deter­mine the order of dif­fer­enc­ing required using a unit-​​root test.”

        Thanks a lot!!

        Diet­mar

        • http://robjhyndman.com Rob J Hyndman

          Brock was try­ing to fit a uni­vari­ate ARIMA model with no regres­sors. In that case, auto.arima() han­dles the dif­fer­enc­ing with­out a prob­lem. In the arti­cle, I was talk­ing about regres­sion with ARIMA errors. In that sit­u­a­tion (where there is at least one regres­sor), dif­fer­enc­ing should be done by hand if required, because the under­ly­ing ‘arima()‘ code (not my code) does not do it correctly.

          • liaom­ing zhou

            may I ask more?
            for exam­ple: I fit a ARIMA model: ARIMA(1,1,1)(0,1,1)[7] with xreg=Xr, How to do dif­fer­enc­ing of Xr handly?

          • http://robjhyndman.com/ Rob J Hyndman

            This issue has been fixed. There is no need to do any dif­fer­enc­ing by hand. Just use xreg=xr and every­thing should work correctly.

  • http://www.twitter.com/BrockTibert Brock

    Per­fect thanks Rob!

  • saugat gurung

    dear Rob,
    do i need to do log trans­for­ma­tion (if data requires) to use auto.arima() func­tion. as the func­tion does the dif­fer­enc­ing itself. what if my data requires log transformation,where should i apply auto.arima in the orig­i­nal data or the log trans­formed data.

    • http://robjhyndman.com Rob J Hyndman

      In v3 of the fore­cast pack­age, you can do the log trans­for­ma­tion inside the auto.arima() function:

      fit <- auto.arima(x,lambda=0)
      plot(forecast(fit))

      The lambda indi­cates a Box-​​Cox trans­for­ma­tion and lambda=0 cor­re­sponds to a log­a­rithm. The fore­cast func­tion will rec­og­nize that a log has been applied and back-​​transform the fore­casts appropriately.

      • saugat gurung

        thank you very much, i find it very helpful.

  • Hervé

    dear Rob, I have some prob­lem with the use of ARIMA with covari­ate in R. For exam­ple how can I esti­mate in R an ARIMA(2,01) included a covari­ate with a time lag of 20s for exam­ple. Thanks
    Hervé.

    • http://robjhyndman.com Rob J Hyndman

      Let x be the lagged covari­ate. Then
      fit <- Arima(y, xreg=x, order=c(2,0,1))

  • Wolf3616

    I find this arti­cle very help­ful! thank you!

  • Wolf3616

    Dear Rob,

    I gen­er­ate a syn­thetic series using ARX model, using the arima.sim() func­tion, and adding a con­stant to it (i.e. Yt=C+arima.sim()) to have an Expectation/​mean of the ‘obser­va­tion’ Yt~1000. later I ‘esti­mate’ the para­me­ters using an arima() func­tion for the gen­er­ated series. The esti­mates of the poly­no­mi­als and mean turn out with small s.e. val­ues to the ‘true’ para­me­ters which I believe, based on your arti­cle, that the arima() fits a regres­sion with arima errors. Is my assump­tion is true?

    My other ques­tion is, I use a ran­dom vari­ables gen­er­ated from a ‘GEV dis­tri­b­u­tion’ for the ‘inno­va­tion’ (for the arima.sim() func­tion) to gen­er­ate the ‘obser­va­tion’, Yt, in hope that a sim­i­lar dis­tri­b­u­tion type (i.e. GEV) is likely to be gen­er­ated for the Yt. as far as I had sim­u­lated, the ‘obser­va­tion’ tend to be skewed and non-​​normal. Am I wrong to pre­dict that?

    • http://robjhyndman.com Rob J Hyndman

      1. Yes, arima() fits a regres­sion with ARIMA errors.
      2. GEV errors does not lead to a GEV mar­ginal dis­tri­b­u­tion. I don’t know what error dis­tri­b­u­tion would lead to a GEV mar­ginal distribution.

  • Wolf3616

    Thank you for your answer! Really appre­ci­ate it!

  • Mohamed

    Dear Rob,

    i have two vari­ables, one response vari­able and the other is covari­ate, i would like to use ari­max in r and i’m con­fused if i should put the covari­ate in xreg or in x transf and if i would like to esti­mate the rela­tion between them at dif­fer­ent lags, how can i apply this in R?!! thanks for help in advance.

  • Shea Parkes

    Might as well dig up an old thread. This is very solid infor­ma­tion, I’m cur­rently explor­ing trans­fer func­tions and their use for interventions.

    I’m unable to repro­duce the dif­fer­enc­ing error in the base arima() func­tion of R-​​stats now (when using an xreg). Is this still a prob­lem or was it even­tu­ally fixed?

    If it was fixed, you might want to toss a note into the post since google pager­anks this post rather high for “ARIMAX” key words.

    • http://robjhyndman.com Rob J Hyndman

      The bug still exists. It doesn’t return an error. The prob­lem is the method of esti­ma­tion used is incon­sis­tent. Dif­fer­enc­ing should be done first so all vari­ables are sta­tion­ary before estimation.

      • Alex

        I’m won­der­ing if the Shea com­ment is about the prob­lem with regres­sion includ­ing arima errors (and the bug in the arima function).

        I’m using auto.arima to fit a model with one regres­sor, both depen­dant and inde­pen­dant vari­ables are non sta­tion­nary, and i don’t get the same coef­fi­cient from the two above com­mand lines :

        model return an arima (2,1,0)(1,0,0)
        and
        model return an arma (1,0,1)(1,0,0)
        the coef­fi­cient of the regres­sor are very dif­fer­ent even if i force an arma (2,0,0)(1,0,0) ine the sec­ond model.

        So i just want to know if the bug in the arima func­tion is still present or if I have a prob­lem in my code (or my under­stand­ing of the model).

        For a model selec­tion point of view, if the bug still exists, i sup­pose the right method­ol­ogy is to fit the first model and apply the dif­fer­en­ci­a­tion of the arima process to the data and refit the model, am i right ?

        • http://robjhyndman.com/ Rob J Hyndman

          Please send me a min­i­mal­ist exam­ple by email and I’ll investigate.

  • Vinayraj

    Hi Mr.Hyndman.….I have used the auto.arima func­tion in fore­cast pack­age with causal vari­ables and found that for non sta­tion­ary data, the para­me­ter co effi­cient esti­mates are not correct…as per your sug­ges­tion, i did dif­fer­enc­ing of the time series before feed­ing to auto.arima…however how do i use the above arima model and the dif­fer­enced series while gen­er­at­ing the forecast?

    • http://robjhyndman.com Rob J Hyndman

      I don’t know what you mean “not cor­rect” as auto.arima does fit the model cor­rectly. It is arima() that is incorrect.

  • Mar­cel

    Dear Rob,

    thank you for writ­ing this arti­cle! I was won­der­ing if you have come across a package/​method for fit­ting ARIMAX mod­els for ensem­ble traces, e.g.

    Over a period of 30 days I record 3 mea­sures A,B,C every minute between 12am to 3pm. I assume that A(t) = alpha_​1 A(t-1) + … + alpha_​n A(t-n) + beta_​1 B(t-1) + … + gamma_​1 C(t-1) + … + Z(t), while B and C do not depend on A. I want to esti­mate the alpha’s, beta’s and gamma’s such that the errors min­imise the sum of the pre­dic­tion error over all days.

    Gen­er­ally I have found quite few tools/​libraries for gen­eral ARIMAX fit­ting, but there seems to be lit­tle infor­ma­tion about how to do this when I have mul­ti­ple non-​​consecutive time series of the same process.

  • Cana­dian Tom

    Hi Rob,

    Thanks for this. This was one of the clear­est expla­na­tions I could find on the web. If you don’t mind, I have a ques­tion to do with non-​​stationary data. It was my under­stand­ing that it’s OK to cal­i­brate an OLS model with non-​​stationary time-​​series data, as long as the resid­u­als are a sta­tion­ary time series. This would imply that they ‘co-​​integrate’. So if I can cal­i­brate an ARMAX model with a cou­ple AR lags that pro­duces a resid­u­als series with no auto­cor­re­la­tion, in gen­eral, that’s OK… right? Or, as you said, do I need to difference?

    • http://robjhyndman.com/ Rob J Hyndman

      Please ask these ques­tions on cross​val​i​dated​.com

  • Pingback: cointegration – mixing S & NS regressors; how to test for stationarity; so on | Question and Answer()

  • liana

    Hi Rob,

    I’m try­ing to fit an arima model with one
    exo­ge­neous vari­able using auto.arima with xreg option. I’m hav­ing some doubts
    because none of my data is sta­tion­ary and they are both sea­sonal. Do I have to
    apply log and dif­fer­en­ti­ate my series first? How do I treat the
    sea­son­al­ity in the orig­i­nal time serie and in the exo­ge­neous serie?

    • http://robjhyndman.com/ Rob J Hyndman

      Please ask such ques­tions on cross​val​i​dated​.com

  • Her­i­man­i­tra

    Dear Sir,

    Your web­site is a valu­able resources.

    I’m curi­ous to know when are you going to talk about VAR, ECM, VECM and more sophis­ti­cated models?

    • http://robjhyndman.com/ Rob J Hyndman

      I don’t have an agenda. I write about things that inter­est me. Cur­rently, I’m not think­ing about these mul­ti­vari­ate time series models.

      • Her­i­man­i­tra

        I see you talked lit­tle about VAR model in your book : http://​otexts​.com/​f​p​p​/9/2/

        I was expected to see bet­ter results in the VAR fore­cast­ing (as it is con­sid­ered as supe­rior to other models).

        So my ques­tions are:

        1) are these vari­ables stationary?

        2) if yes, why fore­casts seem to be flat, or one should include sea­sonal pat­tern to give bet­ter results like in this: http://​otexts​.com/​f​p​p​/6/6/ (by adding method=“naïve”) ?

        Thanks in advance,

        • http://robjhyndman.com/ Rob J Hyndman

          Yes, the vari­ables look sta­tion­ary. There is not much sig­nal here, so the fore­casts are rel­a­tively flat. No method is going to work very well when there is not much sig­nal. The advan­tage of the VAR is that it is using all the avail­able data rel­a­tively efficiently.

  • Diet­mar

    Hi Rob,

    in a regres­sion with ARIMA errors I ran into the fol­low­ing ques­tions. What is the rela­tion­ship between the value of the my.xreg para­me­ter and the pre­dic­tion error, e.g., MAE, which is cal­cu­lated rel­a­tive to the ran­dom walk model? Can the value of my.xreg be inter­preted as a mea­sure of the impor­tance of the covariate?

    I was — per­haps naively — assum­ing that there is a lin­ear rela­tion­ship between my.xreg and fore­cast error/​MAE. In the sense that the lower the MAE the greater/​smaller the value of my.xreg para­me­ter. But this does not seem to be the case. Do you have any sug­ges­tions on this? Thanks!

    Diet­mar

    • Guest

      Prof. Hyn­d­man,

      In one of my projects I am try­ing to imple­ment trans­fer func­tion in R and I am
      using TSA package.

      In Time Series mod­els’ trans­fer func­tions there is a decay para­me­ter in the
      for­mula (let’s call it b). In TSA pack­age that decay para­me­ter is not men­tioned. When I used other soft­ware before
      (such as SAS) I used to deter­mine b after ana­lyz­ing ‘prewhitened series’. But
      in TSA pack­age in R there is no need to spec­ify the decay para­me­ter once you ana­lyze CCF?

      If not how am I going to know when the decay starts?

      I under­stand CCF is used after prewhiten­ing to deter­mine how to
      fil­ter the out­puts but where b comes into the picture?

      Regards

      Kerem

  • Spin­oza

    Prof. Hyn­d­man,

    In one of my projects I am try­ing to imple­ment trans­fer func­tion in R and I am
    using the class arima within TSA pack­age for the trans­fer function

    In Time Series mod­els’ trans­fer func­tions there is a decay para­me­ter in the
    for­mula (let’s call it b). In TSA pack­age that decay para­me­ter is not men­tioned. When I used other soft­ware before
    (such as SAS) I used to deter­mine b after ana­lyz­ing ‘prewhitened series’. But
    in TSA pack­age in R there is no need to spec­ify the decay para­me­ter once you ana­lyze CCF?

    If not how am I going to know when the decay starts?

    I under­stand CCF is used after prewhiten­ing to deter­mine how to
    fil­ter the out­puts but where b comes into the picture?

    Regards

    Kerem

    • http://robjhyndman.com/ Rob J Hyndman

      I am not the author of the TSA pack­age. Please ask on cross​val​i​dated​.com

  • Kavitha R

    very help­ful

  • Kavitha R

    Thanks Dr.Rob. But i have seen ref­er­ences where they use regres­sions (har­monic reg for adjust­ing sea­son­al­ity [i am not sure whether we can include inde­pen­dent vari­ables or not], Pois­son regres­sion.. etc. mostly with­out any adjust­ment for accom­mo­dat­ing ser­ial depen­dency of time series data) for time series data. Is it cor­rect?? If it is cor­rect what are the impor­tant things that has to taken care while we use regres­sion based meth­ods for time series data?? Are these results are com­pa­ra­ble with ARMAX models??

    • http://robjhyndman.com/ Rob J Hyndman

      Regres­sion with time series data but no accom­mo­da­tion for ser­ial cor­re­la­tion is ok if there is no ser­ial cor­re­la­tion. But if ser­ial cor­re­la­tion is present, the esti­mated coef­fi­cients are still unbi­ased although the stan­dard errors, etc., are wrong.

  • Angie

    Hi,

    I would like to ask your help how can i sim­u­late dif­fer­ent forms of trans­fer func­tions in R?

    Thanks!

  • Jim

    Hi Rob — Is there a pref­er­ence when mod­el­ing time series data (with pre­dic­tors) between using lin­ear regres­sion (pos­si­bly with lagged depen­dent and inde­pen­dent vari­ables on the RHS) and using robust stan­dard errors like Newey West for ser­ial cor­re­la­tion VERSUS using the time series regres­sion with arima errors you show above? Specif­i­cally the fore­cast accu­racy and the infer­ence on the coef­fi­cients. Thanks!

    • http://robjhyndman.com/ Rob J Hyndman

      It depends on the pur­pose of the model. If you want to do fore­cast­ing, then you need to use a time series approach to use the ser­ial cor­re­la­tion in mod­i­fy­ing the fore­casts. If you want to under­stand the effect of each regres­sor, and are there­fore pri­mar­ily inter­ested in the regres­sion coef­fi­cients, then the ser­ial cor­re­la­tion is just a nui­sance and using the Newey-​​West approach is simpler.

      • Jim

        Thanks for the response that helps my under­stand­ing. Are the stan­dard errors from the time series regres­sion with arima errors for the pre­dic­tors X, adjusted in a way sim­i­lar to treat­ing the ser­ial cor­re­la­tion as a nui­sance — i.e does time series regres­sion with arima errors pro­duce accu­rate stan­dard errors and is thus the best of both worlds (fore­cast and inference)?

        • http://robjhyndman.com/ Rob J Hyndman

          Yes, the stan­dard errors from the regression+ARIMA model are accurate.

          • Geof­frey

            Hi Rob,

            Along these same lines — can you rec­om­mend an R tuto­r­ial for time series regres­sion, where the pri­mary inter­est is exoge­nous vari­able coef­fi­cients (with prop­erly ARIMA cor­rected stan­dard errors)? Every­thing I’ve found so far is focused on fore­cast­ing. Thank you.

          • http://robjhyndman.com/ Rob J Hyndman

            Try Cryer and Chan’s book, chap­ter 11.

  • Aan­shi

    Hi. Would you please explain how to cal­su­late (white noise process) ?

    I am try­ing to cal­cu­late base­line sales usring ARIMAX model.
    Details for the same:
    Depen­dent vari­able= Sales
    Inde­pen­dent Vari­able (xreg)= Pro­mo­tion flags and sea­son­al­ity index

    Would B= xreg coef­fi­cient (be it for promo flag or sea­son­al­ity index)
    Xt = xreg (promo flag or sea­son­al­ity index) itself?

    • http://robjhyndman.com/ Rob J Hyndman

      Try ask­ing about spe­cific prob­lems on cross​val​i​dated​.com.

      An esti­mate of the white noise process is obtained via the residuals.

  • Broke

    Hi Rob,
    Would you please explain how to cal­cu­late Zt val­ues for the data points?

    • http://robjhyndman.com/ Rob J Hyndman

      Esti­mates of z_​t are given by the resid­u­als, which are nor­mally avail­able with the resid­u­als() function.

      • Broke

        I used resid­u­als func­tion on model. The out­put is almost equiv­a­lent to sub­tract­ing fitted/​predicted series from actual series. And these are Zt val­ues. Cor­rect me if I am wrong

        • Broke

          Hi Rob,
          Await­ing your reply
          Thanks

  • Kris

    What is the actual out­put shown from arima() in R?

    Say I esti­mate an AR(1) model with some exoge­nous vari­ables, x:

    fit <- arima(y, order = c(1, 0, 0), method = “ML”, xreg = x)

    Then the out­put shown in R will be:

    Series: y
    ARIMA(1,0,0) with non-​​zero mean
    Coef­fi­cients:
    ar1 inter­cept x_​1 x_​2 x_​3

    0.8440 –1.0413 0.0009 0.0014 -
    s.e. 0.0051 0.3055 0.0003 0.0010

    Will the esti­mates on x “come” from the first regres­sions with y_​t = Bx_​t + n_​t, while the esti­mate on ar1 comes from the sec­ond regres­sion n_​t = phi_​t n_​t-​​1 + z_​t

    In other words, will R run the two regres­sion, sav­ing the rel­e­vant out­put from both and con­cate­nate an out­put of both?

    I mainly ask for inter­pre­ta­tion rea­sons, can I trust that the Beta and Phi esti­mates are mar­ginal changes?

    • http://robjhyndman.com/ Rob J Hyndman

      The para­me­ters are esti­mated simul­ta­ne­ously, not in two stages.

      • Kris

        Hi Rob,

        Thank you for the quick reply.

        I don’t know if my ques­tion is stu­pid, but I still don’t quite under­stand what out­put I am get­ting from arima().
        My main issue is when I try to esti­mate the same model;
        y ~ lag(y,-1) + x using dynlm() for exam­ple, I don’t get the same results. In my mind I should get the same results from both esti­ma­tion methods.

        Or would I need to cor­rect the esti­mates from dynlm by divid­ing them with (1-​​phi)?

        • http://robjhyndman.com/ Rob J Hyndman

          They are com­pletely dif­fer­ent mod­els as I’ve explained in the post. arima() fits a regres­sion with ARMA errors, but it fits it in one step, not in two stages as you have described. dynlm fits an ARMAX model.

  • anup par­mar

    Hi Rob,

    I am unable to run this code
    fcast <- forecast(fit2,xreg=rep(mean(usconsumption[,2]),8), h=8)
    Below is the error when i try to run above code.

    Error in as.data.frame(newdata) :
    argu­ment “new­data” is miss­ing, with no default
    kindly please help me out.

    • http://robjhyndman.com/ Rob J Hyndman

      Per­haps you haven’t loaded the fpp package.

  • anup par­mar

    Hi rob,
    when i try to run this code
    fit <- Arima(y, xreg=x, order=c(1,1,0))

    out­put is not com­ing and it showed me the below error

    Error in NCOL(x) : object ‘y’ not found
    kindly please help me out.

    • http://robjhyndman.com/ Rob J Hyndman

      Make sure x and y exist.

    • anup par­mar

      thank you rob!

      One more ques­tion how to cal­cu­late fore­cast v/​s actual per­for­mance
      mea­sure­ment in R?

  • anup par­mar

    Hi rob,
    how to cal­cu­late fore­ast v/​s actual per­for­mance mea­sure­ment in R? and how to draw over­lay graph in R?