[R] Error message when adding drift for Arima model

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Mon May 13 18:33:06 CEST 2019


Hello,

Sorry for the late reply.
Inline.

Às 17:54 de 10/05/19, Michael Howell escreveu:
> Rui,
> I'm still new to ARIMA forecasting but I examined the PACF and saw 
> significant correlation at lag 2. 

You saw a PACF with a significant correlation at lag 2 but not at lag 1. 
When this happens, it many times means that you shouldn't consider the 
lag 2. In fact, it might mean that the process is nonlinear.
And the ACF shows an insignificant lag 1.

Try

ords <- list(c(1, 0, 0), c(2, 0, 0), c(0, 0, 1))
fit_list <- lapply(ords, function(o)
   Arima(tsdata, order = o, include.drift = TRUE))
sapply(fit_list, AIC)
sapply(fit_list, BIC)


Which gives the minimum AIC? And BIC?
These are not perfect and automated model selection can have problems, 
but it's not unreasonable to compare them.

I believe this is off-topic for R-Help, since it's a question about 
statistics and nonlinear time series is a really, really broad field to 
be discussed here. Try to find local help on this.

Hope this helps,

Rui Barradas

The ACF showed a more gradual decline
> which seemed to indicate it was Autoregressive. That should mean it's a 
> AR(2) process right?
> 
> image.png
> **//___^
> Regards,
> Michael Howell
> 
> 
> On Fri, May 10, 2019 at 12:51 AM Rui Barradas <ruipbarradas using sapo.pt 
> <mailto:ruipbarradas using sapo.pt>> wrote:
> 
>     Why not
> 
>     Arima(tsdata, c(0, 0, 1), include.drift = TRUE)
> 
>     ?
> 
>     Why do you say it should be an AR(2) model?
> 
>     Hope this helps,
> 
>     Rui Barradas
> 
>     Às 06:43 de 10/05/19, Rui Barradas escreveu:
>      > Hello,
>      >
>      > This is just a typo, in R logical values ("true) are not character
>      > strings. You must pass FALSE (the default, can be omited) or TRUE.
>      >
>      > fitdata  <-  Arima(tsdata, c(2, 0, 0), include.drift = TRUE)
>      >
>      >
>      >  From the help page ?logical
>      >
>      > Details
>      >
>      > TRUE and FALSE are reserved words denoting logical constants in
>     the R
>      > language, whereas T and F are global variables whose initial
>     values set
>      > to these. All four are logical(1) vectors.
>      >
>      > Hope this helps,
>      >
>      > Rui Barradas
>      >
>      > Às 00:26 de 10/05/19, Bert Gunter escreveu:
>      >> In future, always cc the list (unless it's personal,which this
>     isn't). I
>      >> have done so here. As I am largely ignorant on the subject
>     matter, others
>      >> will have to help, which is why you should cc the list.
>      >>
>      >> Cheers,
>      >> Bert Gunter
>      >>
>      >> "The trouble with having an open mind is that people keep coming
>     along
>      >> and
>      >> sticking things into it."
>      >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>      >>
>      >>
>      >> On Thu, May 9, 2019 at 3:49 PM Michael Howell
>     <mchowell2 using gmail.com <mailto:mchowell2 using gmail.com>>
>      >> wrote:
>      >>
>      >>> I apologize for that. The Arima() function that I'm trying to
>     use comes
>      >>> from the forecast package. I created a time series object using
>     the
>      >>> above
>      >>> 24 observations. The initial model I created doesn't seem to
>     perform so
>      >>> well so I thought a drift term might fit the data better. I
>     used the
>      >>> following code to create the time series object:
>      >>>
>      >>> tsdata<- ts(data, start = c(1,1), end = c(24,1), frequency = 1)
>      >>>
>      >>>
>      >>> Where* data* is the dataframe that contains the initial 24
>     observations.
>      >>> I then used the following code to try to create the model:
>      >>>
>      >>> fitdata  <-  Arima(tsdata,c(2,0,0),include.drift="true")
>      >>>>
>      >>>
>      >>> After doing this I obtained the following error message:
>      >>>
>      >>> Error in (order[2] + seasonal$order[2]) > 1 & include.drift:
>     operations
>      >>>> are possible only for numeric, logical or complex types
>      >>>> Traceback:
>      >>>>
>      >>>> 1. Arima(tsdata, c(2, 0, 0), include.drift = "true")
>      >>>
>      >>>
>      >>>   I hope this is more clear.
>      >>>
>      >>> On Thu, May 9, 2019 at 4:39 PM Bert Gunter
>     <bgunter.4567 using gmail.com <mailto:bgunter.4567 using gmail.com>>
>      >>> wrote:
>      >>>
>      >>>> Please start by reading and following the posting guide linked
>     at the
>      >>>> bottom of this email. In particular:
>      >>>>
>      >>>> 1) Post in **plain text** on this plain text list so we don't
>     get the
>      >>>> mangled html of your post.
>      >>>>
>      >>>> 2) Tell us what package Arima() is in.
>      >>>>
>      >>>> Cheers,
>      >>>> Bert Gunter
>      >>>>
>      >>>>
>      >>>>
>      >>>>
>      >>>> On Thu, May 9, 2019 at 2:27 PM Michael Howell
>     <mchowell2 using gmail.com <mailto:mchowell2 using gmail.com>>
>      >>>> wrote:
>      >>>>
>      >>>>> Hello everyone,
>      >>>>> So this is my first post to this list, I'm trying to fit an
>     Arima
>      >>>>> (2,0,0)
>      >>>>> model and I think a drift term would help but I'm getting an
>     error
>      >>>>> term
>      >>>>> when I'm trying to include it. Here is my data:
>      >>>>>
>      >>>>> -6.732172338
>      >>>>> -2.868884273
>      >>>>> -5.371585089
>      >>>>> -6.512740463
>      >>>>> -4.171062657
>      >>>>> -5.738499071
>      >>>>> -3.343947176
>      >>>>> -1.944879508
>      >>>>> -5.464109272
>      >>>>> -3.189183392
>      >>>>> -3.684700232
>      >>>>> -2.168303451
>      >>>>> -2.329837082
>      >>>>> -0.761979236
>      >>>>> -2.189025304
>      >>>>> 1.094238807
>      >>>>> -4.812300745
>      >>>>> 0.784198777
>      >>>>> -1.567075922
>      >>>>> 0.143963653
>      >>>>> 1.131119051
>      >>>>> 2.899746353
>      >>>>> -0.498719993
>      >>>>> 3.121623505 I created a time series object with 24 annual
>      >>>>> observations. I
>      >>>>> didn't include dates because there isn't an observation for
>     every
>      >>>>> year.
>      >>>>>
>      >>>>> tsdata<-ts(read.csv("...\\Pre2001LaunchDateTraining.csv"),
>     start =
>      >>>>> c(1,1),
>      >>>>> end = c(24,1), frequency = 1) I then created a time series
>     object
>      >>>>> using
>      >>>>> the
>      >>>>> Arima() function. fitdata <-
>     Arima(tsdata,c(2,0,0),include.drift =
>      >>>>> "true")
>      >>>>> After executing I get this error: Error in (order[2] +
>      >>>>> seasonal$order[2]) >
>      >>>>> 1 & include.drift: operations are possible only for numeric,
>      >>>>> logical or
>      >>>>> complex types Traceback: 1. Arima(tsdata, c(2, 0, 0),
>     include.drift =
>      >>>>> "true")
>      >>>>> Any help would be greatly appreciated!
>      >>>>>
>      >>>>>          [[alternative HTML version deleted]]
>      >>>>>
>      >>>>> ______________________________________________
>      >>>>> R-help using r-project.org <mailto:R-help using r-project.org> mailing
>     list -- To UNSUBSCRIBE and more, see
>      >>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>      >>>>> PLEASE do read the posting guide
>      >>>>> http://www.R-project.org/posting-guide.html
>      >>>>> and provide commented, minimal, self-contained, reproducible
>     code.
>      >>>>>
>      >>>>
>      >>
>      >>     [[alternative HTML version deleted]]
>      >>
>      >> ______________________________________________
>      >> R-help using r-project.org <mailto:R-help using r-project.org> mailing list
>     -- To UNSUBSCRIBE and more, see
>      >> https://stat.ethz.ch/mailman/listinfo/r-help
>      >> PLEASE do read the posting guide
>      >> http://www.R-project.org/posting-guide.html
>      >> and provide commented, minimal, self-contained, reproducible code.
>      >>
>      >
>      > ______________________________________________
>      > R-help using r-project.org <mailto:R-help using r-project.org> mailing list
>     -- To UNSUBSCRIBE and more, see
>      > https://stat.ethz.ch/mailman/listinfo/r-help
>      > PLEASE do read the posting guide
>      > http://www.R-project.org/posting-guide.html
>      > and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list