Next: invnor()
Up: MacAnova Help File
Previous: invF()
Contents
Usage:
invgamma(P, alpha [,upper:T or lower:F]), P and alpha REAL, elements of
P between 0 and 1, those of alpha > 0
|
Keywords:
probabilities, random numbers
invgamma(p,alpha) computes the pth quantile (100*p percent point) of the
gamma distribution with shape parameter alpha. Its principal use is to
compute critical values for test statistics with a gamma distribution
but may also be used to compute exact confidence intervals for a Poisson
mean.
The elements of p must be between 0 and 1; the elements of alpha must be
positive but need not be integers.
If neither p nor alpha is a scalar (single number), they must be the
same size and shape. If just one argument is a scalar, it is used to
compute all the elements of the result.
invgamma(p,alpha,upper:T) and invgamma(p,alpha,lower:F) compute the pth
upper tail quantile. The result is mathematically equivalent to
invgamma(1 - p, alpha) but may be more accurate for small p.
invgamma() is the inverse of cumgamma().
2*invgamma(p,df/2 [,upper:T]) is equivalent to invchi(p,df [,upper:T]).
mu*invgamma(runi(n),alpha)/alpha will generate a random sample of size n
from a gamma distribution with mean mu and shape parameter alpha.
You can use invgamma() to compute an "exact" confidence interval for mu
based on an observed value x_obs of a Poisson random variable with mean
mu.
Cmd> x_obs <- 11 # observed value of x
Cmd> mu_l <- invgamma(.025,x_obs) # lower 95% limit
Cmd> mu_u <- invgamma(.025,x_obs+1,upper:T) # upper 95% limit
Cmd> vector(mu_l,mu_u) # "exact" 95% confidence interval for mu
(1) 5.4912 19.682
Cmd> vector(cumpoi(x_obs,mu_u),cumpoi(x_obs,mu_l,upper:T)) # check
(1) 0.025 0.025
See also cumgamma(), cumchi(), invchi(), cumpoi(), runi().
Gary Oehlert
2003-01-15