Saturday, May 17, 2008

a bug from using optim for 1d problem

Recently, a bug was described on r-devel, one introduced by using optim for a one-dimensional optimization problem (rather than optimize): HoltWinters fitted level parameter not bounded between 0 and 1. Looking at the source code for HoltWinters, I see the author used L-BFGS-B... so, maybe this is also an example of that method going out of bounds.

The R code leading to the bug:
...
error <- function(p) hw(p, beta, gamma)$SSE
sol <- optim(optim.start["alpha"], error, method = "L-BFGS-B",
lower = 0, upper = 1, control = optim.control)
alpha <- sol$par
...

No comments: