| egamma | R Documentation |
Estimate the shape and scale parameters (or the mean and coefficient of variation) of a Gamma distribution.
egamma(x, method = "mle", ci = FALSE,
ci.type = "two-sided", ci.method = "normal.approx",
normal.approx.transform = "kulkarni.powar", conf.level = 0.95)
egammaAlt(x, method = "mle", ci = FALSE,
ci.type = "two-sided", ci.method = "normal.approx",
normal.approx.transform = "kulkarni.powar", conf.level = 0.95)
x |
numeric vector of non-negative observations.
Missing ( |
method |
character string specifying the method of estimation. The possible values are: |
ci |
logical scalar indicating whether to compute a confidence interval for the mean.
The default value is |
ci.type |
character string indicating what kind of confidence interval to compute.
The possible values are
|
ci.method |
character string indicating which method to use to construct the confidence interval.
Possible values are |
normal.approx.transform |
character string indicating which power transformation to use when |
conf.level |
a scalar between 0 and 1 indicating the confidence level of the confidence interval. The default
value is |
Extended methods and derivations are available in
Probability distributions and parameter estimation: egamma.
Open the vignette locally with
vignette("distributions-and-estimation", package = "EnvStats").
a list of class "estimate" containing the estimated parameters and other information.
See
estimate.object for details.
When ci=TRUE and ci.method="normal.approx", it is possible for the
lower confidence limit based on the transformed data to be less than 0.
In this case, the lower confidence limit on the original scale is set to 0 and a warning is
issued stating that the normal approximation is not accurate in this case.
The gamma distribution takes values on the positive real line. Special cases of the gamma are the exponential distribution and the chi-square distributions. Applications of the gamma include life testing, statistical ecology, queuing theory, inventory control, and precipitation processes. A gamma distribution starts to resemble a normal distribution as the shape parameter a tends to infinity.
Some EPA guidance documents (e.g., Singh et al., 2002; Singh et al., 2010a,b) strongly recommend against using a lognormal model for environmental data and recommend trying a gamma distribuiton instead.
Steven P. Millard (EnvStats@ProbStatInfo.com)
Anderson, C.W., and W.D. Ray. (1975). Improved Maximum Likelihood Estimators for the Gamma Distribution. Communications in Statistics, 4, 437–448.
Forbes, C., M. Evans, N. Hastings, and B. Peacock. (2011). Statistical Distributions, Fourth Edition. John Wiley and Sons, Hoboken, NJ.
Grice, J.V., and L.J. Bain. (1980). Inferences Concerning the Mean of the Gamma Distribution. Journal of the American Statistician, 75, 929-933.
Hawkins, D. M., and R.A.J. Wixley. (1986). A Note on the Transformation of Chi-Squared Variables to Normality. The American Statistician, 40, 296–298.
Johnson, N.L., S. Kotz, and N. Balakrishnan. (1994). Continuous Univariate Distributions, Volume 1. Second Edition. John Wiley and Sons, New York, Chapter 17.
Kulkarni, H.V., and S.K. Powar. (2010). A New Method for Interval Estimation of the Mean of the Gamma Distribution. Lifetime Data Analysis, 16, 431–447.
Singh, A., A.K. Singh, and R.J. Iaci. (2002). Estimation of the Exposure Point Concentration Term Using a Gamma Distribution. EPA/600/R-02/084. October 2002. Technology Support Center for Monitoring and Site Characterization, Office of Research and Development, Office of Solid Waste and Emergency Response, U.S. Environmental Protection Agency, Washington, D.C.
USEPA. (2015). ProUCL Version 5.1.002 Technical Guide. EPA/600/R-07/041, October 2015. Office of Research and Development. U.S. Environmental Protection Agency, Washington, D.C.
Wilson, E.B., and M.M. Hilferty. (1931). The Distribution of Chi-Squares. Proceedings of the National Academy of Sciences, 17, 684–688.
GammaDist, estimate.object, eqgamma,
predIntGamma, tolIntGamma.
# Generate 20 observations from a gamma distribution with parameters
# shape=3 and scale=2, then estimate the parameters.
# (Note: the call to set.seed simply allows you to reproduce this
# example.)
set.seed(250)
dat <- rgamma(20, shape = 3, scale = 2)
egamma(dat, ci = TRUE)
#Results of Distribution Parameter Estimation
#--------------------------------------------
#
#Assumed Distribution: Gamma
#
#Estimated Parameter(s): shape = 2.203862
# scale = 2.174928
#
#Estimation Method: mle
#
#Data: dat
#
#Sample Size: 20
#
#Confidence Interval for: mean
#
#Confidence Interval Method: Optimum Power Normal Approximation
# of Kulkarni & Powar (2010)
# using mle of 'shape'
#
#Normal Transform Power: 0.246
#
#Confidence Interval Type: two-sided
#
#Confidence Level: 95%
#
#Confidence Interval: LCL = 3.361652
# UCL = 6.746794
# Clean up
rm(dat)
#====================================================================
# Using the reference area TcCB data in EPA.94b.tccb.df, assume a
# gamma distribution, estimate the parameters based on the
# bias-corrected mle of shape, and compute a one-sided upper 90%
# confidence interval for the mean.
#----------
# First test to see whether the data appear to follow a gamma
# distribution.
with(EPA.94b.tccb.df,
gofTest(TcCB[Area == "Reference"], dist = "gamma",
est.arg.list = list(method = "bcmle"))
)
#Results of Goodness-of-Fit Test
#-------------------------------
#
#Test Method: Shapiro-Wilk GOF Based on
# Chen & Balakrisnan (1995)
#
#Hypothesized Distribution: Gamma
#
#Estimated Parameter(s): shape = 4.5695247
# scale = 0.1309788
#
#Estimation Method: bcmle
#
#Data: TcCB[Area == "Reference"]
#
#Sample Size: 47
#
#Test Statistic: W = 0.9703827
#
#Test Statistic Parameter: n = 47
#
#P-value: 0.2739512
#
#Alternative Hypothesis: True cdf does not equal the
# Gamma Distribution.
#----------
# Now estimate the paramters and compute the upper confidence limit.
with(EPA.94b.tccb.df,
egamma(TcCB[Area == "Reference"], method = "bcmle", ci = TRUE,
ci.type = "upper", conf.level = 0.9)
)
#Results of Distribution Parameter Estimation
#--------------------------------------------
#
#Assumed Distribution: Gamma
#
#Estimated Parameter(s): shape = 4.5695247
# scale = 0.1309788
#
#Estimation Method: bcmle
#
#Data: TcCB[Area == "Reference"]
#
#Sample Size: 47
#
#Confidence Interval for: mean
#
#Confidence Interval Method: Optimum Power Normal Approximation
# of Kulkarni & Powar (2010)
# using bcmle of 'shape'
#
#Normal Transform Power: 0.246
#
#Confidence Interval Type: upper
#
#Confidence Level: 90%
#
#Confidence Interval: LCL = 0.0000000
# UCL = 0.6561838
#------------------------------------------------------------------
# Repeat the above example but use the alternative parameterization.
with(EPA.94b.tccb.df,
egammaAlt(TcCB[Area == "Reference"], method = "bcmle", ci = TRUE,
ci.type = "upper", conf.level = 0.9)
)
#Results of Distribution Parameter Estimation
#--------------------------------------------
#
#Assumed Distribution: Gamma
#
#Estimated Parameter(s): mean = 0.5985106
# cv = 0.4678046
#
#Estimation Method: bcmle of 'shape'
#
#Data: TcCB[Area == "Reference"]
#
#Sample Size: 47
#
#Confidence Interval for: mean
#
#Confidence Interval Method: Optimum Power Normal Approximation
# of Kulkarni & Powar (2010)
# using bcmle of 'shape'
#
#Normal Transform Power: 0.246
#
#Confidence Interval Type: upper
#
#Confidence Level: 90%
#
#Confidence Interval: LCL = 0.0000000
# UCL = 0.6561838
#------------------------------------------------------------------
# Compare the upper confidence limit based on
# 1) the default method:
# normal approximation method based on Kulkarni and Powar (2010)
# 2) Profile Likelihood
# 3) Chi-Square Approximation
# 4) Chi-Square Adjusted
# Default Method
#---------------
with(EPA.94b.tccb.df,
egamma(TcCB[Area == "Reference"], method = "bcmle", ci = TRUE,
ci.type = "upper", conf.level = 0.9)$interval$limits["UCL"]
)
# UCL
#0.6561838
# Profile Likelihood
#-------------------
with(EPA.94b.tccb.df,
egamma(TcCB[Area == "Reference"], method = "mle", ci = TRUE,
ci.type = "upper", conf.level = 0.9,
ci.method = "profile.likelihood")$interval$limits["UCL"]
)
# UCL
#0.6527009
# Chi-Square Approximation
#-------------------------
with(EPA.94b.tccb.df,
egamma(TcCB[Area == "Reference"], method = "mle", ci = TRUE,
ci.type = "upper", conf.level = 0.9,
ci.method = "chisq.approx")$interval$limits["UCL"]
)
# UCL
#0.6532188
# Chi-Square Adjusted
#--------------------
with(EPA.94b.tccb.df,
egamma(TcCB[Area == "Reference"], method = "mle", ci = TRUE,
ci.type = "upper", conf.level = 0.9,
ci.method = "chisq.adj")$interval$limits["UCL"]
)
# UCL
#0.65467
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.