使用method =“L-BFGS-B”时,优化错误,L-BFGS-B需要有限值fn

时间:2015-12-15 15:25:45

标签: optimization singular

我使用方法L-BFGS-B的'optim'来使用三变量数据估计三变量对数正态分布的参数。以下是我使用的命令。

#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)

经过一些迭代后,它返回错误“L-BFGS-B需要fn的有限值”。这涉及为参数定义的下限和上限,我猜因为方差协方差矩阵倾向于是单数的。任何人都可以建议我应该使用的一般逻辑,以便定义可行的上限和下限,以避免奇异方差协方差矩阵。这是一个trivaraite情况,但我将不得不处理更高维度的情况。所以,如果有人能提出一般规则,那将会非常有帮助。谢谢。

0 个答案:

没有答案