简体   繁体   English

使用 R 的贝尼尼概率分布的参数估计

[英]Parameter Estimation of Benini Probability Distribution Using R

I want to estimate parameters of two-parameter Benini model.我想估计两参数贝尼尼模型的参数。 See the model function here: https://en.wikipedia.org/wiki/Benini_distribution We generalted data from this model using Inverse CDF method and tried to estimate parameters using fitdistr procedure in R under "MASS" package.在此处查看模型函数: https ://en.wikipedia.org/wiki/Benini_distribution 我们使用逆 CDF 方法从该模型中概括数据,并尝试使用 R 中“MASS”包下的 fitdistr 程序估计参数。 Code is below代码如下

###################################################
n=100
u=runif(n,0,1)
beta=.1
sigma=0.002
your_data<-sigma*exp((-1/beta*log(1-u))^(0.5));your_data
hist(your_data,prob=T,col=3,angle=c(45),density=20,main="Benini",cex.main=1)
mean(your_data)
length(your_data)
ELL=function(x,beta,sigma) ((2*beta)/x)*(exp(-beta*(log(x/sigma))^2))*(log(x/sigma))
library(MASS)
your_estimate=fitdistr(x = your_data,densfun = ELL,start = list(beta=0.01,sigma=0.002))
your_estimate

######################################################## ################################################# ######

But we get optim error, I do not know why?但是我们得到 optim 错误,我不知道为什么? because we should get estimates as we have generated data from the this model only.因为我们应该得到估计,因为我们只从这个模型中生成了数据。 Can anyone help to debug the R code.任何人都可以帮助调试R代码。 I tried with another method also like below but same error.我尝试了另一种方法,如下所示,但同样的错误。

##############################################

n=100
u=runif(n,0,1)
beta=.1
sigma=0.002
x<-sigma*exp((-1/beta*log(1-u))^(0.5));your_data



hist(x,prob=T,col=3,angle=c(45),density=20,main="Benini",cex.main=1)

library(stats4) ## loading package stats4
ll<-function(beta,sigma) 
{
n<-length(x)
-(n*log(2*beta)*sum(log(x))-beta*sum((log(x/sigma))^2)+sum(log(log(x/sigma))))
}

fit=mle(minuslogl=ll,start=list(beta=0.1,sigma=0.002),method="CG")
summary(fit)
# #

Help to debug the R code.帮助调试 R 代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM