I´m trying to development a simple routine to run many Arima models result
from some parâmeters combination.
My data test have one year and daily level.
A part of routine is:
for ( d in 0:1 )
{ for ( p in 0:3 )
{ for ( q in 0:3 )
{ for ( sd in 0:1 )
{ for ( sp in 0:3 )
{ for ( sq in 0:3 )
{
Yfit=arima(Yst[,2],order=c(p,d,q),seasonal=list(order=c(sp,sd,sq),period=7),include.mean=TRUE,xreg=DU0)
}}}}}}
Until the step 187 it´s run normally, but in the step 187 return a error and
stop the program.
>
Yfit=arima(Yst[,2],order=c(1,0,1),seasonal=list(order=c(2,1,2),period=7),include.mean=TRUE,xreg=DU0)
Error in optim(init[mask], armafn, method = "BFGS", hessian = TRUE, control
= optim.control, :
non-finite finite-difference value [1]
My questions is:
1. What this error mean and why it occured?
2. How can I do to this program disregard any error and to continue to run
until the end of looping?
3. Someone know if already have any routine that do this?
Thanks
Flávio
[[alternative HTML version deleted]]
> ______________________________________________
> R-h...@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.
______________________________________________
R-h...@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.
This is VERY common -- the BFGS option of optim() is a variant of Roger Fletcher's 1970
variable metric code that I worked out with him in Jan 1976. It's a bit long in the tooth,
and does not include parameter bounds -- we only had about 8K maximum for program and data
at the time. That's K, not M or G.
Some options:
- if you can change to L-BFGS-B variant of optim() you can use box constraints, still with
numerical gradients. nlminb() also has them, as do several routines in optimx. Note that a
bound of 0 may still get you into trouble with numerical gradient approximations -- the
step can go over the "cliff" because the bounds constraints don't always get checked for
the numerical (f(x+delta) - f(x)) / delta. In fact, there is a lot of work still to be
done to make sure all the holes are plugged. I'm working on putting many such checks in
optimx, but it will be a few weeks yet before they are even on the R-forge version.
- you may be able to change your objective function with penalty or barrier functions, or
using log(parameter) to avoid zero divides etc.
Unfortunately, providing "automatic" minimization tools often means and automatic
generation of lots of error messages as these tools follow downhill directions until they
are in very weird parts of parameter spaces.
JN
On 10/22/2011 06:00 AM, r-help-...@r-project.org wrote:
> Message: 54
> Date: Fri, 21 Oct 2011 15:59:12 -0200
> From: Fl?vio Fagundes <flav...@gmail.com>
> To: r-help <r-h...@r-project.org>
> Subject: [R] Arima Models - Error and jump error
> Message-ID:
> <CANr1bppB3e4EGS9C82wV6je5...@mail.gmail.com>
> Content-Type: text/plain
______________________________________________
This is also the case for many routines called by the optimx package (nlm, nlminb, bobyqa,
Rvmmin, Rcgmin, etc.) Soon there'll be a Nelder-Mead variant and a Hooke & Jeeves with
bounds/box constraints. A couple of routines also have masks, which are parameters that
can be temporarily fixed for a run. These can be very useful for problems where one or two
parameters are "usually" fixed or set to one of only a few values.
This information may be of use for other package maintainers. For those wanting to use
optimx, get in touch with me off-list. Which reminds me that I have to get in touch with
someone who already mentioned they wanted some advice on just this matter.
JN
On 10/22/2011 06:00 AM, r-help-...@r-project.org wrote:
> Message: 61
> Date: Fri, 21 Oct 2011 17:08:25 +0200 (CEST)
> From: "NoSkill ButStyle" <NoSkill...@web.de>
> To: r-h...@r-project.org
> Subject: Re: [R] How to use gev.fit (package ismev) under box
> constraints?
> Message-ID: <594607686.882100.1319209705292.JavaMail.fmail@mwmweb023>
> Content-Type: text/plain; charset="UTF-8"
>
> Hallo,
>
> it seems as if something did not work with my first email
>
> I would like to estimate parameters of a general extreme value (GEV) distribution using maximum likelihood as implemented in the gev.fit function of package ismev. If I do the follwing:
>
> y.training<- c(22, 22, 18, 19, 18, 18, 22, 27, 25, 19, 18, 21, 18, 20, 18, 19, 18, 21, 29, 18, 22, 19, 19, 24, 18, 21, 22, 20, 20, 27, 18, 20, 20, 18, 18, 18, 21, 18, 18, 21, 26, 19, 18, 19, 19, 18, 19, 18, 20, 20, 25, 21, 26, 22, 20, 19, 22, 21, 21, 20, 20, 19, 18, 22, 22, 27, 19, 20, 26, 29, 18, 20, 19, 22, 23, 18, 20, 20, 22, 18, 23, 18, 20, 19, 27, 21, 22, 18, 18, 19, 18, 21, 18, 23, 18, 18, 20, 20, 24, 19, 18, 19, 19, 23, 19, 18, 25, 18, 24, 19)
> fit<-gev.fit(xdat=y.training,show=F)
> round(fit$mle,2) # 18.00 , 0.00 , 3.96
>
> # The estimated shape parameter is 3.96. I would like to perform the estimation under the constraint that the shape parameter is smaller than 1, but the following does not work:
>
> fit<-gev.fit(xdat=y.training,show=F,method="L-BFGS-B",lower=c(0,0,-2),upper=c(50,10,1))
> round(fit$mle,2) # 18.09 , 0.27 , 3.05
>
> It seems as is the "lower" and "upper" values are not passed to the optim function in the way they should be. A warning says that they are only passed to the "control" part of optim. Therefore my question: (How) is it possible to use the gev.fit-function to perform the ML estimation under the constraint that the shape parameter is smaller than 1? Or more general: Is it possible to use the gev.fit function under box constraints as it should be possible for optim?
>
> Thanks in advance.
>
>
>
> ------------------------------