简体   繁体   中英

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. 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? because we should get estimates as we have generated data from the this model only. Can anyone help to debug the R code. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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