Learn R Programming

RelDists (version 1.0.2)

GAo: The gamma family in its original parameterization

Description

The function GAo() defines The gamma, a two parameter distribution, for a gamlss.family object to be used in GAMLSS fitting using the function gamlss().

Usage

GAo(mu.link = "log", sigma.link = "log")

Value

Returns a gamlss.family object which can be used to fit a GAo distribution in the gamlss() function.

Arguments

mu.link

defines the mu.link, with "log" link as the default for the mu parameter.

sigma.link

defines the sigma.link, with "log" link as the default for the sigma.

Details

The gamma original with parameters mu and sigma has density given by

\(f(x|\mu,\sigma) = \frac{x^{\mu-1}e^{-x/\sigma}}{\sigma^\mu \Gamma(\mu)}\)

for \(x>0\), \(\mu>0\) and \(\sigma>0\). The parameter \(\mu\) is the shape parameter and \(\sigma\) is the scale parameter. In this parameterization \(\mu\) is the median of \(X\), \(E(X)=\mu \sigma\) and \(Var(X)=\mu \sigma^2\).

References

Abramowitz M, Stegun IA (1972). Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. Dover Publications, New York. ISBN 0486612724. Chapter 6: Gamma and Related Functions.

See Also

dGAo

Examples

Run this code
# Example 1
# Generating some random values with
# known mu and sigma
y <- rGAo(n=100, mu=0.75, sigma=1.3)

# Fitting the model
require(gamlss)
mod1 <- gamlss(y~1, sigma.fo=~1, family=GAo)

# Extracting the fitted values for mu and sigma
# using the inverse link function
exp(coef(mod1, what="mu"))
exp(coef(mod1, what="sigma"))

# Example 2
# Generating random values for a regression model

# A function to simulate a data set with Y as GAo
gendat <- function(n) {
  x1 <- runif(n)
  x2 <- runif(n)
  mu <- exp(1.45 - 3 * x1)
  sigma <- exp(2 - 1.5 * x2)
  y <- rGAo(n=n, mu=mu, sigma=sigma)
  data.frame(y=y, x1=x1, x2=x2)
}

set.seed(123)
dat <- gendat(n=500)

mod2 <- gamlss(y~x1, sigma.fo=~x2, 
               family=GAo, data=dat)

summary(mod2)

Run the code above in your browser using DataLab