gamlss: Generalized Additive Models for Location Scale and Shape

View source: R/gamlss-5.R

gamlssR Documentation

Generalized Additive Models for Location Scale and Shape

Description

Returns an object of class "gamlss", which is a generalized additive model for location scale and shape (GAMLSS). The function gamlss() is very similar to the gam() function in S-plus (now also in R in package gam), but can fit more distributions (not only the ones belonging to the exponential family) and can model all the parameters of the distribution as functions of the explanatory variables (e.g. using linear, non-linear, smoothing, loess and random effects terms).

This implementation of gamlss() allows modelling of up to four parameters in a distribution family, which are conventionally called mu, sigma, nu and tau.

The function gamlssNews() shows what is new in the current implementation.

Usage

gamlss(formula = formula(data), sigma.formula = ~1, 
        nu.formula = ~1, tau.formula = ~1, family = NO(), 
        data, weights = NULL, 
        contrasts = NULL, method = RS(),  start.from = NULL,  
        mu.start = NULL,  sigma.start = NULL, 
        nu.start = NULL, tau.start = NULL, 
        mu.fix = FALSE, sigma.fix = FALSE, nu.fix = FALSE, 
        tau.fix = FALSE, control = gamlss.control(...), 
        i.control = glim.control(...), ...)
is.gamlss(x)
gamlssNews()

Arguments

formula

a formula object, with the response on the left of an ~ operator, and the terms, separated by + operators, on the right. Nonparametric smoothing terms are indicated by pb() for penalised beta splines, cs for smoothing splines, lo for loess smooth terms and random or ra for random terms, e.g. y~cs(x,df=5)+x1+x2*x3. Additional smoothers can be added by creating the appropriate interface. Interactions with nonparametric smooth terms are not fully supported, but will not produce errors; they will simply produce the usual parametric interaction

sigma.formula

a formula object for fitting a model to the sigma parameter, as in the formula above, e.g. sigma.formula=~cs(x,df=5). It can be abbreviated to sigma.fo=~cs(x,df=5).

nu.formula

a formula object for fitting a model to the nu parameter, e.g. nu.fo=~x

tau.formula

a formula object for fitting a model to the tau parameter, e.g. tau.fo=~cs(x,df=2)

family

a gamlss.family object, which is used to define the distribution and the link functions of the various parameters. The distribution families supported by gamlss() can be found in gamlss.family. Functions such as BI() (binomial) produce a family object. Also can be given without the parentheses i.e. BI. Family functions can take arguments, as in BI(mu.link=probit)

data

a data frame containing the variables occurring in the formula, e.g. data=aids. If this is missing, the variables should be on the search list.

weights

a vector of weights. Note that this is not the same as in the glm() or gam() function. Here weights can be used to weight out observations (like in subset) or for a weighted likelihood analysis where the contribution of the observations to the likelihood differs according to weights. The length of weights must be the same as the number of observations in the data. By default, the weight is set to one. To set weights to vector w use weights=w

contrasts

list of contrasts to be used for some or all of the factors appearing as variables in the model formula. The names of the list should be the names of the corresponding variables. The elements should either be contrast-type matrices (matrices with as many rows as levels of the factor and with columns linearly independent of each other and of a column of ones), or else they should be functions that compute such contrast matrices.

method

the current algorithms for GAMLSS are RS(), CG() and mixed(). i.e. method=RS() will use the Rigby and Stasinopoulos algorithm, method=CG() will use the Cole and Green algorithm and mixed(2,10) will use the RS algorithm twice before switching to the Cole and Green algorithm for up to 10 extra iterations

start.from

a fitted GAMLSS model which the fitted values will be used as staring values for the current model

mu.start

vector or scalar of initial values for the location parameter mu e.g. mu.start=4

sigma.start

vector or scalar of initial values for the scale parameter sigma e.g. sigma.start=1

nu.start

vector or scalar of initial values for the parameter nu e.g. nu.start=3

tau.start

vector or scalar of initial values for the location parameter tau e.g. tau.start=2

mu.fix

whether the mu parameter should be kept fixed in the fitting processes e.g. mu.fix=FALSE

sigma.fix

whether the sigma parameter should be kept fixed in the fitting processes e.g. sigma.fix=FALSE

nu.fix

whether the nu parameter should be kept fixed in the fitting processes e.g. nu.fix=FALSE

tau.fix

whether the tau parameter should be kept fixed in the fitting processes e.g. tau.fix=FALSE

control

this sets the control parameters of the outer iterations algorithm. The default setting is the gamlss.control function

i.control

this sets the control parameters of the inner iterations of the RS algorithm. The default setting is the glim.control function

...

for extra arguments

x

an object

Details

The Generalized Additive Model for Location, Scale and Shape is a general class of statistical models for a univariate response variable. The model assumes independent observations of the response variable y given the parameters, the explanatory variables and the values of the random effects. The distribution for the response variable in the GAMLSS can be selected from a very general family of distributions including highly skew and/or kurtotic continuous and discrete distributions, see gamlss.family. The systematic part of the model is expanded to allow modelling not only of the mean (or location) parameter, but also of the other parameters of the distribution of y, as linear parametric and/or additive nonparametric (smooth) functions of explanatory variables and/or random effects terms. Maximum (penalized) likelihood estimation is used to fit the (non)parametric models. A Newton-Raphson/Fisher scoring algorithm is used to maximize the (penalized) likelihood. The additive terms in the model are fitted using a backfitting algorithm.

is.gamlss is a short version is is(object,"gamlss")

Value

Returns a gamlss object with components

family

the distribution family of the gamlss object (see gamlss.family)

parameters

the name of the fitted parameters i.e. mu, sigma, nu, tau

call

the call of the gamlss function

y

the response variable

control

the gamlss fit control settings

weights

the vector of weights

G.deviance

the global deviance

N

the number of observations in the fit

rqres

a function to calculate the normalized (randomized) quantile residuals of the object

iter

the number of external iterations in the fitting process

type

the type of the distribution or the response variable (continuous or discrete)

method

which algorithm is used for the fit, RS(), CG() or mixed()

converged

whether the model fitting has have converged

residuals

the normalized (randomized) quantile residuals of the model

mu.fv

the fitted values of the mu model, also sigma.fv, nu.fv, tau.fv for the other parameters if present

mu.lp

the linear predictor of the mu model, also sigma.lp, nu.lp, tau.lp for the other parameters if present

mu.wv

the working variable of the mu model, also sigma.wv, nu.wv, tau.wv for the other parameters if present

mu.wt

the working weights of the mu model, also sigma.wt, nu.wt, tau.wt for the other parameters if present

mu.link

the link function for the mu model, also sigma.link, nu.link, tau.link for the other parameters if present

mu.terms

the terms for the mu model, also sigma.terms, nu.terms, tau.terms for the other parameters if present

mu.x

the design matrix for the mu, also sigma.x, nu.x, tau.x for the other parameters if present

mu.qr

the QR decomposition of the mu model, also sigma.qr, nu.qr, tau.qr for the other parameters if present

mu.coefficients

the linear coefficients of the mu model, also sigma.coefficients, nu.coefficients, tau.coefficients for the other parameters if present

mu.formula

the formula for the mu model, also sigma.formula, nu.formula, tau.formula for the other parameters if present

mu.df

the mu degrees of freedom also sigma.df, nu.df, tau.df for the other parameters if present

mu.nl.df

the non linear degrees of freedom, also sigma.nl.df, nu.nl.df, tau.nl.df for the other parameters if present

df.fit

the total degrees of freedom use by the model

df.residual

the residual degrees of freedom left after the model is fitted

aic

the Akaike information criterion

sbc

the Bayesian information criterion

Warning

Respect the parameter hierarchy when you are fitting a model. For example a good model for mu should be fitted before a model for sigma is fitted

Note

The following generic functions can be used with a GAMLSS object: print, summary, fitted, coef, residuals, update, plot, deviance, formula

Author(s)

Mikis Stasinopoulos, Bob Rigby, Calliope Akantziliotou and Vlasios Voudouris

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Rigby, R. A., Stasinopoulos, D. M., Heller, G. Z., and De Bastiani, F. (2019) Distributions for modeling location, scale, and shape: Using GAMLSS in R, Chapman and Hall/CRC. An older version can be found in https://www.gamlss.com/.

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, https://www.jstatsoft.org/v23/i07/.

Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017) Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.

(see also https://www.gamlss.com/).

See Also

gamlss.family, pdf.plot, find.hyper

Examples

 
data(abdom)
mod<-gamlss(y~pb(x),sigma.fo=~pb(x),family=BCT, data=abdom, method=mixed(1,20))
plot(mod)
rm(mod)

gamlss documentation built on May 29, 2024, 6:08 a.m.