Dear All,
I am trying to maximize logL in order to find Maximum Likelihood Estimate (MLE) of 5 parameters (alpha1, beta1, alpha2, beta2, p) using NLM function in R as follows.
# Defining Log likelihood – In the function it is noted as logL
> library(stats)
> loglike1<- function(x)
+ {
+ alpha1<-x[1]
+ beta1<-x[2]
+ alpha2<-x[3]
+ beta2<-x[4]
+ p<-x[5]
+ n<- mydata[3]
+ e<-mydata[4]
+ f1<- ((1+beta1/e)^(-n))*((1+e/beta1)^(-alpha1))*gamma(alpha1+n)/(gamma(n+1)*gamma(alpha1))
+ f2<- ((1+beta2/e)^(-n))*((1+e/beta2)^(-alpha2))*gamma(alpha2+n)/(gamma(n+1)*gamma(alpha2))
+ logL=sum(log(p*f1+(1-p)*f2))
+ logL<- -logL
+ }
# Supplying starting parameter values
> theta<-c(.2041,.0582, 1.4150, 1.8380,0.0969)
# Calculating MLE using NLM function
> result<- nlm(loglike1, theta, hessian=TRUE, print.level=1)
Now the problem is, this is not working as there is no improvement in final parameter estimate over starting values and NLM just stops just after 1 iteration with gradient value of all the 5 parameters as zero. I have tried other set of starting values, but then also I am getting final parameter estimates similar to starting values and iteration stops just after one step. When I check for warnings, R displays following kind of warnings:
NA/Inf replaced by maximum positive value
value out of range in 'gammafn'
Please suggest what I should do. I am expecting the final MLE of alpha1, alpha2, beta1 and beta2 greater than 0 and P should lie between 0 to 1.
Thanks & Regards,
Madan Gopal Kundu
Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8. http://downloads.yahoo.com/in/internetexplorer/
|