[英]Log-likelihood of Nakagami distribution is infinite in R
I am fitting the normalized histogram of my dataset $x \\in [60,80]$ to Nakagami distribution. 我正在将[60,80] $中的数据集$ x \\的归一化直方图拟合为Nakagami分布。 First I have estimated the scale and shape parameters using dnaka
of VGAM
package through the following MLE code: 首先,我们估计使用比例和形状参数dnaka
的VGAM
包通过以下MLE代码:
ll <- function(par) {
if(par[1]>0 & par[2]>0) {return(-sum(log(dnaka(x, scale = par[1], shape = par[2]) ) ) )} # m=shape, ohm or spread = scale
else return(Inf)
}
mle = optim(c(1000,1), ll)
Then, I am estimating the log-likelihood value based on the estimated parameters through the following code: 然后,我通过以下代码基于估计的参数来估计对数似然值:
lik = sum(log(dnaka(x, shape = mle$par[1], scale = mle$par[2]) ) )
But the log-likelihood value lik is -Inf
. 但是对数似然值-Inf
是-Inf
。 I understand that this infinite value is due to the exp(.) term in the PDF equation of Nakagami distribution. 我知道这个无限值是由于Nakagami分布的PDF方程中的exp(。)项引起的。 Is there a way to estimate the finite log-likelihood value for the Nakagami distribution for my dataset $x \\in [60,80]$? 有没有办法为我的数据集$ x \\ in [60,80] $估算Nakagami分布的有限对数似然值? Thank you. 谢谢。
Please see my comment to the original question. 请参阅我对原始问题的评论。
Here is a working example using simulated data with scale = 1.5
and shape = 1
这是一个使用scale = 1.5
且shape = 1
模拟数据的工作示例
set.seed(2017);
x <- rnaka(10^4, scale = 1.5, shape = 1);
ll <- function(par) {
if (par[1] >= 0.5 && par[2] > 0) {
return(-sum(log(dnaka(x, scale = par[1], shape = par[2]))));
}
else return(Inf);
}
mle <- optim(c(0.5, 1), ll);
mle$par;
#[1] 1.4833965 0.9938022
ll(mle$par);
#[1] 7946.478
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.