[R] Using MLE on a somewhat unusual likelihood function

Hugo André karlhugoandre at gmail.com
Tue Nov 7 06:02:02 CET 2017

So I am trying to use the mle command (from stats4 package) to estimate a
number of parameters using data but it keeps throwing up this error message:

Error in solve.default(oout$hessian) :
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0

This error sometimes indicates that the list of starting values is too far
from optimum but this is unlikely since I picked values close to where the
parameters usually end up. I have also tried switching these around a bit.

Here is the code:

  xhat = c(statemw-(1-alpha)*rval)
  survivalf <- function(x) {(1-plnorm(statemw,mean=mu,sd=logalpha))}

wagefn <- function(lam, eta, alpha, xhat, mu, logalpha)  {
  wagevec = matrix(nrow=n,ncol=1)
    for (i in 1:n) {

    if (cpsdata2[i,2] > 0){
     wagevec[i,] <-
    } else if (cpsdata2[i,1,]==statemw) {
      wagevec[i,] <-
    } else if (cpsdata2[i,1,]>statemw) {
      wagevec[i,] <-
      else {
       wagevec[i,] <- NA
  lnwagevec <- log(wagevec)
  -sum(lnwagevec>-200 & ln2wagevec<200, na.rm=TRUE)

fit <- mle(wagefn, start=listmat, method= "L-BFGS-B",lower=

I know the likelihood function is a handful but it does return a reasonable
looking vector of values. The "lnwagevec>-200" etc is an inelegant way of
preventing values of Inf and -Inf from entering the sum, the actual values
rarely go as high as 8 or low as -5.

Thank you in advance to anyone responding!

	[[alternative HTML version deleted]]

More information about the R-help mailing list