Skip to content

optim() and ARIMA

3 messages · John C Nash, Gerard M. Keogh, Ravi Varadhan

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