R/ig.fit.R

Defines functions ig_fit

Documented in ig_fit

# MLE for the Inverse Gaussian distribution

ig_fit <- function(x){
  DNAME <- deparse(substitute(x))
  stopifnot(is.numeric(x))
  samplerange <- max(x) - min(x)
  if (samplerange == 0) stop("all observations are identical")
  if (min(x) < 0 ) stop("The dataset contains negative observations. \nAll data must be non-negative real numbers.")
  n <- length(x)
  mu.hat <- mean(x)
  lambda.hat <- n / (sum(1 / x - 1 / mu.hat))
  fit <- as.matrix(c(mu.hat, lambda.hat))
  colnames(fit) <- c("Inverse Gaussian MLE ")
  rownames(fit) <- c("mu", "lambda")
  return(fit)
}

Try the goft package in your browser

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

goft documentation built on May 2, 2019, 6:32 a.m.