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

______________________________________________
R-help@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.

Reply via email to