R/pe.mle.R

Defines functions pe.mle

Documented in pe.mle

pe.mle <- function(x) {

  pe <- function(vec, x, n, sx) {
    theta <- exp( vec[1] )
    lambda <- exp( vec[2] )
    - n * log( theta * lambda ) + lambda * sx + theta * sum( exp( - lambda * x ) ) + n * log( 1 - exp( - theta ) )
  }

  n <- length(x)  ;  sx <- sum(x)
  f <- optim( par = c(1, 1), fn = pe, x = x, n = n, sx = sx, control = list(maxit = 5000) )
  f <- optim( par = f$par, fn = pe, x = x, n = n, sx = sx, control = list(maxit = 5000) )
  param <- exp( f$par )
  names(param) <- c("theta", "lambda")
  list(param = param, loglik = -f$value)
}

Try the geppe package in your browser

Any scripts or data that you put into this service are public.

geppe documentation built on June 24, 2024, 5:08 p.m.