fgamma | R Documentation |
Fast Maximum Likelihood estimation of the Gamma distribution.
fgamma(x, check.loglik = FALSE)
x |
Sample vector to be fitted. Should contain only positive non-NA values. |
check.loglik |
If |
The likelihood is concentrated with respect to the scale parameter. The concentrated log-likelihood is a strictly concave function of the shape parameter which can easily maximised numerically.
A list with the following elements
estimate |
Parameter ML estimates. |
sd |
Vector of (asymptotic) standard deviations for the estimates. |
loglik |
The maximised log-likelihood. |
check.loglik |
The checked log-likelihood. |
cov |
The (asymptotic) covariance matrix computed from theoretical or observed information matrix. |
info |
The information matrix. |
The distribution is fitted by using the scale
parameter rather
than rate
(inverse of scale
).
Yves Deville
GammaDist
in the stats package.
set.seed(9876)
alpha <- 0.06
beta <- rexp(1)
n <- 30
x <- rgamma(n, shape = alpha, scale = beta)
fit <- fgamma(x, check.loglik = TRUE)
## compare with MASS results
if (require(MASS)) {
fit.MASS <- fitdistr(x, densfun = "gamma")
rate <- 1 / fit$estimate["scale"]
est <- c(fit$estimate, rate = rate)
der <- rate * rate ## derivative of rate w.r.t scale
sdest <- c(fit$sd, rate = der * fit$sd["scale"])
tab <- rbind(sprintf(" %10.8f ", est),
sprintf("(%10.8f)", sdest))
colnames(tab) <- c("shape", "scale", "rate")
rownames(tab) <- c("est", "sd")
noquote(tab)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.