[R] maximum likelihood estimation

Arne Henningsen arne.henningsen at gmail.com
Fri Oct 10 15:43:07 CEST 2014


On 10 October 2014 08:04, pari hesabi <statistics84 at hotmail.com> wrote:
> 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

> [...]
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Your example is not reproducible:

> pr(N(2)=n)= integral( ((2-x)^n)*(exp(ax-2))) - integral (((5-ax)^n))
Error: unexpected '=' in "pr(N(2)="

Please format your email in a way that one can easily copy the R code
to the R console.

Best regards,
Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name



More information about the R-help mailing list