[R] Maximum likelihood estimation (stats4::mle)

Ronald Kölpin ronald.koelpin at ruhr-uni-bochum.de
Mon Jul 21 21:10:24 CEST 2014


Dear R-Community,

I'm trying to estimate the parameters of a probability distribution
function by maximum likelihood estimation (using the stats4 function
mle()) but can't seem to get it working.

For each unit of observation I have a pair of observations (a, r)
which I assume (both) to be log-normal distributed (iid). Taking the
log of both values I have (iid) normally distributed random variables
and the likelihood function to be estimated is:

L = Product(F(x_i) - F(y_i), i=1..n)

where F is the Normal PDF and (x,y) := (log(a), log(r)). Taking the
log and multiplying by -1 gives the negative loglikelihood

l = Sum(log( F(x_i) - F(y_i) ), i=1..n)

However estimation by mle() produces the error "vmmin is not finite"
and "NaN have been created" - even though put bound on the parameters
mu and sigma (see code below).


library("stats4")

gaps <- matrix(nrow=10, ncol=4, dimnames=list(c(1:10),c("r_i", "a_i",
"log(r_i)", "log(a_i)")))
gaps[,1] <- c(2.6, 1.4, 2.2, 2.9, 2.9, 1.7, 1.3, 1.7, 3.8, 4.5)
gaps[,2] <- c(9.8, 20.5, 8.7, 7.2, 10.3, 11, 4.5, 5.2, 6.7, 7.6)
gaps[,3] <- log(gaps[,1])
gaps[,4] <- log(gaps[,2])

nll <- function(mu, sigma)
{
    if(sigma >= 0 && mu >= 0)
    {
        -sum(log(pnorm(gaps[,3], mean=mu, sd=sigma) - pnorm(gaps[,4],
mean=mu, sd=sigma)))
    }
    else
    {
        NA
    }
}

fit <- mle(nll, start=list(mu=0, sigma=1), nobs=10)
print(fit)


To be honest, I'm stumped and don't quite know what the problem is...

Regards and Thanks,

Ronald Kölpin



More information about the R-help mailing list