Why do I get negative variance from hessian matrix in optim function

 ̄綄美尐妖づ 提交于 2021-01-29 14:14:33

问题


I try to estimate mle parameters of a generalised gamma distribution.

I use optim function with a lower bound equal to one (since parameters must be positive) and BFGS method.

Initially, I estimate the log likelihood function as below:

negloglikgengamma<-function(thet,dat) {
            alpha<-thet[1]
            kappa<-thet[2]
            lamda<-thet[3]
            -sum(dggamma(y,scale=alpha,shape1=kappa,shape2=lamda,log=T))
}

I use minus log likelihood function in order to use "optim" and find the minimum.

Then I use optim function.

fitggamma<-optim(c(0.4,0.5,2),negloglikgengamma,hessian=TRUE,method="L-BFGS-  B",dat=y,lower=1)

The results are:

$par
[1] 1.000000 1.000000 2.165561

$value
[1] -0.1214229

$counts
function gradient 
       6        6 

$convergence
[1] 0

$message
[1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"

$hessian
              [,1]       [,2]          [,3]
[1,] -9.998753e-01  1.0000003 -2.924863e-05
[2,]  1.000000e+00  1.2063171 -9.530030e-02
[3,] -2.924863e-05 -0.0953003  4.402082e-02

I am trying to estimate s.e. and I notice that Var(alpha)=-9.998753e-01 <0. Why is this happening? What I should change?

来源:https://stackoverflow.com/questions/59951587/why-do-i-get-negative-variance-from-hessian-matrix-in-optim-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!