I am using 'optim' with method L-BFGS-B for estimating the parameters of a tri-variate lognormal distribution using a tri-variate data. Following are the commands I have used.
#Definition of logliklihood
logl <- function (theta, x)
{
p1=dim(x)[2]
scale= theta[1:p1]
shape.vct = theta[(p1+1):length(theta)]
shape.cov = matrix(shape.vct,p1)
ll = dlnorm.rplus(x,shape.cov,scale,thres,log=TRUE)
-sum(log(ll))
}
# Define initial values for the parameters
p1=dim(x)[2]
scale.start = array(0,dim=p1)
shape.start = array(0,dim=c(p1,p1))
diag(shape.start)=1
shape.vct = as.vector(shape.start)
#define lower and upper limits of pars for L-BFGS-B
scale_lower=rep(-Inf,p1)
scale_upper=rep(Inf,p1)
shape_lower=c(.1,-1,-1,-1,.1,-1,-1,-1,.1)
shape_upper=c(Inf,1,1,1,Inf,1,1,1,Inf)
L=c(scale_lower,shape_lower)
U=c(scale_upper,shape_upper)
# Calculate the maximum likelihood
theta.start = c(scale.start,shape.vct)
mle = optim(theta.start,logl,x=x,method="L-BFGS-B",lower=L,upper=U)
After some iterations it returns the error "L-BFGS-B needs finite values of fn". This is concerned with the lower and upper bounds defined for the parameters, I guess as the variance covariance matrix tends to be singular one. Can anybody please suggest the general logic I should use in order to define feasible upper and lower bounds so to avoid singular variance covariance matrix.This is a trivaraite case, but i will have to deal with higher dimensional cases also. So it will be really helpful if somebody could suggest a general rule.Thanks in advance.