简体   繁体   中英

Maximum likelihood estimation of beta-normal in R

i want to estimate the parameters of beta-normal distribution.I've used the maxLik package

library(VGAM)
library(maxLik)
alfa=2;beta=3;mu=0;sigma=1
n=100
x=rbetanorm(n,alfa,beta,mu,sigma)
logLikFun=function(w){
  alfa=w[1]
  beta=w[2]
  mu=w[3]
  sigma=w[4]
  ll={-n*log(beta(alfa,beta))+(alfa-1)*sum(log(pnorm((x-mu)/sigma,mean=0,sd=1)))+(beta-1)*sum(log(1-pnorm((x-mu)/sigma,mean=0,sd=1)))-n*log(sigma)+sum(log(dnorm((x-mu)/sigma,mean=0,sd=1)))}
  ll
}
mle=maxLik(logLikFun,start=c(alfa=3,beta=2,mu=1,sigma=2))
summary(mle)

but it gives error

----------------------------------
Maximum Likelihood estimation
Newton-Raphson maximisation, 4 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -86.16515 
4  free parameters
Estimates:
      Estimate Std. error t value Pr(> t)
alfa     3.000        Inf       0       1
beta     2.941        Inf       0       1
mu       1.000        Inf       0       1
sigma    2.000        Inf       0       1
--------------------------------------------

the problem is the infinite value for the errors which is not acceptable. I would be pleased if someone could solve this problem.

The results are extremely dependent to the initial values. Also, you can set some initial values as fixed values.

For more information regarding the theoretical issues behind the code refer to this link .

library(VGAM)
library(maxLik)
alfa=1;beta=1;mu=0;sigma=1
n=100
x<-rbetanorm(n,alfa,beta,mu,sigma)
logLikFun<-function(w){
        alfa<-w[1]
        beta<-w[2]
        mu<-w[3]
        sigma<-w[4]
        ll<-{-n*log(beta(alfa,beta))+(alfa-1)*sum(log(pnorm((x-mu)/sigma,mean=0,sd=1)))+(beta-1)*sum(log(1-pnorm((x-mu)/sigma,mean=0,sd=1)))-n*log(sigma)+sum(log(dnorm((x-mu)/sigma,mean=0,sd=1)))}
        ll
}
mle<-maxLik(logLikFun,grad=NULL,hess=NULL,start=c(alfa=1,beta=1,mu=mean(x),sigma=1),"NR")
summary(mle)


OUTPUT:
--------------------------------------------
Maximum Likelihood estimation
Newton-Raphson maximisation, 10 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -139.6822 
3  free parameters
Estimates:
        Estimate Std. error t value  Pr(> t)    
alfa    0.4026     0.1190   3.384 0.000714 ***
beta    4.3981     2.9560   1.488 0.136794    
mu      2.0340     0.6135   3.315 0.000915 ***
sigma   1.0000     0.0000      NA       NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
--------------------------------------------

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