1

I am at the beginning of the study of the language R-programming, and I try to analyse the MLE of this paper "Parameter Estimations for Some Modifications of the Weibull Distribution "

This my code

library(nleqslv)

Weibull.mle<-function(a=1,b=3,c=1,n=100){

u<-runif(n)

sim.data<-((-log(1-u^(1/c)))/a)^(1/b)   
  x<-c() 
  for(i in 1:n){x[i]<-sim.data[i]}

log.likeAll<-function(x){

    aa <- x[1]
    bb <- x[2]
    cc <- x[3]

    y <- numeric(3)     
    y[1]<-(n/aa)-sum(sim.data^bb)+(cc-1)*sum(((sim.data^bb)*exp(-aa*(sim.data^bb)))/(1-exp(-aa*(sim.data^bb))))
    y[2]<-(n/bb)+sum(log(sim.data))-aa*sum((sim.data)^bb*log(sim.data))+aa*(cc-1)*sum((log(sim.data)*(sim.data^bb)*exp(-aa*(sim.data^bb)))/(1-exp(-aa*(sim.data^bb))))
    y[3]<-(n/cc)+sum(log(1-(exp(-aa*(sim.data^bb)))))

        return(y)
}

 estAll<-nleqslv(c(a,b,c),log.likeAll)

a.est<-estAll$x[1]
b.est<-estAll$x[2]
c.est<-estAll$x[3]

output<-c(a.est,b.est,c.est)

return(output)
}
#Testing#
Weibull.mle(a=1,b=3,c=1,n=100)

I don't know if my code is complete or there is error

Please, Help me Thanks.

B--rian
  • 5,578
  • 10
  • 38
  • 89
Hamada Al
  • 111
  • 1
  • Well, when you run the function, does it return an error? – nrussell Jan 04 '16 at 13:54
  • No , but print this [1] 0.5045443 4.9275237 0.5104492 – Hamada Al Jan 04 '16 at 13:59
  • but , i feel like that the function not complete or does not work – Hamada Al Jan 04 '16 at 14:01
  • Please elaborate on that. Is it just a gut feeling of yours? Or did you attempt to validate your parameter estimates, and find that they are not suitable? If so, please explain. – nrussell Jan 04 '16 at 14:06
  • Because I'm new in the R-program I copy the function of another scientific research and then modify a little programming But I think that the program is not compatible with itself – Hamada Al Jan 04 '16 at 14:14

0 Answers0