Hi R-experts, I'm new to R in mle. I tried to do the following but just couldn't get it right. Hope someone can point out the mistakes. thanks a lot.
t <- c(1:90) y <- c(5,10,15,20,26,34,36,43,47,49,80,84,108,157,171,183,191,200,204,211,217,226,230, 234,236,240,243,252,254,259,263,264,268,271,277,290,309,324,331,346,367,375,381, 401,411,414,417,425,430,431,433,435,437,444,446,446,448,451,453,460,463,463,464, 464,465,465,465,466,467,467,467,468,469,469,469,469,470,472,472,473,473,473,473, 473,473,473,475,475,475,475) fr <- function(a, b, p, lambda){ l <- 0.5*(lambda + b*p + (1-p)*(lambda-b)) l^2 > lambda*b*p delta <- sqrt(abs(l^2 - b*p*lambda)) mt <- a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta) logl <- sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y))) return(-logl) } optim(c(15,0.01,0.5,0.01),fr, method="L-BFGS-B", lower = c(0.002, 0.002, 0.002, 0.002), upper = c(Inf, Inf, 0.999, Inf),control=list(fnscale=-1)) -- View this message in context: http://www.nabble.com/Maximum-likelihood-estimation-tp19304249p19304249.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.