[R] maximum likelihood estimation
pari hesabi
statistics84 at hotmail.com
Fri Oct 10 08:04:57 CEST 2014
Hello,As an example for Exponential distribution the MLE is got by this structure:t <- rexp(100, 2)loglik <- function(theta){ log(theta) - theta*t}a <- maxLik(loglik, start=1)print(a)Exponential distribution has a simple loglikelihood function. But if a new pdf has a more complicated form like:pr(N(2)=n)= integral( ((2-x)^n)*(exp(ax-2))) - integral (((5-ax)^n)), both integrals are defined over the interval(0,2) with respect to x. I also need to use the loglike of the form : [F log(pr(n))]=lnL where F is the vector of observations and (n) is the vector of input for the defined pmf. Do you think how I can insert (define) the pr(n) in the loop below? loglik <- function(a) sum(F*(log(pr(n)))?> > n <- c(0,1,2,3,4,5,6,7,8)> > F<-c(0,0,1,3,5,7,8,11,10)> > loglik <- function(a) sum(F*(log(pr(n)))??????> > re <- maxLik (loglik, start=.5)> > summary(re)I would be grateful if you let me know your idea.Best Regards,pari
[[alternative HTML version deleted]]
More information about the R-help
mailing list