[R] optim() and ARIMA

nashjc at uottawa.ca nashjc at uottawa.ca
Tue Jan 27 17:59:24 CET 2009


The optim() function really does no "statistics", so outlier detection is
not part of it. It is a link to function minimization. Ravi Varadhan and I
are doing some work to see what might be feasible to do to improve optim()
and unify the many optimization tools to help users choose the tools more
easily. Readers interested can contact me off-list and I'll send them the
coordinates of the wiki we're using to collaborate; help definitely
welcome.

It does occur to me that BFGS, as implemented in R, does not have bounds
constraints on parameters, so it is not impossible for inadmissible values
to be sent to the function to be minimized (and hence to the gradient
estimator). I'm currently struggling to learn how to work with the R
internals to add bounds constraints to BFGS, since the code at the C level
is pretty straightforward. (My learning woes are in how to interface R and
C properly.)

And over a career in nonlinear fitting, I've found plenty of just plain
nasty functions that will give trouble to software. It's part of the
scenery of this area of work.

Perhaps someone who has knowledge of how various arima tools in R are
implemented can comment if there are filters and scaling before optim() is
called.

JN

> Surely, this sounds like a bug in the optim function.
>
> The rule of thumb with ts data is to scale so that data have mean 0 and
> unit variance and then fit
>    a) for non-seasonal data the IMA model (0,1,1); and
>    b) for seasonal data so-called Airline Model (0,1,1)X(0,1,1)S
> see for example A course in TS analysis by Daniel Pena.
> These can usually be fit to most series unless they are very irregular
> (e.g. mainly zeros) and then Box-Jenkins ARIMA is inappropriate.
>
> The fit of any other model is then judged against these two models. If a
> proposed model fit fails it is usual report the fault and then to step
> over
> that model and try the next in sequence - optim should do this, if not
> then
> it's a code fault.
> Very often with nasty series only the 2 basic models can be fit and these
> results are reported - but for these the parameters may not even fully
> converge.
> The moral of all this is that automatic modelling methods are handy but
> not
> a substitute for looking at the acf and choosing an appropriate
> parameterisation.
>
> Can someone say whether optim has automatic outlier detection - this is a
> must have with this type of procedure.
>
> Gerard
>
>
>
>
>
>              nashjc at uottawa.ca
>              Sent by:
>              r-help-bounces at r-                                          To
>              project.org               r-help at r-project.org
>                                                                         cc
>
>              27/01/2009 15:45                                      Subject
>                                        Re: [R] optim() and ARIMA
>
>
>
>
>
>
>
>
>
>
> dhabby wrote:
>     Last week I run in to a lot a problems triyng to fit an ARIMA model
> to
> a
>     time series. The problem is that the internal process of the arima
> function
>     call function "optim" to estimate the model parameters, so far so
> good...
>     but my data presents a problem with the default method "BFGS" of the
> optim
>     function, the output error looks like this:
>
> Error en optim(init[mask], armafn, method = "BFGS", hessian = TRUE,
> control
> = optim.control,  :
>   non-finite finite-difference value [7]
>
> I don't know much about the calls from ARIMA to optim, but when I
> modified
> Fletcher's 1970 VM method (called BFGS in R), I was aiming to make it
> extremely robust to messy functions. (I had machinery with only 6 hex
> digits for floating point and no guard digits. Furthermore, only 8K bytes
> for program AND data. This was 1975/6.) However, BFGS needs gradients,
> and
> it is clear there's some sort of trouble approximating them with finite
> differences.
>
> Changing optimization methods might succeed on this occasion, but your
> problem is more likely bad scaling or some setup where your ARIMA model
> essentially is not sensible. Can you duplicate the message on a small
> example problem?
>
> John Nash
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
>
>
> **********************************************************************************
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.  It is the policy of the Department of Justice, Equality and Law
> Reform and the Agencies and Offices using its IT services to disallow the
> sending of offensive material.
> Should you consider that the material contained in this message is
> offensive you should contact the sender immediately and also
> mailminder[at]justice.ie.
>
> Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le
> haghaidh an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a
> tarchuireadh agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi
> phribhléid inti. Toirmisctear aon athbhreithniú, atarchur nó leathadh a
> dhéanamh ar an bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon
> ghníomh a dhéanamh ar a hiontaoibh, ag daoine nó ag eintitis seachas an
> faighteoir beartaithe. Má fuair tú é seo trí dhearmad, téigh i dteagmháil
> leis an seoltóir, le do thoil, agus scrios an t-ábhar as aon ríomhaire. Is
> é beartas na Roinne Dlí agus Cirt, Comhionannais agus Athchóirithe Dlí,
> agus na nOifígí agus na nGníomhaireachtaí a úsáideann seirbhísí TF na
> Roinne, seoladh ábhair cholúil a dhícheadú.
> Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa
> teachtaireacht seo is ceart duit dul i dteagmháil leis an seoltóir
> láithreach agus le mailminder[ag]justice.ie chomh maith.
> ***********************************************************************************
>
>
>




More information about the R-help mailing list