fgamma {Renext} | R Documentation |
ML estimation of the Gamma distribution
Description
Fast Maximum Likelihood estimation of the Gamma distribution.
Usage
fgamma(x, check.loglik = FALSE)
Arguments
x |
Sample vector to be fitted. Should contain only positive non-NA values. |
check.loglik |
If |
Details
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.
Value
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. |
Note
The distribution is fitted by using the scale
parameter rather
than rate
(inverse of scale
).
Author(s)
Yves Deville
See Also
GammaDist
in the stats package.
Examples
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)
}