[R] Error optimizing Poisson log-likelihood with L-BFGS-B

Sergey Goriatchev sergeyg at gmail.com
Wed Oct 31 16:49:16 CET 2007


Dear R users,
I have following code, estimating Poisson log-likelihood a number of times:


poisson.loglik <- function(mu, y){
    n <- NROW(y)
    logl <- sum(y)*log(mu)-n*mu
    return(-logl)
    }

estimates <- numeric(1e5)

for(i in seq_along(estimates)){
estimates[i] <- optim(par=1, poisson.loglik, method="L-BFGS-B",
lower=0, y=rpois(10,lambda=2))$par
}

I cannot run this because I always get an error message:

Error in optim(par = 1, poisson.loglik, lower = 0, method = "L-BFGS-B",  :
  non-finite finite-difference value [1]

Could someone enlighten me what that means and why this happens?

THanks in advance,
Sergey



More information about the R-help mailing list