[R] optim() and ARIMA

Ravi Varadhan RVaradhan at jhmi.edu
Tue Jan 27 18:09:17 CET 2009


This is "surely" not a bug in "optim".  "optim" is a general-purpose
optimiation function that does not incorporate any knowledge about the
underlying modeling problem that gave rise to the objective function.
Therefore, the onus is on the modeler/user to ensure that the objective
function is well-behaved (i.e. it is correctly coded, properly scaled, any
potential singularities are properly handled, etc.).  As John Nash had
pointed out, it is always a good idea to properly scale the function such
that the components of gradient vector are similar, and to provide analytic
gradients.  Expecting a general-purpose optimizer to do the ground work for
you is not going to be fruitful.  

If you are not willing to do the groundwork then the next best thing is to
try different starting values.  Based on the knowledge of how ARIMA models
behave, you should be able to come up with multiple (sensible) starting
values.

Ravi.


----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Gerard M. Keogh
Sent: Tuesday, January 27, 2009 11:17 AM
To: nashjc at uottawa.ca
Cc: r-help at r-project.org
Subject: Re: [R] optim() and ARIMA

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. 
****************************************************************************
*******



______________________________________________
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.




More information about the R-help mailing list