Re: [R] Problem NOT with optim()

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 02 May 2006 - 01:58:56 EST

optim does not call chol()!

Please use the debugging tools described in Writing R Extensions (R >= 2.3.0) to find out what is actually happening. This looks like a bug in your own code. (Remember that you have imposed the constraint z >= 0 and not z > 0.)

On Mon, 1 May 2006, Fernando Saldanha wrote:

> I am having a problem with optim() using the "L-BFGS-B" method. When I
> set the lower limit for the third parameter equal to zero I get an
> error message:
>
>> low.lim.3 <- 0
>> phi_opt <- optim(phi_, model_lik, NULL, method = "L-BFGS-B", lower=c(0.2, -100, low.lim.3, 0), upper= c(10, 100, 10, 10), control = list(maxit = 1000, parscale = c(0.2, u1, 0.002, 0.002), trace = 0, REPORT = 3), hessian = FALSE)
> Error in chol(M) : the leading minor of order 1 is not positive definite
>
> However, setting that limit just above zero fixes things:
>
>> low.lim.3 <- 0.001
>> phi_opt <- optim(phi_, model_lik, NULL, method = "L-BFGS-B", lower=c(0.2, -100, low.lim.3, 0), upper= c(10, 100, 10, 10), control = list(maxit = 1000, parscale = c(0.2, u1, 0.002, 0.002), trace = 0, REPORT = 3), hessian = FALSE)
>> cat("Optimal parameters:", phi_opt$par, "\n")
> Optimal parameters: 0.3 0.005316 0.001280 0.0006127
>> cat("Max likelihood:", -phi_opt$value, "\n\n")
> Max likelihood: 1035
>
> This does not seem to be happening because the function to be
> optimized, which is minus the likelihood of a SS object (see package
> SSPIR) is badly behaved:

There is no package SSPIR, only sspir, as far as I can see.

It looks like it _is_ badly behaved at zero, which you have not tested.

>> model.opt <- model
>> phi(model.opt) <- phi_opt$par
>> for(i in seq(0.0001, 0.0015, by = 0.0001)) {
> + phi(model.opt)[3] <- i
> + model.f <- kfilter(model.opt)
> + cat(i, model.f$likelihood, "\n")
> + }
> 1e-04 828.8
> 2e-04 888.2
> 3e-04 930.5
> 4e-04 961.1
> 5e-04 983.5
> 6e-04 1000
> 7e-04 1012
> 8e-04 1021
> 9e-04 1027
> 0.001 1031
> 0.0011 1034
> 0.0012 1035
> 0.0013 1035
> 0.0014 1035
> 0.0015 1033
>>
>
> This is in practice a problem as one has to manually tweak these
> limits. Any insights on how to deal with this issue?
>
> Thanks in aedvance.
>
> Fernando Saldanha
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue May 02 02:04:27 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 02 May 2006 - 04:09:57 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.