The gamlss Package - University of...

150
The gamlss Package May 29, 2006 Description The main GAMLSS library and datasets. Title A collection of functions to fit Generalized Additive Models for Location Scale and Shape. LazyLoad yes Version 1.2-0 Date 2006-5-28 Depends R (>= 2.2.1), graphics, stats, splines Imports MASS, survival Author Mikis Stasinopoulos <[email protected]>, Bob Rigby <[email protected]> with contributions from Calliope Akantziliotou. Maintainer Mikis Stasinopoulos <[email protected]> License GPL (version 2 or later) See file LICENSE. URL http://www.londonmet.ac.uk/gamlss/ R topics documented: abdom ............................................ 3 additive.fit .......................................... 4 aep .............................................. 5 aids ............................................. 6 BB .............................................. 7 BCCG ............................................ 9 BCPE ............................................ 11 BCT ............................................. 13 db .............................................. 15 BEINF ............................................ 16 BE .............................................. 18 bfp .............................................. 20 BI .............................................. 22 centiles.com ......................................... 24 centiles.pred ......................................... 25 centiles ........................................... 27 centiles.split ......................................... 29 checklink .......................................... 30 1

Transcript of The gamlss Package - University of...

Page 1: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

The gamlss PackageMay 29, 2006

Description The main GAMLSS library and datasets.

Title A collection of functions to fit Generalized Additive Models for Location Scale and Shape.

LazyLoad yes

Version 1.2-0

Date 2006-5-28

Depends R (>= 2.2.1), graphics, stats, splines

Imports MASS, survival

Author Mikis Stasinopoulos <[email protected]>, Bob Rigby<[email protected]> with contributions from Calliope Akantziliotou.

Maintainer Mikis Stasinopoulos <[email protected]>

License GPL (version 2 or later) See file LICENSE.

URL http://www.londonmet.ac.uk/gamlss/

R topics documented:

abdom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3additive.fit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4aep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5aids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6BB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7BCCG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9BCPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11BCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13db . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15BEINF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16BE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18bfp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20BI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22centiles.com . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24centiles.pred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25centiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27centiles.split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29checklink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30

1

Page 2: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

2 R topics documented:

coef.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33deviance.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35fabric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36find.hyper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37fitted.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39fitted.plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40formula.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41gamlss.control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42gamlss.cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43gamlss.family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44gamlss.fp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46gamlss.lo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47gamlss-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48gamlss.ps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49gamlss.random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50gamlss.ra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51gamlss.rc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53gamlss.scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57GA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58glim.control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60GU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61histDist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62hodges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64IC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65IG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66JSUo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68JSU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70LNO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72LO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74lo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75lpred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77make.link.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78model.frame.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81Mums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82NBII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83NBI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86NO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88NO.var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90par.plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91pdf.plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93PE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94PIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96plot.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98polyS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99PO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100predict.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101print.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103prof.dev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104prof.term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106

Page 3: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

abdom 3

ps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108Q.stats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110ra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112rc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113refit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114rent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115residuals.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117RG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118rqres.plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120SEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121SI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123stepGAIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125summary.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128term.plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129TF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131update.gamlss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132usair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134VGD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135WEI2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136WEI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138wp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139ZAIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141ZIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143

Index 146

abdom Abdominal Circumference Data

Description

The abdom data frame has 610 rows and 2 columns. The data are measurements of abdominalcircumference (response variable) taken from fetuses during ultrasound scans at Kings CollegeHospital, London, at gestational ages (explanatory variable) ranging between 12 and 42 weeks.

Usage

data(abdom)

Format

This data frame contains the following columns:

y abdominal circumference: a numeric vector

x gestational age: a numeric vector

Details

The data were used to derived reference intervals by Chittyet al. (1994) and also for comparingdifferent reference centile methods by Wright and Royston (1997), who also commented that thedistribution of Z-scores obtained from the different fitted models ’has somewhat longer tails thanthe normal distribution’.

Page 4: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

4 additive.fit

Source

Dr. Eileen M. Wright, Department of Medical Statistics and Evaluation, Royal Postgraduate Medi-cal School, Du Cane Road, London, W12 0NN.

References

Chitty, L.S., Altman, D.G., Henderson, A. and Campbell, S. (1994) Charts of fetal size: 3, abdomi-nal measurement.Br. J. Obstet. Gynaec., 101: 125–131

Wright, E. M. and Royston, P. (1997). A comparison of statistical methods for age-related referenceintervals.J.R.Statist.Soc. A., 160: 47–69.

Examples

data(abdom)attach(abdom)plot(x,y)detach(abdom)

additive.fit Implementing Backfitting in GAMLSS

Description

This function is not to be used on its own. It is used for backfitting in the GAMLSS fitting al-gorithms and it is based on the equivalent function written by Trevor Hastie in the gam() S-plusimplementation, (Chambers and Hastie, 1991).

Usage

additive.fit(x, y, w, s, who, smooth.frame, maxit = 30, tol = 0.001,trace = FALSE, se = TRUE, ...)

Arguments

x the linear part of the explanatory variables

y the response variable

w the weights

s the matrix containing the smoothers

who the current smoothers

smooth.frame the data frame used for the smoothers

maxit maximum number of iterations in the backfitting

tol the tolerance level for the backfitting

trace whether to trace the backfitting algorithm

se whether standard errors are required

... for extra arguments

Details

This function should not be used on its own

Page 5: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

aep 5

Value

Returns a list with the linear fit plus the smothers

Note

Author(s)

Mikis Stasinopoulos

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss

aep The Hospital Stay Data

Description

The data, 1383 observations, are from a study at the Hospital del Mar, Barcelona during the years1988 and 1990, Gangeet al. (1996).

Usage

data(aep)

Format

A data frame with 1383 observations on the following 8 variables.

los the total number of days patients spent in hospital: a discrete vector

noinap the number of inappropriate days spent in hospital: a discrete vector

loglos the log(los/10): a numeric vector

sex the gender of patient: a factor with levels1=male,2=female

ward the type of ward in the hospital: a factor with levels1=medical2=surgical,3=others

year the specific year 1988 or 1990: a factor with levels88 and90

age the age of the patient subtracted from 55: a numeric vector

y the response variable a matrix with 2 columns, the first is noinap the second is equal to (los-noinap)

Page 6: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

6 aids

Details

Gangeet al. (1996) used a logistic regression model for the number of inappropriate days (noinap)out of the total number of days spent in hospital (los), with binomial and beta binomial errors andfound that the later provided a better fit to the data. They modelled both the mean and the dispersionof the beta binomial distribution (BB) as functions of explanatory variables

Source

References

Gange, S. J. Munoz, A. Saez, M. and Alonso, J. (1996) Use of the beta-binomial distribution tomodel the effect of policy changes on appropriateness of hospital stays.Appl. Statist, 45, 371–382

Examples

data(aep)attach(aep)pro<-noinap/losplot(ward,pro)rm(pro)detach(aep)

aids Aids Cases in England and Wales

Description

The quarterly reported AIDS cases in the U.K. from January 1983 to March 1994 obtained from thePublic Health Laboratory Service, Communicable Disease Surveillance Centre, London.

Usage

data(aids)

Format

A data frame with 45 observations on the following 3 variables.

y the number of quarterly aids cases in England and Wales: a numeric vector

x time in months from January 1983, 1:45 : a numeric vector

qrt the quarterly seasonal effect a factor with 4 levels, [1=Q1 (Jan-March), 2=Q2 (Apr-June), 3=Q3(July-Sept), 4=Q4 (Oct-Dec)]

Details

The counts y can be modelled using a (smooth) Poisson regression model in time x with the quar-terly effects i.e. cs(x,df=7)+qrt. Overdispersion persists, so use a Negative Binomial distribution oftype I or II. The data also can be used to find a break point in time, see Rigby and Stasinopoulos(1992).

Page 7: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BB 7

Source

Public Health Laboratory Service, Communicable Disease Surveillance Centre, London.

References

Stasinopoulos, D.M. and Rigby, R. A. (1992). Detecting break points in generalized linear models.Computational Statistics and Data Analysis, 13, 461–471.

Examples

data(aids)attach(aids)plot(x,y,pch=21,bg=c("red","green3","blue","yellow")[unclass(qrt)])detach(aids)

BB Beta Binomial Distribution For Fitting a GAMLSS Model

Description

This function defines the beta binomial distribution, a two parameter distribution, for agamlss.familyobject to be used in a GAMLSS fitting using the function gamlss()

Usage

BB(mu.link = "logit", sigma.link = "log")dBB(y, mu = 0.5, sigma = 1, bd = 10, log = FALSE)pBB(q, mu = 0.5, sigma = 1, bd = 10, lower.tail = TRUE,

log.p = FALSE)qBB(p, mu = 0.5, sigma = 1, bd = 10, lower.tail = TRUE,

log.p = FALSE, fast = FALSE)rBB(n, mu = 0.5, sigma = 1, bd = 10, fast = FALSE)

Arguments

mu.link Defines themu.link , with "logit" link as the default for the mu parameter.Other links are "probit" and "cloglog"’(complementary log-log)

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter. Other links are "inverse", "identity" and "sqrt"

mu vector of positive probabilities

sigma the dispersion parameter

bd vector of binomial denominators

p vector of probabilities

y,q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Page 8: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

8 BB

fast a logical variable iffast=TRUE thedBB function is used in the calculation ofthe inverse c.d.f function. This is faster to the defaultfast=FALSE , where thepBB is used, but not always consistent with the results obtained frompBB() ,for example if p <- pBB(c(0,1,2,3,4,5), mu=.5 , sigma=1, bd=5) do not ensurethat qBB(p, mu=.5 , sigma=1, bd=5) will be c(0,1,2,3,4,5)

Details

Definition file for beta binomial distribution.

f(y|µ, σ) =Γ(n + 1)

Γ(y + 1)Γ(n− y + 1)Γ( 1

σ )Γ(y + µσ )Γ[n + (1−µ)

σ − y]Γ(n + 1

σ )Γ(µσ )Γ( 1−µ

σ )

for y = 0, 1, 2, . . . , n, 0 < µ < 1 andσ > 0. Forµ = 0.5 andσ = 0.5 the distribution is uniform.

Value

Returns agamlss.family object which can be used to fit a Beta Binomial distribution in thegamlss() function.

Warning

The functionspBB andqBB are calculated using a laborious procedure so they are relatively slow.

Note

The response variable should be a matrix containing two columns, the first with the count of suc-cesses and the second with the count of failures. The parametermurepresents a probability param-eter with limits0 < µ < 1. nµ is the mean of the distribution where n is the binomial denominator.nµ(1− µ)[1 + (n− 1)σ/(σ + 1)]0.5 is the standard deviation of the Beta Binomial distribution.Henceσ is a dispersion type parameter

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Kalliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Page 9: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BCCG 9

Examples

BB()# gives information about the default links for the Beta Binomial distribution#plot the pdfplot(function(y) dBB(y, mu = .5, sigma = 1, bd =40), from=0, to=40, n=40+1, type="h")#calculate the cdf and plotting itppBB <- pBB(seq(from=0, to=40), mu=.2 , sigma=3, bd=40)plot(0:40,ppBB, type="h")#calculating quantiles and plotting themqqBB <- qBB(ppBB, mu=.2 , sigma=3, bd=40)plot(qqBB~ ppBB)# when the argument fast is usefulp <- pBB(c(0,1,2,3,4,5), mu=.01 , sigma=1, bd=5)qBB(p, mu=.01 , sigma=1, bd=5, fast=TRUE)# 0 1 1 2 3 5qBB(p, mu=.01 , sigma=1, bd=5, fast=FALSE)# 0 1 2 3 4 5# generate random sampletN <- table(Ni <- rBB(1000, mu=.2, sigma=1, bd=20))r <- barplot(tN, col='lightblue')# fitting a modeldata(aep)library(gamlss)# fits a Beta-Binomial modelh<-gamlss(y~ward+loglos+year, sigma.formula=~year+ward, family=BB, data=aep)rm(h, r, tN, ppBB, qqBB)

BCCG Box-Cox Cole and Green distribution (or Box-Cox normal) for fittinga GAMLSS

Description

The functionBCCGdefines the Box-Cox Cole and Green distribution (Box-Cox normal), a threeparameter distribution, for agamlss.family object to be used in GAMLSS fitting using thefunctiongamlss() . The functionsdBCCG, pBCCG, qBCCGandrBCCGdefine the density, dis-tribution function, quantile function and random generation for the specific parameterization of theBox-Cox Cole and Green distribution. [The functionBCCGuntr() is the original version of thefunction suitable only for the untruncated Box-Cox Cole and Green distribution See Cole and Green(1992) and Rigby and Stasinopoulos (2003a,2003b) for details.

Usage

BCCG(mu.link = "identity", sigma.link = "log", nu.link = "identity")BCCGuntr(mu.link = "identity", sigma.link = "log", nu.link = "identity")dBCCG(y, mu = 1, sigma = 0.1, nu = 1, log = FALSE)pBCCG(q, mu = 1, sigma = 0.1, nu = 1, lower.tail = TRUE, log.p = FALSE)qBCCG(p, mu = 1, sigma = 0.1, nu = 1, lower.tail = TRUE, log.p = FALSE)rBCCG(n, mu = 1, sigma = 0.1, nu = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter,other links are "1/mu2" and "log"

Page 10: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

10 BCCG

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other links are "inverse" and "identity"

nu.link Defines thenu.link , with "identity" link as the default for the nu parameter,other links are "1/nu2" and "log"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of skewness parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The probability distribution function of the untrucated Box-Cox Cole and Green distribution,BCCGuntr ,is defined as

f(y|µ, σ, ν) =1√2πσ

yν−1

µνexp(−z2

2)

where ifν 6= 0 thenz = [(y/µ)ν − 1]/(νσ) elsez = log(y/µ)/σ, for y > 0, µ > 0, σ > 0 andν = (−∞,+∞).

The Box-Cox Cole anf Green distribution,BCCG, adjusts the above densityf(y|µ, σ, ν) for thetruncation resulting from the conditiony > 0. See Rigby and Stasinopoulos (2003a,2003b) fordetails.

Value

BCCG() returns agamlss.family object which can be used to fit a Cole and Green distributionin thegamlss() function.dBCCG() gives the density,pBCCG() gives the distribution function,qBCCG() gives the quantile function, andrBCCG() generates random deviates.

Warning

TheBCCGuntr distribution may be unsuitable for some combinations of the parameters (mainlyfor largeσ) where the integrating constant is less than 0.99. A warning will be given if this is thecase. The BCCG distribution is suitable for all combinations of the distributional parameters withintheir range [i.e.µ > 0, σ > 0, ν = (−∞,+∞)]

Note

µ is the median of the distributionσ is approximately the coefficient of variation (for small valuesof σ), andν controls the skewness.

The BCCGdistribution is suitable for all combinations of the parameters within their ranges [i.e.µ > 0, σ > 0, andν = (−∞,∞) ]

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Kalliope Akantziliotou

Page 11: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BCPE 11

References

Cole, T. J. and Green, P. J. (1992) Smoothing reference centile curves: the LMS method and penal-ized likelihood,Statist. Med.11, 1305–1319

Rigby, R. A. and Stasinopoulos, D. M. (2004). Smooth centile curves for skew and kurtotic datamodelled using the Box-Cox Power Exponential distribution.Statistics in Medicine, 23: 3053-3076.

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

Rigby, R.A. Stasinopoulos, D.M. (2006). Using the Box-Coxt distribution in GAMLSS to modeskewnees and and kurtosis. to appear inStatistical Modelling.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

BCCG() # gives information about the default links for the Cole and Green distributiondata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCCG, data=abdom)plot(h)plot(function(x) dBCCG(x, mu=5,sigma=.5,nu=-1), 0.0, 20,

main = "The BCCG density mu=5,sigma=.5,nu=-1")plot(function(x) pBCCG(x, mu=5,sigma=.5,nu=-1), 0.0, 20,

main = "The BCCG cdf mu=5, sigma=.5, nu=-1")rm(h)

BCPE Box-Cox Power Exponential distribution for fitting a GAMLSS

Description

This function defines the Box-Cox Power Exponential distribution, a four parameter distribution, fora gamlss.family object to be used for a GAMLSS fitting using the functiongamlss() . ThefunctionsdBCPE, pBCPE, qBCPEand rBCPE define the density, distribution function, quantilefunction and random generation for the Box-Cox Power Exponential distribution. The functioncheckBCPE can be used, typically when a BCPE model is fitted, to check whether there exit aturning point of the distribution close to zero. It give the number of values of the response belowtheir minimum turning point and also the maximum probability of the lower tail below minimumturning point. [The functionBiventer() is the original version of the function suitable only forthe untruncated BCPE distribution.] See Rigby and Stasinopoulos (2003) for details.

Usage

BCPE(mu.link = "identity", sigma.link = "log", nu.link = "identity",tau.link = "log")

BCPEuntr(mu.link = "identity", sigma.link = "log", nu.link = "identity",tau.link = "log")

Page 12: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

12 BCPE

dBCPE(y, mu = 5, sigma = 0.1, nu = 1, tau = 2, log = FALSE)pBCPE(q, mu = 5, sigma = 0.1, nu = 1, tau = 2, lower.tail = TRUE, log.p = FALSE)qBCPE(p, mu = 5, sigma = 0.1, nu = 1, tau = 2, lower.tail = TRUE, log.p = FALSE)rBCPE(n, mu = 5, sigma = 0.1, nu = 1, tau = 2)checkBCPE(obj = NULL, mu = 10, sigma = 0.1, nu = 0.5, tau = 2,...)

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

nu.link Defines thenu.link , with "identity" link as the default for thenu parameter.Other links are "1/nu2" and "log"

tau.link Defines thetau.link , with "log" link as the default for thetau parameter.Other links are "1/tau2", and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector ofnu parameter values

tau vector oftau parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

obj a gamlss BCPE family object

... for extra arguments

Details

The probability density function of the untrucated Box Cox Power Exponential distribution, (BCPE.untr ),is defined as

f(y|µ, σ, ν, τ) =yν−1τ exp[− 1

2 |zc |

τ ]µνσc2(1+1/τ)Γ( 1

τ )

wherec = [2(−2/τ)Γ(1/τ)/Γ(3/τ)]0.5, where if ν 6= 0 thenz = [(y/µ)ν − 1]/(νσ) elsez =log(y/µ)/σ, for y > 0, µ > 0, σ > 0, ν = (−∞,+∞) andτ > 0.

The Box-Cox Power Exponential,BCPE, adjusts the above densityf(y|µ, σ, ν, τ) for the truncationresulting from the conditiony > 0. See Rigby and Stasinopoulos (2003) for details.

Value

BCPE() returns agamlss.family object which can be used to fit a Box Cox Power Exponentialdistribution in thegamlss() function.dBCPE() gives the density,pBCPE() gives the distribu-tion function,qBCPE() gives the quantile function, andrBCPE() generates random deviates.

Page 13: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BCT 13

Warning

TheBCPE.untr distribution may be unsuitable for some combinations of the parameters (mainlyfor largeσ) where the integrating constant is less than 0.99. A warning will be given if this is thecase.

The BCPEdistribution is suitable for all combinations of the parameters within their ranges [i.e.µ > 0, σ > 0, ν = (−∞,∞)andτ > 0 ]

Note

µ, is the median of the distribution,σ is approximately the coefficient of variation (for smallσ andmoderatenu>0 ), ν controls the skewness andτ the kurtosis of the distribution

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Rigby, R. A. and Stasinopoulos, D. M. (2004). Smooth centile curves for skew and kurtotic datamodelled using the Box-Cox Power Exponential distribution.Statistics in Medicine, 23: 3053-3076.

Stasinopoulos D. M. Rigby R. A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , BCT

Examples

BCPE() #data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCPE, data=abdom)plot(h)rm(h)plot(function(x)dBCPE(x, mu=5,sigma=.5,nu=1, tau=3), 0.0, 15,

main = "The BCPE density mu=5,sigma=.5,nu=1, tau=3")plot(function(x) pBCPE(x, mu=5,sigma=.5,nu=1, tau=3), 0.0, 15,

main = "The BCPE cdf mu=5, sigma=.5, nu=1, tau=3")

BCT Box-Cox t distribution for fitting a GAMLSS

Description

The functionBCT() defines the Box-Cox t distribution, a four parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The functionsdBCT, pBCT,qBCTandrBCT define the density, distribution function, quantile function and random generationfor the Box-Cox t distribution. [The functionBCTuntr() is the original version of the functionsuitable only for the untruncated BCT distribution]. See Rigby and Stasinopoulos (2003) for details.

Page 14: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

14 BCT

Usage

BCT(mu.link = "identity", sigma.link = "log", nu.link = "identity",tau.link = "log")

BCTuntr(mu.link = "identity", sigma.link = "log", nu.link = "identity",tau.link = "log")

dBCT(y, mu = 5, sigma = 0.1, nu = 1, tau = 2, log = FALSE)pBCT(q, mu = 5, sigma = 0.1, nu = 1, tau = 2, lower.tail = TRUE, log.p = FALSE)qBCT(p, mu = 5, sigma = 0.1, nu = 1, tau = 2, lower.tail = TRUE, log.p = FALSE)rBCT(n, mu = 5, sigma = 0.1, nu = 1, tau = 2)

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

nu.link Defines thenu.link , with "identity" link as the default for thenu parameter.Other links are "1/nu2" and "log"

tau.link Defines thetau.link , with "log" link as the default for thetau parameter.Other links are "1/tau2", and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector ofnu parameter values

tau vector oftau parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The probability density function of the untruncated Box-Cox t distribution,BCTuntr , is given by

f(y|µ, σ, ν, τ) =yν−1

µνσ

Γ[(τ + 1)/2]Γ(1/2)Γ(τ/2)τ0.5

[1 + (1/τ)z2]−(τ+1)/2

where if ν 6= 0 thenz = [(y/µ)ν − 1]/(νσ) elsez = log(y/µ)/σ, for y > 0, µ > 0, σ > 0,ν = (−∞,+∞) andτ > 0.

The Box-Coxt distribution,BCT, adjusts the above densityf(y|µ, σ, ν, τ) for the truncation result-ing from the conditiony > 0. See Rigby and Stasinopoulos (2003) for details.

Value

BCT() returns agamlss.family object which can be used to fit a Box Cox-t distribution in thegamlss() function.dBCT() gives the density,pBCT() gives the distribution function,qBCT()gives the quantile function, andrBCT() generates random deviates.

Page 15: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

db 15

Warning

The useBCTuntr distribution may be unsuitable for some combinations of the parameters (mainlyfor largeσ) where the integrating constant is less than 0.99. A warning will be given if this is thecase.

The BCT distribution is suitable for all combinations of the parameters within their ranges [i.e.µ > 0, σ > 0, ν = (−∞,∞)andτ > 0 ]

Note

µ is the median of the distribution,σ( ττ−2 )0.5 is approximate the coefficient of variation (for small

σ and moderatenu>0 and moderate or largeτ ), ν controls the skewness andτ the kurtosis of thedistribution

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Rigby, R.A. Stasinopoulos, D.M. (2006). Using the Box-Coxt distribution in GAMLSS to modeskewnees and and kurtosis. to appear inStatistical Modelling.

Stasinopoulos, D. M. Rigby, R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

BCT() # gives information about the default links for the Box Cox t distributiondata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom) #plot(h)plot(function(x)dBCT(x, mu=5,sigma=.5,nu=1, tau=2), 0.0, 20,

main = "The BCT density mu=5,sigma=.5,nu=1, tau=2")plot(function(x) pBCT(x, mu=5,sigma=.5,nu=1, tau=2), 0.0, 20,

main = "The BCT cdf mu=5, sigma=.5, nu=1, tau=2")rm(h)

db Head Circumference of Dutch Boys

Description

The data are comming from the Fourth Dutch Growth Study, Fredriks et al. (2000a, 2000b), whichis a cross-sectional study that measures growth and development of the Dutch population betweenthe ages 0 and 21 years. The study measured, among other variables, height, weight, head circum-ference and age for 7482 males and 7018 females. Here we have the only the head circumferenceof Dutch boys.

Page 16: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

16 BEINF

Usage

data(db)

Format

A data frame with 7040 observations on the following 2 variables.

head head circumference

age age in years

Details

Source

The data were kindly given by professor Stef. van Buuren.

References

Fredriks, A.M. van Buuren, S. Burgmeijer, R.J.F. Meulmeester, J.F. Beuker, R.J. Brugman, E.Roede, M.J. Verloove-Vanhorick, S.P. and Wit, J. M. (2000a), Continuing positive secular changein The Netherlands, 1955-1997,Pediatric Research, 47, 316–323

Fredriks, A.M. van Buuren, S. Wit, J.M. and Verloove-Vanhorick, S. P. (2000b) Body index mea-surments in 1996-7 compared with 1980,Archives of Childhood Diseases, 82, 107–112

van Buuren and Fredriks M. (2001) Worm plot: simple diagnostic device for modelling growthreference curves.Statistics in Medicine, 20, 1259–1277

Examples

data(db)attach(db)plot(age,head)detach(db)

BEINF The beta inflated distribution for fitting a GAMLSS

Description

The functionBEINF() defines the beta inflated distribution, a four parameter distribution, fora gamlss.family object to be used in GAMLSS fitting using the functiongamlss() . Thebeta inflated is similar to the beta but allows zeros and one as y values. The two extra parametersmodel the probabilities at zero and one. The functionsdBEINF , pBEINF , qBEINF andrBEInFdefine the density, distribution function, quantile function and random generation for theBEINFparameterization of the beta inflated distribution.plotBEINF can be used to plot the distribution.meanBEINF calculates the expected value of the response for a fitted model.

Page 17: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BEINF 17

Usage

BEINF(mu.link = "logit", sigma.link = "logit", nu.link = "log",tau.link = "log")

dBEINF(y, mu = 0.5, sigma = 0.1, nu = 0.1, tau = 0.1,log = FALSE)

pBEINF(q, mu = 0.5, sigma = 0.1, nu = 0.1, tau = 0.1,lower.tail = TRUE, log.p = FALSE)

qBEINF(p, mu = 0.5, sigma = 0.1, nu = 0.1, tau = 0.1,lower.tail = TRUE, log.p = FALSE)

rBEINF(n, mu = 0.5, sigma = 0.1, nu = 0.1, tau = 0.1)plotBEINF(mu = 0.5, sigma = 0.5, nu = 0.5, tau = 0.5,

from = 0, to = 1, n = 101, ...)meanBEINF(obj)

Arguments

mu.link themulink function with defaultlogit

sigma.link thesigma link function with defaultlogit

nu.link thenu link function with defaultlog

tau.link thetau link function with defaultlog

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of parameter values modelling the probability at zero

tau vector of parameter values modelling the probability at one

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

from where to start plotting the distribution from

to up to where to plot the distribution

obj a fittedBEINF object

... other graphical parameters for plotting

Details

The beta inflated distribution is given as

f(y) = p0

if (y=0)f(y) = p1

if (y=1)

f(y|α, β) =1

B(α, β)yα−1(1− y)β−1

otherwise

for y = (0, 1), α > 0 andβ > 0. The parametrization in the functionBEINF() is µ = αα+β and

σ = 1α+β+1 for µ = (0, 1) andσ = (0, 1) andν = p0

p2, τ = p1

p2wherep2 = f(y).

Page 18: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

18 BE

Value

returns agamlss.family object which can be used to fit a beta inflated distribution in thegamlss() function. ...

Note

Author(s)

Bob Rigby and Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , BE

Examples

BEINF()# gives information about the default links for the normal distribution# plotting the distributionplotBEINF( mu =.5 , sigma=.5, nu = 0.5, tau = 0.5, from = 0, to=1, n = 101)# plotting the cdfplot(function(y) pBEINF(y, mu=.5 ,sigma=.5, nu = 0.5, tau = 0.5,), 0, 1)# plotting the inverse cdfplot(function(y) qBEINF(y, mu=.5 ,sigma=.5, nu = 0.5, tau = 0.5,), 0.01, .99)# generate random numbersdat <- rBEINF(1000,mu=.5,sigma=.5, nu=.5, tau=.5)# fit a model to the datam1<-gamlss(dat~1,family=BEINF)meanBEINF(m1)[1]

BE The beta distribution for fitting a GAMLSS

Description

The functionBE() defines the beta distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() , with mean equal to the param-etermuandsigma a scale parameter, see below. The functionsdBE, pBE, qBEandrBE define thedensity, distribution function, quantile function and random generation for theBEparameterizationof the beta distribution.

Page 19: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BE 19

Usage

BE(mu.link = "logit", sigma.link = "logit")dBE(y, mu = 0.5, sigma = 0.02, log = FALSE)pBE(q, mu = 0.5, sigma = 0.02, lower.tail = TRUE, log.p = FALSE)qBE(p, mu = 0.5, sigma = 0.02, lower.tail = TRUE, log.p = FALSE)rBE(n, mu = 0.5, sigma = 0.02)

Arguments

mu.link themulink function with defaultlogit

sigma.link thesigma link function with defaultlogit

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The beta distribution is given as

f(y|α, β) =1

B(α, β)yα−1(1− y)β−1

for y = (0, 1), α > 0 andβ > 0. The parametrization in the functionBE() is µ = αα+β and

σ = 1α+β+1 for µ = (0, 1) andσ = (0, 1). The expected value of y isµ and the variance is

σ2µ ∗ (1− µ).

Value

returns agamlss.family object which can be used to fit a normal distribution in thegamlss()function.

Note

Note thatmuis the mean andsigma a scale parameter contributing to the variance of y

Author(s)

Bob Rigby and Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 20: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

20 bfp

See Also

gamlss , gamlss.family , BEINF

Examples

BE()# gives information about the default links for the normal distributiondat<-rBE(100, mu=.3, sigma=.5)hist(dat)mod1<-gamlss(dat~1,family=BE) # fits a constant for mu and sigmafitted(mod1)[1]fitted(mod1,"sigma")[1]plot(function(y) dBE(y, mu=.1 ,sigma=.5), 0.001, .999)plot(function(y) pBE(y, mu=.1 ,sigma=.5), 0.001, 0.999)plot(function(y) qBE(y, mu=.1 ,sigma=.5), 0.001, 0.999)plot(function(y) qBE(y, mu=.1 ,sigma=.5, lower.tail=FALSE), 0.001, .999)

bfp Functions to fit fractional polynomials in GAMLSS

Description

The functionbfp generate a power polynomial basis matrix which (for given powers) can be usedto fit power polynomials in one x-variable. The functionfp takes a vector and returns it withseveral attributes. The vector is used in the construction of the model matrix. The functionfp()is not used for fitting the fractional polynomial curves but assigns the attributes to the vector to aidgamlss in the fitting process. The function doing the fitting isgamlss.fp () which is used at thebackfitting functionadditive.fit (but never used on its own). The (experimental) functionppcan be use to fit power polynomials as ina+ b1x

p1 + b2xp2 ., where p1 and p2 have arbitrary values

rather restricted as in thefp function.

Usage

bfp(x, powers = c(1, 2), shift = NULL, scale = NULL)fp(x, npoly = 2, shift = NULL, scale = NULL)pp(x, start = list(), shift = NULL, scale = NULL)

Arguments

x the explanatory variable to be used in functionsbfp() or fp() . Note that thisis different from the argumentx use ingamlss.fp (a function used in thebackfitting but not by straight by the user)

powers a vector containing as elements the powers in which the x has to be raised

shift a number for shifting the x-variable. The default values is zero, if x is positive,or the minimum of the positive difference in x minus the minimum of x

scale a positive number for scalling the x-variable. The default values is10(sign(log10(range)))∗trunc(abs(log10(range)))

npoly a positive indicating how many fractional polynomials should be considered inthe fit. Can take the values 1, 2 or 3 with 2 as default

start a list containing the starting values for the non-linear maximization to find thepowers. The results from fitting the equivalent fractional polynomials can beused here

Page 21: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

bfp 21

Details

The above functions are an implementation of the fractional polynomials introduced by Roystonand Altman (1994). The three functions involved in the fitting are loosely based on the fractionalpolynomials implementation in S-plus written by Gareth Amber. The functionbfp generates theright design matrix for the fitting a power polynomial of the typea+b1x

p1 +b2xp2 +. . .+bkxp

k. Forgiven powersp1, p2, . . . , pk given as the argumentpowers in bfp() the function can be used to fitpower polynomials in the same way as the functionspoly() or bs() (of packagesplines ) areused to fit orthogonal or piecewise polynomials respectively. The functionfp() , which is workingas a smoother ingamlss , is used to fit the best fractional polynomials within a set of power values.Its argumentnpoly determines whether one, two or three fractional polynomials should used in thefitting. For a fixed numbernpoly the algorithm looks for the best fitting fractional polynomials inthe listc(-2, -1, -0.5, 0, 0.5, 1, 2, 3) . Note thatnpolu=3 is rather slow sinceit fits all possible combinations 3-way combinations at each backfitting interaction. The functiongamlss.fp() is an internal function of GAMLSS allowing the fractional polynomials to be fittedin the backfitting cycle ofgamlss , and should be not used on its own.

Value

The functionbfp returns a matrix to be used as part of the design matrix in the fitting.

The functionfp returns a vector with values zero to be included in the design matrix but withattributes useful in the fitting of the fractional polynomials algorithm ingamlss.fp .

Warning

Since the model constant is included in both the design matrix X and in the backfitting part offractional polynomials, its values is wrongly given in thesummary . Its true values is the modelconstant minus the constant from the fractional polynomial fitting ??? What happens if more thatone fractional polynomials are fitted?

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

Amber G. (1999) Fracial polynomials in S-plus,http://lib.stat.cmu.edu/S/fracpoly .

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

Royston, P. and Altman, D. G., (1994). Regression using fractional polynomials of continuouscovariates: parsimonious parametric modelling (with discussion),Appl. Statist., 43, 429-467.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Page 22: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

22 BI

Examples

data(abdom)#fits polynomials with power 1 and .5mod1<-gamlss(y~bfp(x,c(1,0.5)),data=abdom)# fit the best of one fractional polynomialm1<-gamlss(y~fp(x,1),data=abdom)# fit the best of two fractional polynomialsm2<-gamlss(y~fp(x,2),data=abdom)# fit the best of three fractional polynomialsm3<-gamlss(y~fp(x,3),data=abdom)# get the coefficient for the second modelm2$mu.coefSmo# now power polynomials using the best 2 fp c()

m4 <- gamlss(y ~ pp(x, c(1,3)), data = abdom)# This is not good idea in this case because# if you look at the fitted values you see what it went wrongplot(y~x,data=abdom)lines(fitted(m2,"mu")~abdom$x,col="red")lines(fitted(m4,"mu")~abdom$x,col="blue")

BI Binomial distribution for fitting a GAMLSS

Description

The BI() function defines the binomial distribution, a one parameter family distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . The func-tionsdBI , pBI , qBI andrBI define the density, distribution function, quantile function and ran-dom generation for the binomial,BI() , distribution.

Usage

BI(mu.link = "logit")dBI(y, bd = 1, mu = 0.5, log = FALSE)pBI(q, bd = 1, mu = 0.5, lower.tail = TRUE, log.p = FALSE)qBI(p, bd = 1, mu = 0.5, lower.tail = TRUE, log.p = FALSE)rBI(n, bd = 1, mu = 0.5)

Arguments

mu.link Defines themu.link , with "logit" link as the default for themu parameter.Other links are "probit" and "cloglog"’(complementary log-log)

y vector of (non-negative integer) quantiles

mu vector of positive probabilities

bd vector of binomial denominators

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Page 23: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

BI 23

Details

Definition file for binomial distribution.

f(y|µ) =Γ(n + 1)

Γ(y + 1)Γ(n− y + 1)µy(1− µ)(n−y)

for y = 0, 1, 2, ..., n and0 < µ < 1.

Value

returns agamlss.family object which can be used to fit a binomial distribution in thegamlss()function.

Note

The response variable should be a matrix containing two columns, the first with the count of suc-cesses and the second with the count of failures. The parametermurepresents a probability param-eter with limits0 < µ < 1. nµ is the mean of the distribution where n is the binomial denominator.

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

BI()# gives information about the default links for the Binomial distributiondata(aep)library(gamlss)h<-gamlss(y~ward+loglos+year, family=BI, data=aep)# plot of the binomial distributioncurve(dBI(y=x, mu = .5, bd=10), from=0, to=10, n=10+1, type="h")tN <- table(Ni <- rBI(1000, mu=.2, bd=10))r <- barplot(tN, col='lightblue')rm(h,tN,r)

Page 24: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

24 centiles.com

centiles.com Comparing centiles from different GAMLSS models

Description

This function compares centiles curves for more than one GAMLSS objects. It is based on thecentiles function. The function also tabulates the sample percentages below each centile curve(for comparison with the model percentages given by the argumentcent .) A restriction of thefunction is that it applies to models with one explanatory variable only.

Usage

centiles.com(obj, ..., xvar = NULL, cent = c(0.4, 10, 50, 90, 99.6),legend = TRUE, ylab = "y", xlab = "x", xleg = min(xvar),yleg = max(obj$y), xlim = range(xvar), ylim = NULL,no.data = FALSE, color = TRUE, plot = TRUE)

Arguments

obj a fitted gamlss object from fitting a gamlss continuous distribution

... optionally more fitted GAMLSS model objects

xvar the unique explanatory variable

cent a vector with elements the % centile values for which the centile curves have tobe evaluated

legend whether a legend is required in the plot or not, the default islegent=TRUE

ylab the y-variable label

xlab the x-variable label

xleg position of the legend in the x-axis

yleg position of the legend in the y-axis

xlim the limits of the x-axis

ylim the limits of the y-axis

no.data whether the data should plotted, defaultno.data=FALSE or notno.data=TRUE

color whether the fitted centiles are shown in colour,color=TRUE (the default) ornotcolor=FALSE

plot whether to plot the centiles

Details

Value

Centile plots are produced for the different fitted models and the sample centiles below each centilecurve are printed

Warning

This function is appropriate only when one continuous explanatory variable is fitted in the model

Page 25: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

centiles.pred 25

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , centiles , centiles.split

Examples

data(abdom)h1<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom)h2<-gamlss(y~lo(x,span=0.4), sigma.formula=~lo(x,span=0.4), family=BCT, data=abdom )centiles.com(h1,h2,xvar=abdom$x)rm(h1,h2)

centiles.pred Creating predictive centiles values

Description

This function creates predictive centiles curves for new x-values given a GAMLSS fitted model.The function has three options: i) for given new x-values and given percentage centiles calculatesa matrix containing the centiles values for y, ii) for given new x-values and standard normalizedcentile values calculates a matrix containing the centiles values for y, iii) for given new x-valuesand new y-values calculates the z-scores. A restriction of the function is that it applies to modelswith only one explanatory variable.

Usage

centiles.pred(obj, type = c("centiles", "z-scores", "standard-centiles"),xname = NULL, xvalues = NULL, power = NULL, yval = NULL,cent = c(0.4, 2, 10, 25, 50, 75, 90, 98, 99.6),dev = c(-4, -3, -2, -1, 0, 1, 2, 3, 4),plot = FALSE, legend = TRUE,...)

Page 26: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

26 centiles.pred

Arguments

obj a fitted gamlss object from fitting a gamlss continuous distribution

type the default, "centiles", gets the centiles values given in the optioncent . type="standard-centiles" gets the standard centiles given in thedev . type="z-scores"gets the z-scores for given y and x new values

xname the name of the unique explanatory variable (it has to be the same as in theoriginal fitted model)

xvalues the new values for the explanatory variable where the prediction will take place

power if power transformation is needed (but read the note below)

yval the response values for a given x required for the calculation of "z-scores"

cent a vector with elements the % centile values for which the centile curves have tobe evaluated

dev a vector with elements the standard normalized values for which the centilecurves have to be evaluated in the optiontype="standard-centiles"

plot whether to plot the "centiles" or the "standard-centiles", the default isplot=FALSE

legend whether a legend is required in the plot or not, the default islegent=TRUE

... for extra arguments

Details

Value

a vector (for optiontype="z-scores" ) or a matrix for optionstype="centiles" or type="standard-centiles" containing the appropriate values

Warning

See example below of how to use the function when power transofrmation is used for the x-variables

Note

The power option should be only used if the model

Author(s)

Mikis Stasinopoulos ,〈[email protected]〉, based on ideas of Elaine Borghie fromthe World Health Organization

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , centiles , centiles.split

Page 27: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

centiles 27

Examples

data(abdom)a<-gamlss(y~cs(x),sigma.fo=~cs(x), data=abdom, family=BCT)#plot the centilescentiles(a,xvar=abdom$x)# calculate the centiles at new x valuesnewx<-seq(12,40,2)mat <- centiles.pred(a, xname="x", xvalues=newx )mat# plot the centiles

mat <- centiles.pred(a, xname="x",xvalues=newx, plot=TRUE )# calculate standard-centiles for new values using the fitted modelnewx <- seq(12,40,2)

mat <- centiles.pred(a, xname="x",xvalues=newx, type="standard-centiles" )mat

#to plot the centilesmat <- centiles.pred(a, xname="x",xvalues=newx, type="s", plot = TRUE )# get z-scores for new values and plot themnewx <- c(20,21.2,23,20.9,24.2,24.1,25)newy <- c(130,121,123,125,140,145,150)znewx <- centiles.pred(a, xname="x",xvalues=newx,yval=newy, type="z-scores" )znewxfor(i in 1:7) points(newx[i],newy[i],col="blue")# now with transformed dataaa<-gamlss(y~cs(x^0.5),sigma.fo=~cs(x^0.5), data=abdom, family=BCT)centiles(aa,xvar=abdom$x)mat <- centiles.pred(aa, xname="x",xvalues=c(30) )xx<-rep(mat[,1],9)yy<-mat[,2:10]points(xx,yy,col="red")# now with transformed previously datanx<-abdom$x^0.5aa<-gamlss(y~cs(nx),sigma.fo=~cs(nx), data=abdom, family=BCT)centiles(aa, xvar=abdom$x)newd<-data.frame( abdom, nx=abdom$x^0.5)mat <- centiles.pred(aa, xname="nx", xvalues=c(30), power=0.5, data=newd)xxx<-rep(mat[,1],9)yyy<-mat[,2:10]points(xxx,yyy,col="red")

centiles Plots the centile curves for a GAMLSS object

Description

This function plots centiles curves for distributions belonging to the GAMLSS family of distribu-tions. The function also tabulates the sample percentages below each centile curve (for comparisonwith the model percentages given by the argumentcent .) A restriction of the function is that itapplies to models with one explanatory variable only.

Usage

centiles(obj, xvar = NULL, cent = c(0.4, 2, 10, 25, 50, 75, 90, 98, 99.6),legend = TRUE, ylab = "y", xlab = "x", xleg = min(xvar),

Page 28: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

28 centiles

yleg = max(obj$y), xlim = range(xvar), ylim = range(obj$y),save = FALSE, plot = TRUE, ...)

Arguments

obj a fitted gamlss object from fitting a gamlss distribution

xvar the unique explanatory variable

cent a vector with elements the % centile values for which the centile curves have tobe evaluated

legend whether a legend is required in the plot or not, the default islegent=TRUE

ylab the y-variable label

xlab the x-variable label

xleg position of the legend in the x-axis

yleg position of the legend in the y-axis

xlim the limits of the x-axis

ylim the limits of the y-axis

save whether to save the sample percentages or not with default equal toFALSE. Inthis case the sample percentages are printed but are not saved

plot whether to plot the centiles. This option is useful forcentile.split

... for extra arguments

Details

Value

A centile plot is produced and the sample centiles below each centile curve are printed (or saved)

Warning

This function is appropriate only when one continuous explanatory variable is fitted in the model

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 29: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

centiles.split 29

See Also

gamlss , centiles.split , centiles.com

Examples

data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom)centiles(h,xvar=abdom$x)rm(h)

centiles.split Plots centile curves split by x for a GAMLSS object

Description

This function plots centiles curves for separate ranges of the unique explanatory variable x. It issimilar to thecentiles function but the range of x is split at a user defined valuesxcut.pointinto r separate ranges. The functions also tabulates the sample percentages below each centile curvefor each of the r ranges of x (for comparison with the model percentage given by cent) The modelshould have only one explanatory variable.

Usage

centiles.split(obj, xvar = NULL, xcut.points = NULL, n.inter = 4,cent = c(0.4, 2, 10, 25, 50, 75, 90, 98, 99.6),legend = FALSE, ylab = "y", xlab = "x", ylim = NULL,overlap = 0, save = TRUE, plot = TRUE, ...)

Arguments

obj a fitted gamlss object from fitting a gamlss continuous distribution

xvar the unique explanatory variable

xcut.points the x-axis cut off points e.g.c(20,30) . If xcut.points=NULL then then.inter argument is activated

n.inter if xcut.points=NULL this argument gives the number of intervals in whichthe x-variable will be splited, with default 4

cent a vector with elements the % centile values for which the centile curves are tobe evaluated

legend whether a legend is required in the plots or not, the default islegent=FALSE

ylab the y-variable label

xlab the x-variable label

ylim the range of the y-variable axis

overlap how much overlapping in thexvar intervals. Default value isoverlap=0 fornon overlapping intervals

save whether to save the sample percentages or not with default equal toTRUE. Inthis case the functions produce a matrix giving the sample percentages for eachinterval

plot whether to plot the centles. This option is usefull if the sample statistics onlyare to be used

... for extra arguments

Page 30: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

30 checklink

Details

Value

Centile plots are produced and the sample centiles below each centile curve for each of the r rangesof x can be saved into a matrix.

Warning

This function is appropriate when only one continuous explanatory variable is fitted in the model

Note

Author(s)

Mikis Stasinopoulos,〈[email protected]〉, Bob Rigby〈[email protected]〉,with contributions from Elaine Borghie

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2003) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss centiles , centiles.com

Examples

data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom)mout <- centiles.split(h,xvar=abdom$x)moutrm(h,mout)

checklink Set the Right Link Function for Specified Parameter and Distribution

Description

This function is used within the distribution family specification of a GAMLSS model to define theright link for each of the parameters of the distribution. This function should not be called by theuser unless he/she specify a new distribution family or wishes to change existing link functions inthe parameters.

Page 31: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

checklink 31

Usage

checklink(which.link = NULL, which.dist = NULL, link = NULL, link.List = NULL,par.link = c(1))

Arguments

which.link which parameter link e.g.which.link="mu.link"

which.dist which distribution family e.g.which.dist="Cole.Green"

link a repetition ofwhich.link e.g. link=substitute(mu.link)

link.List what link function are required e.g.link.List=c("inverse", "log","identity")

par.link sets the values for the shifted parameter(s) forlogshifted and"logitshifted"i.e par.link=1 for logshifted orpar.link=c(0,2) for logitshifted

Details

Value

Defines the right link for each parameter

Author(s)

Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

Page 32: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

32 coef.gamlss

coef.gamlss Extract Model Coefficients in a GAMLSS fitted model

Description

coef.gamlss is the GAMLSS specific method for the generic functioncoef which extractsmodel coefficients from objects returned by modelling functions. ‘coefficients’ is an alias forcoef .

Usage

coef.gamlss(object, what = c("mu", "sigma", "nu", "tau"), ... )

Arguments

object a GAMLSS fitted model

what which parameter coefficient is required, defaultwhat="mu"

... for extra arguments

Details

Value

Coefficients extracted from the GAMLSS model object.

Note

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , deviance.gamlss , fitted.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #coef(h)rm(h)

Page 33: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

cs 33

cs Specify a Smoothing Spline Fit in a GAMLSS Formula

Description

Takes a vector and returns it with several attributes. The vector is used in the construction of themodel matrix. The functioncs() does no smoothing, but assigns the attributes to the vector to aidgamlss in the smoothing. The function doing the smoothing isgamlss.cs () (a modified versionof the R functionsmooth.spline() ) which is used at the backfitting functionadditive.fit. The (experimental) functionvc can be use to fit varying coefficient models Hastie and Tibshirani(1993).

Usage

cs(x, df = 3, spar = NULL, c.spar = NULL)vc(r, x, df = 3, spar = NULL, c.spar = NULL)

Arguments

x the univariate predictor, (or expression, that evaluates to a numeric vector). Forthe functionvc the x argument is the vector which has its (linear) coefficientchange withr

df the desired equivalent number of degrees of freedom (trace of the smoother ma-trix minus two for the constant and linear fit). The real smoothing parameter(spar below) is found such that df=tr(S)-2, where S is the implicit smoothermatrix. Values for df should be greater than 0, with 0 implying a linear fit.

spar smoothing parameter, typically (but not necessarily) in (0,1]. The coefficientlambda of the integral of the squared second derivative in the fit (penalizedlog likelihood) criterion is a monotone function of ‘spar’, see the details insmooth.spline .

c.spar This is an option to be used when the degrees of freedom of the fitted gamlssobject are different from the ones given as input in the optiondf . The de-fault values used are the ones given the optioncontrol.spar in the R func-tion smooth.spine() and they arec.spar=c(-1.5, 2) . For very largedata sets e.g. 10000 observations, the upper limit may have to increase for ex-ample toc.spar=c(-1.5, 2.5) . Use this option if you have received thewarning ’The output df are different from the input, change the control.spar’.c.spar can take both vectors or lists of length 2, for examplec.spar=c(-1.5, 2.5) or c.spar=list(-1.5, 2.5) would have the same effect.

r for the functionvc , r represent the vector of the explanatory variable whicheffects the coefficients ofx i.e. beta(r)*x. Both thex andr vectors should beadjusted by subtracting the their mean

Details

Note thatcs itself does no smoothing; it simply sets things up for the functiongamlss() whichin turn uses the functionadditive.fit() for backfitting which in turn usesgamlss.cs()

Page 34: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

34 cs

Value

the vector x is returned, endowed with a number of attributes. The vector itself is used in theconstruction of the model matrix, while the attributes are needed for the backfitting algorithmsadditive.fit() . Since smoothing splines includes linear fits, the linear part will be efficientlycomputed with the other parametric linear parts of the model.

Warning

For a user who wishes to compare thegamlss() results with the equivalentgam() resultsin S-plus: make sure when using S-plus that the convergence criteria epsilon and bf.epsilon incontrol.gam() are decreased sufficiently to ensure proper convergence in S-plus. Also notethat the degrees of freedom are defined on top of the linear term ingamlss , but on top of theconstant term in S-plus, (so use an extra degrees of freedom in S-plus in order to obtain comparableresults to those ingalmss ).

Change the upper limit of spar if you received the warning ’The output df are different from theinput, change the control.spar’.

For large data sets do not use expressions, e.g.cs(x^0.5) inside thegamlss function commandbut evaluate the expression, e.g. nx=x0.5, first and then usecs(nx) .

Note

The degrees of freedom df are defined differently from that of the gam() function in S-plus. Here dfare the additional degrees of freedom excluding the constant and the linear part of x. For exampledf=4 in gamlss() is equivalent todf=5 in gam() in S-plus

Author(s)

Mikis Stasinopoulos and Bob Rigby

References

Hastie, T. J. and Tibshirani, R. J. (1993), Varying coefficient models (with discussion),J. R. Statist.Soc. B.,55, 757-796.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.cs , lo

Examples

# cubic splines exampledata(aids)attach(aids)# fitting a smoothing cubic spline with 7 degrees of freedom# plus the a quarterly effectaids1<-gamlss(y~cs(x,df=7)+qrt,data=aids,family=PO) #plot(x,y)lines(x,fitted(aids1))

Page 35: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

deviance.gamlss 35

rm(aids1)detach(aids)# varying-coefficient exampledata(rent)attach(rent)# adjusting the variablesFlbar<-Fl-mean(Fl)Abar<-A-mean(A)# additive model

m1<-gamlss(R~cs(Flbar, df=3)+cs(Abar))# varying-coefficient model

m2<-gamlss(R~cs(Flbar, df=3)+cs(Abar)+vc(r=Abar,x=Flbar))AIC(m1,m2)detach(rent)

deviance.gamlss Global Deviance of a GAMLSS model

Description

Returns the global, -2*log(likelihood), or the penalized, -2*log(likelihood)+ penalties, deviance ofa fitted GAMLSS model object.

Usage

deviance.gamlss(object, what = c("G", "P"), ...)

Arguments

object a GAMLSS fitted model

what put "G" for Global or "P" for Penalized deviance

... for extra arguments

Details

deviance is a generic function which can be used to extract deviances for fitted models.deviance.gamlssis the method for a GAMLSS object.

Value

The value of the global or the penalized deviance extracted from a GAMLSS object.

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 36: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

36 fabric

See Also

gamlss.family , coef.gamlss , fitted.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #deviance(h)rm(h)

fabric The Fabric Data

Description

The data are 32 observations on faults in rolls of fabric

Usage

data(fabric)

Format

A data frame with 32 observations on the following 3 variables.

leng the length of the roll : a numeric vector

y the number of faults in the roll of fabric : a discrete vector

x the log of the length of the roll : a numeric vector

Details

The data are 32 observations on faults in rolls of fabric taken from Hinde (1982) who used the EMalgorithm to fit a Poisson-normal model. The response variable is the number of faults in the roll offabric and the explanatory variable is the log of the length of the roll.

Source

John Hinde

References

Hinde, J. (1982) Compound Poisson regression models: inGLIM 82, Proceedings of the Inter-national Conference on Generalized Linear Models, ed. Gilchrist, R., 109–121, Springer: NewYork.

Examples

data(fabric)attach(fabric)plot(x,y)detach(fabric)

Page 37: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

find.hyper 37

find.hyper A function to select values of hyperparameters in a GAMLSS model

Description

This function selects the values of hyper parameters and/or non-linear parameters in a GAMLSSmodel. It uses theR function optim which then minimised the generalized Akaike informationcriterion (GAIC) with a user defined penalty.

Usage

find.hyper(model = NULL, parameters = NULL, other = NULL, penalty = 2.5,steps = c(0.1), lower = -Inf, upper = Inf, method = "L-BFGS-B",...)

Arguments

model this is a GAMLSS model. e.g.model=gamlss(y~cs(x,df=p[1]),sigma.fo=~cs(x,df=p[2]),data=abdom)where p[1] and p[2] denore the parametets to be estimated

parameters the starting values in the search of the optimum hyperparameters and/or non-linear parameters e.g.parameters=c(3,3)

other this is used to optimize other non-parameters, for example a transformation ofthe explanatory variable of the kindxp[3], others=quote(nx<-x^p[3])where nx is now in the model formula

penalty specifies the penalty in the GAIC, (the default is 2.5) e.g.penalty=3

steps the steps taken in the optimization procedure [see the ndeps option inoptim() ],by default is set to 0.1 for all hyper parameters and non-linear parameters

lower the lower permissible level of the parameters i.e.lower=c(1,1) this doesnot apply if a method other than the default method "L-BFGS-B" is used

upper the upper permissible level of the parameters i.e.upper=c(30,10) , this isnot apply if a method other than the default method "L-BFGS-B" is used

method the method used inoptim() to numerically minimize the GAIC over the hy-perparameters and/or non-linear parameters. By default this is "L-BFGS-B" toallow box-restriction on the parameters

... for extra arguments to be passed to theR functionoptim() used in the opti-mization

Details

This is an experimental function which appears to work well for the search of the optimum degreesof freedom and non-linear parameters (e.g. power parameterλ used to transform x toxλ). Furtherinvestigation will check whether this function is reliable in general.

Page 38: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

38 find.hyper

Value

The function turns the same output as the functionoptim()

par the optimum hyperparameter values

value the minimized value of the GAIC

counts A two-element integer vector giving the number of calls to ‘fn’ and ‘gr’ respec-tively

convergence An integer code. ‘0’ indicates successful convergence. see the functionoptim()for other errors

message A character string giving any additional information returned by the optimizer,or ‘NULL’

Warning

It may be slow to find the optimum

Note

Author(s)

Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , plot.gamlss , optim

Examples

data(abdom)attach(abdom)# declare the modelmod1<-quote(gamlss(y~cs(nx,df=p[1]),family=BCT,data=abdom,

control=gamlss.control(trace=FALSE)))# we want also to check for a transformation in x# so we use the other optionop<-find.hyper(model=mod1, other=quote(nx<-x^p[2]), par=c(3,0.5),

lower=c(1,0.001), steps=c(0.1,0.001))# the optimum parameters found are# par=(p[1],p[2]) = (2.944836 0.001000) = (df for mu, lambda)# so it needs df = 3 on top of the constant and linear# in the cubic spline model for mu since p[1] is approximately 3# and log transformation for x since p[2] is approximately 0oprm(op)

Page 39: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

fitted.gamlss 39

fitted.gamlss Extract Fitted Values For A GAMLSS Model

Description

fitted.gamlss is the GAMLSS specific method for the generic functionfitted which ex-tracts fitted values for a specified parameter from a GAMLSS objects.fitted.values is analias for it. The functionfv() is similar tofitted.gamlls() but allows the argumentwhatnot to be character

Usage

fitted.gamlss(object, what = c("mu", "sigma", "nu", "tau"), ...)fv(obj, what = "mu", ...)

Arguments

object a GAMLSS fitted model

obj a GAMLSS fitted model

what which parameter fitted values are required, defaultwhat="mu"

... for extra arguments

Value

Fitted values extracted from the GAMLSS object for the given parameter.

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

print.gamlss , summary.gamlss , fitted.gamlss , coef.gamlss , residuals.gamlss ,update.gamlss , plot.gamlss , deviance.gamlss , formula.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #fitted(h)rm(h)

Page 40: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

40 fitted.plot

fitted.plot Plots The Fitted Values of a GAMLSS Model

Description

This function, applicable only to a models with a single explanatory variable, plots the fitted valuesfor all the parameters of a GAMLSS model against the (one) explanatory variable. It is also usefulfor comparing the fits for more than one model.

Usage

fitted.plot(object, ..., x = NULL, color = TRUE, line.type = FALSE)

Arguments

object a fitted GAMLSS model object(with only one explanatory variable)

... optionally more fitted GAMLSS model objects

x The unique explanatory variable

color whether the fitted lines plots are shown in colour,color=TRUE (the default)or notcolor=FALSE

line.type whether the line type should be different or not. The default iscolor=FALSE

Value

A plot of the fitted values against the explanatory variable

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , centiles , centiles.split

Examples

data(abdom)h1<-gamlss(y~cs(x,df=3), sigma.formula=~x, family=BCT, data=abdom)h2<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,df=3), family=BCT, data=abdom)fitted.plot(h1,h2,x=abdom$x)rm(h1,h2)

Page 41: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

formula.gamlss 41

formula.gamlss Extract the Model Formula in a GAMLSS fitted model

Description

formula.gamlss is the GAMLSS specific method for the generic functionformula whichextracts the model formula from objects returned by modelling functions.

Usage

formula.gamlss(x, what = c("mu", "sigma", "nu", "tau"), ... )

Arguments

x a GAMLSS fitted model

what which parameter coefficient is required, defaultwhat="mu"

... for extra arguments

Details

Value

Returns a model formula

Note

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , deviance.gamlss , fitted.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #formula(h,"mu")rm(h)

Page 42: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

42 gamlss.control

gamlss.control Auxiliary for Controlling GAMLSS Fitting

Description

Auxiliary function as user interface forgamlss fitting. Typically only used when callinggamlssfunction with the optioncontrol .

Usage

gamlss.control(c.crit = 0.001, n.cyc = 20, mu.step = 1, sigma.step = 1, nu.step = 1,tau.step = 1, gd.tol = 5, iter = 0, trace = TRUE, autostep = TRUE, ...)

Arguments

c.crit the convergence criterion for the algorithm

n.cyc the number of cycles of the algorithm

mu.step the step length for the parametermu

sigma.step the step length for the parametersigma

nu.step the step length for the parameternu

tau.step the step length for the parametertau

gd.tol global deviance tolerance level

iter starting value for the number of iterations, typically set to 0 unless the functionrefit is used

trace whether to print at each iteration (TRUE) or not (FALSE)

autostep whether the steps should be halved automatically if the new global deviance isgreater that the old one, the default isautostep=TRUE

... for extra arguments

Details

The step length for each of the parametersmu, sigma , nu or tau is very useful to aid convergenceif the parameter has a fully parametric model. However using a step length is not theoreticallyjustified if the model for the parameter includes one or more smoothing terms, (even thought it maygive a very approximate result).

Thec.crit can be increased to speed up the convergence especially for a large set of data whichtakes longer to fit. When ‘trace’ is TRUE, calls to the functioncat produce the output for eachouter iteration.

Value

A list with the arguments as components.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

Page 43: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.cs 43

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

codegamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #con<-gamlss.control(mu.step=0.1)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids, control=con) #rm(h,con)

gamlss.cs Support for Function cs()

Description

This is support for the function cs(). It is not intended to be called directly by users. The functiongamlss.cs is based on the R functionsmooth.spline

Usage

gamlss.cs(x, y = NULL, w = NULL, df = 5, spar = NULL, cv = FALSE, all.knots = TRUE,df.offset = 0, penalty = 1, control.spar = list(low = -1.5, high = 2), xeval = NULL)

Arguments

x the design matrix

y the response variable

w prior weights

df effective degrees of freedom

spar spar the smoothing parameter

cv options for thesmooth.spline function not to use here

all.knots options for thesmooth.spline function not to use here

df.offset options for thesmooth.spline function not to use here

penalty options for thesmooth.spline function not to use here

control.spar control for spar. It can be changed throughcs

xeval used in prediction

Page 44: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

44 gamlss.family

Value

Returns a class "smooth.spline" object with

residuals The residuals of the fitfitted.values

The smoothing values

var the variance for the fitted smoother

lambda the final value for spar

nl.df the smoothing degrees of freedom excluding the constant and linear terms, i.e.(df-2)

coefSmo this is a list containing among others the knots and the coefficients

...

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

See Also

gamlss , cs

gamlss.family Family Objects for fitting a GAMLSS model

Description

GAMLSS families are the current available distributions that can be fitted using thegamlss()function.

Usage

gamlss.family(object,...)as.gamlss.family(object)as.family(object)print.gamlss.family(x,...)gamlss.family.default(object,...)

Arguments

object a gamlss family object e.g.BCT

x a gamlss family object e.g.BCT

... further arguments passed to or from other methods.

Details

There are several distributions available for the response variable in thegamlss function. Thefollowing table display their names and their abbreviations inR. Note that the different distributionscan be fitted using theirR abbreviations (and optionally excluding the brackets) i.e. family=BI(),family=BI are equivalent.

Page 45: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.family 45

Distributions R names No of parametersBeta BE() 2Beta Binomial BB() 2Beta inflated BEINF() 4Binomial BI () 1Box-Cox Cole and Green BCCG() 3Box-Cox Power Exponential BCPE() 4Box-Cox-t BCT() 4Gamma GA() 2Gumbel GU() 2Inverse Gaussian IG () 2Johnson’s SU JSU() 4Logistic LO() 2log-Normal LNO() 2Negative Binomial type I NBI () 2Negative Binomial type II NBII () 2Normal NO() 2Power Exponential PE() 3Poison PO() 1Poisson inverse Gaussian PIG() 2Reverse Gumbel RG() 2Sichel SI () 3t-distribution TF() 3Weibull WEI() 2Weibull(PH parameterization) WEI2() 2Zero inflated poisson ZIP () 2Zero adjusted IG ZAIG() 2

The parameters of the distributions are in order,mu for location,sigma for scale (or dispersion),and nu and tau for shape. More specifically for theBCCGfamily mu is the median,sigmaapproximately the coefficient of variation, andnu the skewness parameter. The parameters forBCPEdistribution have the same interpretation with the extra fourth parametertau modellingthe kurtosis of the distribution. The parameters for BCT have the same interpretation except thatσ[(τ/(τ − 2))0.5] is approximately the coefficient of variation.

All of the distribution in the above list are also provided with the correspondingd, p, q and rfunctions for density (pdf), distribution function (cdf), quantile function and random generationfunction respectively, (see individual distribution for details).

Value

The above GAMLSS families return an object which is of typegamlss.family . This object isused to define the family in thegamlss() fit.

Note

More distributions will be documented in later GAMLSS releases. Further user defined distributionscan be incorporate relatively easy, see, for example, the help documentation accompanying thegamlss library.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

Page 46: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

46 gamlss.fp

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss ,BE,BB,BEINF, BI ,LNO,BCT,BCPE,BCCG, GA,GU,JSU,IG ,LO,NBI ,NBII ,NO,PE,PO,RG,PIG,TF,WEI,WEI2,ZIP

Examples

normal<-NO(mu.link="log", sigma.link="log")normalrm(normal)

gamlss.fp Support for Function fp()

Description

This is support for the function fp(). It is not intended to be called directly by users.

Usage

gamlss.fp(x, y, w, npoly = 2, xeval = NULL)

Arguments

x thex for functiongamlss.fp is referred to the design matric of the specificparameter model (not to be used by the user)

y they for functiongamlss.fp is referred to the working variable of the specificparameter model (not to be used by the user)

w thew for functiongamlss.fp is referred to the iterative weight variable of thespecific parameter model (not to be used by the user)

npoly a positive indicating how many fractional polynomials should be considered inthe fit. Can take the values 1, 2 or 3 with 2 as default

xeval used in prediction

Value

Returns a list withfitted.values

residuals residuals

var

nl.df the trace of the smoothing matrix

lambda the value of the smoothing parameter

coefSmo the coefficients from the smoothing fit

varcoeff the variance of the coefficients

Page 47: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.lo 47

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , fp

gamlss.lo Support for Function lo()

Description

This is support for theloess function lo() . It is not intended to be called directly by users. Thefunctiongamlss.lo is based on the R functionloess

Usage

gamlss.lo(x, y, w = NULL, span, df = NULL, degree = 1, ncols =FALSE, wspan = TRUE, parametric = FALSE, drop.square= FALSE, normalize = FALSE, family = "gaussian",method = "loess", control = loess.control(...), xeval= NULL, ...)

Arguments

x the design matrix

y the response variable

w prior weights

span the smoothing parameter

df effective degrees of freedom

degree the order of the polynomial

ncols the number of columns of the x matrix

wspan argument for theloess function not to use here

parametric argument for theloess function not to use here

drop.square argument for theloess function not to use here

normalize argument for theloess function not to use here

family argument for theloess function not to use here

method argument for theloess function not to use here

control argument for theloess function not to use here

xeval used in prediction

... further arguments passed to or from other methods.

Page 48: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

48 gamlss-package

Value

Returns an object with

fitted the smooth values

residuals the residuals

var the variance of the smoother

nl.df the non-linear degrees of freedom

coefSmo with value NULL

lambda the value of span

Author(s)

Mikis Stasinopoulos based on Brian Ripley loess function in R

See Also

gamlss , lo

gamlss-package The GAMLSS library and datasets

Description

This a collection of functions to fit Generalized Additive Models for Location Scale and Shape(GAMLSS)and handled gamlss objects.

GAMLSS were introduced by Rigby and Stasinopoulos (2005). GAMLSS is a general frameworkfor univariate regression type statistical problems using new ways of dealing with overdispersion,skewness and kurtosis in the response variable. In GAMLSS the exponential family distributionassumption used in Generalized Linear Model (GLM) and Generalized Additive Model (GAM),(seeNelder and Wedderburn, 1972 and Hastie and Tibshirani, 1990, respectively) is relaxed and replacedby a very general distribution family including highly skew and kurtotic discrete and continuousdistributions. The systematic part of the model is expanded to allow modelling not only the mean(or location) but other parameters of the distribution of the response variable as linear parametric,nonlinear parametric or additive non-parametric functions of explanatory variables and/or randomeffects terms. Maximum (penalized) likelihood estimation is used to fit the models.

Details

Package: gamlssType: PackageVersion: 1.1-0Date: 2006-03-08License: GPL (version 2 or later) See file LICENSE

This package allow the user to model the distribution of the response variable using a variety ofone, two, three and four parameter families of distributions. The distributions implemented cur-rently can be found ingamlss.family . Other distributions can be easily added. In the currentimplementation of GAMLSS several additive terms have been implemented including regression

Page 49: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.ps 49

splines, smoothing splines, penalized splines, varying coefficients, fractional polynomials and ran-dom effects. Other additive terms can be easily added.

Author(s)

Mikis Stasinopoulos <[email protected]>, Bob Rigby <[email protected]>with contributions from Calliope Akantziliotou.

Maintainer: Mikis Stasinopoulos <[email protected]>

References

Nelder, J. A. and Wedderburn, R. W. M. (1972). Generalized linear models.J. R. Statist. Soc.A.,135370-384.

Hastie, T. J. and Tibshirani, R. J. (1990).Generalized Additive Models. Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

Examples

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

gamlss.ps upport for Function ps()

Description

This is support for the functionps() . It is not intended to be called directly by users.

Usage

gamlss.ps(x, y, w, xeval = NULL, ...)

Arguments

x thex for functiongamlss.fp is referred to the design matric of the specificparameter model (not to be used by the user)

y they for functiongamlss.fp is referred to the working variable of the specificparameter model (not to be used by the user)

w thew for functiongamlss.fp is referred to the iterative weight variable of thespecific parameter model (not to be used by the user)

xeval used in prediction

... further arguments passed to or from other methods.

Page 50: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

50 gamlss.random

Details

Value

comp1 Description of ’comp1’

comp2 Description of ’comp2’

...

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2003) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , ps

gamlss.random Support for Function random()

Description

This is support for the function random(). It is not intended to be called directly by users. Thefunctiongamlss.radom is similar to the GAMLSS functiongamlss.ra .

Usage

gamlss.random(x, y, w, df = sum(non.zero), lambda = 0)

Arguments

x the explanatory design matrix

y the response variable

w iterative weights

df effective degrees of freedom

lambda the smoothing parameter

Page 51: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.ra 51

Value

Returns a list with

y the fitted values

residuals the residuals

var the variance of the fitted values

lambda the final lambda, the smoothing parameter

coefSmo with value NULL

Author(s)

Mikis Stasinopoulos, based on Trevor Hastie functiongam.random

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , random , ra

gamlss.ra Support for Function ra()

Description

This is support for the random effect smoother function ra() . It is not intended to be called directlyby users. The functiongamlss.ra is similar to the GAMLSS functiongamlss.random . Bothfunctions can be used with the same effect.

Usage

gamlss.ra(x, y, w, df = sum(non.zero))

Arguments

x the explanatory design matrix

y the response variable

w iterative weights

df effective degrees of freedom

Details

Page 52: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

52 gamlss.rc

Value

Returns an list with

fitted.valuesfitted values

residuals residuals

var variances of the fitted values

nl.df the trace of the smoothing matrix

lambda the value of the smoothing parameter

coefSmo the coefficients from the smoothing fit

varcoeff the variance of the coefficients

Note

This is an experimental function and should be used with care

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , ra , random

gamlss.rc Support for Function rc()

Description

This is support for the function rc(). It is not intended to be called directly by users.

Usage

gamlss.rc(x, y, w, df = sum(non.zero))

Arguments

x the explanatory design matrix

y the response variable

w iterative weights

df effective degrees of freedom

Page 53: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss 53

Value

Returns a list with

fitted.values

residuals residuals

var

nl.df the trace of the smoothing matrix

lambda the value of the smoothing parameter

coefSmo the coefficients from the smoothing fit

varcoeff the variance of the coefficients

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , rc

gamlss Generalized Additive Models for Location Scale and Shape

Description

Returns an object of class "gamlss", which is a generalized additive model for location scale andshape (GAMLSS). The functiongamlss() is very similar to thegam() function in S-plus (nowalso in R in packagegam), but can fit more distributions (not only the ones belonging to the expo-nential family) and can model all the parameters of the distribution as functions of the explanatoryvariables (e.g. using linear, non-linear, smoothing, loess and random effects terms).

This implementation ofgamlss() allows modelling of up to four parameters in a distributionfamily, which are conventionally calledmu, sigma , nu andtau .

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

Page 54: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

54 gamlss

Usage

gamlss(formula = formula(data), sigma.formula = ~1,nu.formula = ~1, tau.formula = ~1, family = NO(),data = sys.parent(), 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 in-dicated bycs for smoothing splines,lo for loess smooth terms andrandom orra for random terms, e.g.y~cs(x,df=5)+x1+x2*x3 . Additional smootherscan be added by creating the appropriate interface. Interactions with nonpara-metric smooth terms are not fully supported, but will not produce errors; theywill simply produce the usual parametric interaction

sigma.formulaa formula object for fitting a model to the sigma parameter, as in the formulaabove, e.g.sigma.formula=~cs(x,df=5) . It can be abbreviated tosigma.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 thelink functions of the various parameters. The distribution families supportedby gamlss() can be found ingamlss.family . Functions such as BI()(binomial) produce a family object. Also can be given without the parenthesesi.e. BI . Family functions can take arguments, as inBI(mu.link=probit)

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

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 insubset )or for a weighted likelihood analysis where the contribution of the observationsto the likelihood differs according toweights . The length ofweights mustbe the same as the number of observations in the data. By default, the weight isset to one. To set weights to vector w useweights=w

contrasts list of contrasts to be used for some or all of the factors appearing as variables inthe model formula. The names of the list should be the names of the correspond-ing variables. The elements should either be contrast-type matrices (matriceswith as many rows as levels of the factor and with columns linearly independentof each other and of a column of ones), or else they should be functions thatcompute 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 theCole and Green algorithm andmixed(2,10) will use the RS algorithm twicebefore switching to the Cole and Green algorithm for up to 10 extra iterations

Page 55: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss 55

start.from a fitted GAMLSS model which the fitted values will be used as staring valuesfor 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 defaultsetting is thegamlss.control function

i.control this sets the control parameters of the inner iterations of the RS algorithm. Thedefault setting is theglim.control function

... for extra arguments

x an object

Details

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

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

Value

Returns a gamlss object with components

family the distribution family of the gamlss object (seegamlss.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

Page 56: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

56 gamlss

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

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 pa-rameters if present

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

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

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

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

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

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

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

mu.coefficientsthe 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 forthe other parameters if present

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

mu.nl.df the non linear degrees of freedom, also sigma.nl.df, nu.nl.df, tau.nl.df for theother 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 formushould be fitted before a model forsigma is fitted

Note

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

Page 57: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

gamlss.scope 57

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss.family , pdf.plot , find.hyper

Examples

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

gamlss.scope Generate a Scope Argument for Stepwise GAMLSS

Description

Generates a scope argument for a stepwise GAMLSS.

Usage

gamlss.scope(frame, response = 1, smoother = "cs", arg = NULL, form = TRUE)

Arguments

frame a data or model frame

response which variable is the response; the default is the first

smoother what smoother to use; default iscs

arg any additional arguments required by the smoother

form should a formula be returned (default), or else a character version of the formula

Details

Each formula describes an ordered regimen of terms, each of which is eligible on their own forinclusion in the gam model. One of the terms is selected from each formula by step.gam. If a 1 isselected, that term is omitted.

Page 58: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

58 GA

Value

a list of formulas is returned, one for each column in frame (excluding the response). For a numericvariable, say x1, the formula is

1 + x1 + cs(x1)

If x1 is a factor, the last smooth term is omitted.

Author(s)

Mikis Stasinopoulos: a modified function from Statistical Models in S

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

stepGAIC

Examples

data(usair)gs1<-gamlss.scope(model.frame(y~x1+x2+x3+x4+x5+x6, data=usair))gs2<-gamlss.scope(model.frame(usair))gs1gs2gs3<-gamlss.scope(model.frame(usair), smooth="fp", arg="3")gs3

GA Gamma distribution for fitting a GAMLSS

Description

The functionGAdefines the gamma distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The parameterization used hasthe mean of the distribution equal toµ and the variance equal toσ2µ2. The functionsdGA, pGA,qGAandrGA define the density, distribution function, quantile function and random generation forthe specific parameterization of the gamma distribution defined by functionGA.

Usage

GA(mu.link = "log", sigma.link ="log")dGA(y, mu = 1, sigma = 1, log = FALSE)pGA(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qGA(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)rGA(n, mu = 1, sigma = 1)

Page 59: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

GA 59

Arguments

mu.link Defines themu.link , with "log" link as the default for the mu parameter, otherlinks are "inverse" and "identity"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other link is the "inverse" and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The specific parameterization of the gamma distribution used inGAis

f(y|µ, σ) =y(1/σ2−1) exp[−y/(σ2µ)]

(σ2µ)(1/σ2)Γ(1/σ2)

for y > 0, µ > 0 andσ > 0.

Value

GA() returns agamlss.family object which can be used to fit a gamma distribution in thegamlss() function. dGA() gives the density,pGA() gives the distribution function,qGA()gives the quantile function, andrGA() generates random deviates. The latest functions are basedon the equivalentR functions for gamma distribution.

Note

µ is the mean of the distribution inGA. In the functionGA, σ is the square root of the usual dispersionparameter for a GLM gamma model. Henceσµ is the standard deviation of the distribution definedin GA.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Page 60: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

60 glim.control

Examples

GA()# gives information about the default links for the gamma distributiondat<-rgamma(100, shape=1, scale=10) # generates 100 random observationsgamlss(dat~1,family=GA)# fits a constant for each parameter mu and sigma of the gamma distributionnewdata<-rGA(1000,mu=1,sigma=1) # generates 1000 random observationshist(newdata)rm(dat,newdata)

glim.control Auxiliary for Controlling the inner algorithm in a GAMLSS Fitting

Description

Auxiliary function used for the inner iteration ofgamlss algorithm. Typically only used whencallinggamlss function through the optioni.control .

Usage

glim.control(cc = 0.001, cyc = 50, trace = FALSE,bf.cyc = 30, bf.tol = 0.001, bf.trace = FALSE,...)

Arguments

cc the convergence criterion for the algorithm

cyc the number of cycles of the algorithm

trace whether to print at each iteration (TRUE) or not (FALSE)

bf.cyc the number of cycles of the backfitting algorithm

bf.tol the convergence criterion (tolerance level) for the backfitting algorithm

bf.trace whether to print at each iteration (TRUE) or not (FALSE, the default)

... for extra arguments

Value

A list with the arguments as components

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 61: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

GU 61

See Also

gamlss

Examples

data(aids)con<-glim.control(trace=TRUE)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids, i.control=con) #rm(h,con)

GU The Gumbel distribution for fitting a GAMLSS

Description

The functionGUdefines the Gumbel distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The functionsdGU, pGU, qGUandrGU define the density, distribution function, quantile function and random generation for thespecific parameterization of the Gumbel distribution.

Usage

GU(mu.link = "identity", sigma.link = "log")dGU(y, mu = 0, sigma = 1, log = FALSE)pGU(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qGU(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rGU(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter.other available link is "log"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other links are the "inverse" and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The specific parameterization of the Gumbel distribution used inGUis

f(y|µ, σ) =1σ

exp(

y − µ

σ

)− exp

(y − µ

σ

)for y = (−∞,∞), µ = (−∞,+∞) andσ > 0.

Page 62: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

62 histDist

Value

GU() returns agamlss.family object which can be used to fit a Gumbel distribution in thegamlss() function. dGU() gives the density,pGU() gives the distribution function,qGU()gives the quantile function, andrGU() generates random deviates.

Note

The mean of the distribution isµ− 0.57722σ and the variance isπ2σ2/6.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

plot(function(x) dGU(x, mu=0,sigma=1), -6, 3,main = "Gumbel density mu=0,sigma=1")

GU()# gives information about the default links for the Gumbel distributiondat<-rGU(100, mu=10, sigma=2) # generates 100 random observationsgamlss(dat~1,family=GU) # fits a constant for each parameter mu and sigma

histDist This function plots the histogram and a fitted (GAMLSS family) distri-bution to a variable

Description

This function fits constants to the parameters of a GAMLSS family distribution and them plot thehistogram and the fitted distribution.

Usage

histDist(y, family = NO, freq = NULL, xmin = NULL,xmax = NULL, g.control = gamlss.control(),density = FALSE, main = NULL, ...)

Page 63: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

histDist 63

Arguments

y a vector

family a continuous GAMLSS family distribution

freq the frequencies of the data iny if exist. freq is used asweights in thegamlss fit

xmin the minimum x-variable value (if the default values are out of range)

xmax the maximum x-variable value (if the default values are out of range)

g.control this is similar togamlss.control in case that some of the control parametershave to be changed

density default value is FALSE. Change to TRUE if you would like a non-parametricdensity plot together with the parametric fitted distribution plot (for continuousvariable only)

main the main title for the plot

... for extra arguments to be passed to thetruehist() or thegamlss function

Details

This function first fits constants for each parameters of a GAMLSS distribution family using thegamlss function and them plots the fitted distribution together with the appropriate plot accordingto whether they variable is of a continuous or discrete type. Histogram is plotted for continuous andbarplot for discrete variables. The functiontruehist of Venables and Ripley’s MASS packageis used for the histogram plotting.

Value

returns a plot

Author(s)

Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

data(abdom)attach(abdom)histDist(y,family="NO")# use the ymax argument of the of the truehist()histDist(y,family="NO",ymax=0.005)# bad fit use PE

Page 64: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

64 hodges

histDist(y,family="PE",ymax=0.005)detach(abdom)# discere data counts# Hand at al. p150 Leptinotarsa decemlineatay <- c(0,1,2,3,4,6,7,8,10,11)freq <- c(33,12,5,6,5,2,2,2,1,2)histDist(y, "NBI", freq=freq)# the same ashistDist(rep(y,freq), "NBI")

hodges Hodges data

Description

There two data sets contain data used in Hodges (1998). In addition to the data used in thatmanuscript, it contains other data items.

The original data consists of two matrices of dimensions of 341x6 and a 45x4 respectively.

The first matrixhodges describes plans. The information for each plan is: the state, a two-character code that identifies plans within state, the total premium for an individual, the total pre-mium for a family, the total enrollment of federal employees as individuals, and the total enrollmentof federal employees as families.

The second matrix,hodges , describes states. The information for each state is: its two-letterabbreviation, the state average expenses per admission (from American Medical Association 1991Annual Survey of Hospitals), population (1990 Census), and the region (from the Marion MerrillDow Managed Care Digest 1991).

The Hodges manuscript used these variables: Plan level: individual premium, individual enroll-ment. State level: expenses per admission, region.

Usage

data(hodges)

Format

Two data frames the first with 341 observations on the following 6 variables.

state a factor with 45 levelsAL AZ CA CO CT DC DE FL GA GU HI IA ID IL IN KS KY LA MAMD ME MI MN MO NC ND NE NH NJ NM NV NY OH OK OR PA PR RI SC TN TX UT VA WA WI

plan a two-character code that identifies plans within state declared here as factor with 325 levals.

prind a numeric vector showing the total premium for an individual

prfam a numeric vector showing the total premium for a family

enind a numeric vector showing the total enrollment of federal employees as individuals

enfam a numeric vector showing the total enrollment of federal employees as families.

and the second with 45 observations on the following 4 variables

State a factor with levels same as state above

expe a numeric vector showing the state average expenses per admission (from American MedicalAssociation 1991 Annual Survey of Hospitals)

Page 65: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

IC 65

pop a numeric vector shoing the population (1990 Census)

region the region (from the Marion Merrill Dow Managed Care Digest 1991), a factor with levelsMA MT NC NE PA SA SC

Details

Source

http://www.biostat.umn.edu/~hodges/

References

Hodges, J. S. (1998). Some algebra and geometry for hierarchical models, applied to diadnostics.J. R. Statist. Soc. B., 60pp 497:536.

Examples

data(hodges)attach(hodges)plot(prind~state, cex=1, cex.lab=1.5, cex.axis=1, cex.main=1.2)str(hodges)data(hodges1)str(hodges1)

IC Gives the GAIC for a GAMLSS Object

Description

IC is a function to calculate the Generalized Akaike information criterion (GAIC) for a givenpenaltyk for a fitted GAMLSS object. The functionAIC.gamlss is the method associated with aGAMLSS object of the generic functionAIC . The functionGAIC is a synonymous of the functionAIC.gamlss . The functionextractAIC is a the method associated a GAMLSS object of thegeneric functionextractAIC and it is mainly used in thestepAIC function.

Usage

IC(object, k = 2)AIC.gamlss(object, ..., k = 2)GAIC(object, ..., k = 2 )extractAIC.gamlss(fit, scale, k = 2, ...)

Arguments

object an gamlss fitted model

fit an gamlss fitted model

... allows several GAMLSS object to be compared using a GAIC

k the penalty with defaultk=2.5

scale this argument is not used in gamlss

Page 66: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

66 IG

Value

The functionIC returns the GAIC for given penalty k of the GAMLSS object. The functionAICreturns a matrix contains the df’s and the GAIC’s for given penalty k. The functionGAIC returnsidentical results toAIC . The functionextractAIC returns vector of length two with the degreesof freedom and the AIC criterion.

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss

Examples

data(abdom)mod1<-gamlss(y~cs(x,df=3),sigma.fo=~cs(x,df=1),family=BCT, data=abdom)IC(mod1)mod2<-gamlss(y~cs(x,df=3),sigma.fo=~x,family=BCT, data=abdom)AIC(mod1,mod2,k=3)GAIC(mod1,mod2,k=3)extractAIC(mod1,k=3)rm(mod1,mod2)

IG Inverse Gaussian distribution for fitting a GAMLSS

Description

The functionIG() , or equivalentlyInverse.Gaussian() , defines the inverse Gaussian distri-bution, a two parameter distribution, for agamlss.family object to be used in GAMLSS fittingusing the functiongamlss() . The functionsdIG , pIG , qIG andrIG define the density, distri-bution function, quantile function and random generation for the specific parameterization of theInverse Gaussian distribution defined by functionIG .

Usage

IG(mu.link = "log", sigma.link = "log")dIG(y, mu = 1, sigma = 1, log = FALSE)pIG(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qIG(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE,

lower.limit = 0, upper.limit = mu+10*sqrt(sigma^2*mu^3))rIG(n, mu = 1, sigma = 1, ...)

Page 67: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

IG 67

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

lower.limit the argumentlower.limit sets the lower limit in the golden section searchfor q, the default is zero but it may have to change for small values ofsigmasay less than 0.05 since the distribution will be concentrated close tomu

upper.limit the argumentupper.limit sets the upper limit in the golden section searchfor q, the default is 10 time its standard deviation

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

... ... can be used to pass the uppr.limit argument toqIG

Details

Definition file for inverse Gaussian distribution.

f(y|µ, σ) =1√

2πσ2y3exp

− 1

2µ2σ2y(y − µ)2

for y > 0, µ > 0 andσ > 0.

Value

returns agamlss.family object which can be used to fit a inverse Gaussian distribution in thegamlss() function.

Note

µ is the mean andσ2µ3 is the variance of the inverse Gaussian

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 68: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

68 JSUo

See Also

gamlss , gamlss.family

Examples

IG()# gives information about the default links for the normal distributiondata(rent)gamlss(R~cs(Fl),family=IG, data=rent) #plot(function(x)dIG(x, mu=1,sigma=.5), 0.01, 6,

main = "Inverse Gaussian density mu=1,sigma=0.5")plot(function(x)pIG(x, mu=1,sigma=.5), 0.01, 6,

main = "Inverse Gaussian cdf mu=1,sigma=0.5")

JSUo The original Johnson’s Su distribution for fitting a GAMLSS

Description

This function defines the , a four parameter distribution, for agamlss.family object to be usedfor a GAMLSS fitting using the functiongamlss() . The functionsdJSUo, pJSUo, qJSUo andrJSUo define the density, distribution function, quantile function and random generation for thethe Johnson’s Su distribution.

Usage

JSUo(mu.link = "identity", sigma.link = "log", nu.link = "identity", tau.link = "log")dJSUo(y, mu = 0, sigma = 1, nu = 0, tau = 1, log = FALSE)pJSUo(q, mu = 0, sigma = 1, nu = 0, tau = 1, lower.tail = TRUE, log.p = FALSE)qJSUo(p, mu = 0, sigma = 1, nu = 0, tau = 1, lower.tail = TRUE, log.p = FALSE)rJSUo(n, mu = 0, sigma = 1, nu = 0, tau = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

nu.link Defines thenu.link , with "identity" link as the default for thenu parameter.Other links are "1/nu2" and "log"

tau.link Defines thetau.link , with "log" link as the default for thetau parameter.Other links are "1/tau2", and "identity

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of skewnessnu parameter values

tau vector of kurtosistau parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Page 69: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

JSUo 69

Details

The probability density function of the orininal Jonhson’s SU distribution, (JSU), is defined as

f(y|n, µ, σ ν, τ) =τ

σ

1(z2 + 1)

12

1√2π

exp[−1

2r2

]for −∞ < y < ∞, µ = (−∞,+∞), σ > 0, ν = (−∞,+∞) andτ > 0. wherez = (y−µ)

σ ,r = ν + τsinh−1(z).

Value

JSUo() returns agamlss.family object which can be used to fit a Johnson’s Su distributionin thegamlss() function.dJSUo() gives the density,pJSUo() gives the distribution function,qJSUo() gives the quantile function, andrJSUo() generates random deviates.

Warning

The functionJSU uses first derivatives square in the fitting procedure so standard errors should beinterpreted with caution. It is recomented to be used only withmethod=mixed(2,20)

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

References

Johnson, N. L. (1954). Systems of frequency curves derived from the first law of Laplace.,Trabajosde Estadistica, 5, 283-291.

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

Stasinopoulos D. M. Rigby R. A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , JSU, BCT

Examples

JSU()data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=JSUo,

data=abdom, method=mixed(2,20))plot(h)rm(h)plot(function(x)dJSUo(x, mu=0,sigma=1,nu=-1, tau=.5), -4, 15,

main = "The JSUo density mu=0,sigma=1,nu=-1, tau=.5")plot(function(x) pJSUo(x, mu=0,sigma=1,nu=-1, tau=.5), -4, 15,

main = "The JSUo cdf mu=0, sigma=1, nu=-1, tau=.5")

Page 70: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

70 JSU

JSU The Johnson’s Su distribution for fitting a GAMLSS

Description

This function defines the , a four parameter distribution, for agamlss.family object to be usedfor a GAMLSS fitting using the functiongamlss() . The functionsdJSU, pJSU, qJSU andrJSU define the density, distribution function, quantile function and random generation for the theJohnson’s Su distribution.

Usage

JSU(mu.link = "identity", sigma.link = "log", nu.link = "identity", tau.link = "log")dJSU(y, mu = 0, sigma = 1, nu = 1, tau = 0.5, log = FALSE)pJSU(q, mu = 0, sigma = 1, nu = 1, tau = 0.5, lower.tail = TRUE, log.p = FALSE)qJSU(p, mu = 0, sigma = 1, nu = 0, tau = 0.5, lower.tail = TRUE, log.p = FALSE)rJSU(n, mu = 0, sigma = 1, nu = 0, tau = 0.5)

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

nu.link Defines thenu.link , with "identity" link as the default for thenu parameter.Other links are "1/nu2" and "log"

tau.link Defines thetau.link , with "log" link as the default for thetau parameter.Other links are "1/τ2", and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of skewnessnu parameter values

tau vector of kurtosistau parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The probability density function of the Jonhson’s SU distribution, (JSU), is defined as

f(y|n, µ, σ ν, τ) ==1cσ

1τ(z2 + 1)

12

1√2π

exp[−1

2r2

]for −∞ < y < ∞, µ = (−∞,+∞), σ > 0, ν = (−∞,+∞) andτ > 0. wherer = −ν +1τ sinh−1(z), z = y−(µ+cσw

12 sinh Ω)

cσ , c = [12 (w − 1)(w cosh 2Ω + 1)]12 , w = eτ2

andΩ = −ντ .

Page 71: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

JSU 71

This is a reparameterization of the original Johnson Su distribution, Johnson (1954), so the param-etersmu andsigma are the mean and the standard deviation of the distribution. The parameternu determines the skewness of the distribution withnu>0 indicating positive skewness andnu<0negative. The parametertau determines the kurtosis of the distribution.tau should be positiveand most likely in the region from zero to 1. Astau goes to 0 (and fornu=0 ) the distributionapproaches the the Normal density function. The distribution is appropriate for leptokurtic data thatis data with kurtosis larger that the Normal distribution one.

Value

JSU() returns agamlss.family object which can be used to fit a Johnson’s Su distributionin the gamlss() function. dJSU() gives the density,pJSU() gives the distribution function,qJSU() gives the quantile function, andrJSU() generates random deviates.

Warning

The functionJSU uses first derivatives square in the fitting procedure so standard errors should beinterpreted with caution

Note

Author(s)

Bob Rigby and Mikis Stasinopoulos

References

Johnson, N. L. (1954). Systems of frequency curves derived from the first law of Laplace.,Trabajosde Estadistica, 5, 283-291.

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

Stasinopoulos D. M. Rigby R. A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , JSU, BCT

Examples

JSU()data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=JSU, data=abdom)plot(h)rm(h)plot(function(x)dJSU(x, mu=0,sigma=1,nu=-1, tau=.5), -4, 4,

main = "The JSU density mu=0,sigma=1,nu=-1, tau=.5")plot(function(x) pJSU(x, mu=0,sigma=1,nu=-1, tau=.5), -4, 4,

main = "The JSU cdf mu=0, sigma=1, nu=-1, tau=.5")

Page 72: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

72 LNO

LNO Log Normal distribution for fitting a GAMLSS

Description

The functionLOGNOdefines agamlss.family distribution to fits the log-Normal distribu-tion. The functionLNO is more general and can fit a Box-Cox transformation to data using thegamlss() function. In theLOGNOthere are two parameters involvedmu sigma , while in theLNOthere are three parametersmu sigma , and the transformation parameternu . The transforma-tion parameternu in LNOis a ’fixed’ parameter (not estimated) and it has its default value equalto zero allowing the fitting of the log-normal distribution as inLOGNO. See the example below onhow to fix nu to be a particular value. In order to estimate (or model) the parameternu , use thegamlss.family BCCGdistribution which uses a reparameterized version of the the Box-Coxtransformation. The functionsdLOGNO, pLOGNO, qLOGNOandrLOGNOdefine the density, dis-tribution function, quantile function and random generation for the specific parameterization of thelog-normal distribution. The functionsdLNO, pLNO, qLNOand rLNO define the density, distri-bution function, quantile function and random generation for the specific parameterization of thelog-normal distribution and more generally a Box-Cox transformation.

Usage

LNO(mu.link = "identity", sigma.link = "log")LOGNO(mu.link = "identity", sigma.link = "log")dLNO(y, mu = 1, sigma = 0.1, nu = 0, log = FALSE)dLOGNO(y, mu = 0, sigma = 1, log = FALSE)pLNO(q, mu = 1, sigma = 0.1, nu = 0, lower.tail = TRUE, log.p = FALSE)pLOGNO(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qLNO(p, mu = 1, sigma = 0.1, nu = 0, lower.tail = TRUE, log.p = FALSE)qLOGNO(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rLNO(n, mu = 1, sigma = 0.1, nu = 0)rLOGNO(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter. Other links are "inverse", and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of shape parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Page 73: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

LNO 73

Details

The probability density function inLOGNOis defined as

f(y|µ, σ) =1

y√

2πσexp[− 1

2σ2(log(y)− µ)2]

for y > 0, µ = (−∞,+∞) andσ > 0.

The probability density function inLNOis defined as

f(y|µ, σ, ν) =1√2πσ

yν−1 exp[− 12σ2

(z − µ)2]

where ifν 6= 0 z = (yν − 1)/ν elsez = log(y) andz ∼ N(0, σ2), for y > 0, µ > 0, σ > 0 andν = (−∞,+∞).

Value

LNO() returns agamlss.family object which can be used to fit a log-narmal distribution in thegamlss() function.dLNO() gives the density,pLNO() gives the distribution function,qLNO()gives the quantile function, andrLNO() generates random deviates.

Warning

This is a two parameter fit forµ andσ while ν is fixed. If you wish to modelν use the gamlssfamily BCCG.

Note

µ is the mean of z (and also the median of y), the Box-Cox transformed variable andσ is thestandard deviation of z and approximate the coefficient of variation of y

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations (with discussion),J. R. Statist.Soc.B., 26, 211–252

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , BCCG

Page 74: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

74 LO

Examples

LOGNO()# gives information about the default links for the log normal distributionLNO()# gives information about the default links for the Box Cox distributiondata(abdom)h1<-gamlss(y~cs(x), family=LOGNO, data=abdom)#fits the log-Normal distributionh2<-gamlss(y~cs(x), family=LNO, data=abdom) #should be identical to the one above# to change to square root transformation, i.e. fix nu=0.5h3<-gamlss(y~cs(x), family=LNO, data=abdom, nu.fix=TRUE, nu.start=0.5)rm(h1,h2,h3)

LO Logistic distribution for fitting a GAMLSS

Description

The functionLO() , or equivalentlyLogistic() , defines the logistic distribution, a two param-eter distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss()

Usage

LO(mu.link = "identity", sigma.link = "log")dLO(y, mu = 0, sigma = 1, log = FALSE)pLO(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qLO(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rLO(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

Definition file for Logistic distribution.

f(y|µ, σ) =1σ

e−y−µ

σ [1 + e−y−µ

σ ]−2

for y = (−∞,∞), µ = (−∞,∞) andσ > 0.

Page 75: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

lo 75

Value

LO() returns agamlss.family object which can be used to fit a logistic distribution in thegamlss() function. dLO() gives the density,pLO() gives the distribution function,qLO()gives the quantile function, andrLO() generates random deviates for the logistic distribution. Thelatest functions are based on the equivalentR functions for logistic distribution.

Note

µ is the mean andσπ/√

3 is the standard deviation for the logistic distribution

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

LO()# gives information about the default links for the Logistic distributiondata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=LO, data=abdom) # fitsplot(h)rm(h)plot(function(y) dLO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) pLO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) qLO(y, mu=10 ,sigma=2), 0, 1)

lo Specify a loess fit in a GAMLSS formula

Description

Allows the user to specify a loess fit in a GAMLSS formula. This function is similar to thelofunction in thegam implementation of S-plus

Usage

lo(..., span = 0.5, df = NULL, degree = 1)

Page 76: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

76 lo

Arguments

... the unspecified ... can be a comma-separated list of numeric vectors, numericmatrix, or expressions that evaluate to either of these. If it is a list of vectors,they must all have the same length.

span the number of observations in a neighborhood. This is the smoothing parameterfor a loess fit.

df the effective degrees of freedom can be specified instead of span, e.g.df=5

degree the degree of local polynomial to be fit; can be 1 or 2.

Details

Note thatlo itself does no smoothing; it simply sets things up for the functiongamlss.lo()which is used by the backfitting functiongamlss.add() .

Value

a numeric matrix is returned. The simplest case is when there is a single argument to lo anddegree=1; a one-column matrix is returned, consisting of a normalized version of the vector. Ifdegree=2 in this case, a two-column matrix is returned, consisting of a 2d-degree orthogonal-polynomial basis. Similarly, if there are two arguments, or the single argument is a two-columnmatrix, either a two-column matrix is returned if degree=1, or a five-column matrix consisting ofpowers and products up to degree 2. Any dimensional argument is allowed, but typically one or twovectors are used in practice. The matrix is endowed with a number of attributes; the matrix itselfis used in the construction of the model matrix, while the attributes are needed for the backfittingalgorithms all.wam or lo.wam (weighted additive model). Local-linear curve or surface fits repro-duce linear responses, while local-quadratic fits reproduce quadratic curves or surfaces. These partsof the loess fit are computed exactly together with the other parametric linear parts of the model.

Warning

For user wanted to compare thegamlss() results with the equivalentgam() results in S-plus:make sure that the convergence criteria epsilon and bf.epsilon in S-plus are decreased sufficientlyto ensure proper convergence in S-plus

Note

Note thatlo itself does no smoothing; it simply sets things up forgamlss.lo() to do the back-fitting.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉,based on the Trevor Hastie S-pluslo function

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 77: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

lpred 77

See Also

cs , random ,

Examples

data(aids)attach(aids)# fitting a loess curve with span=0.4 plus the a quarterly effectaids1<-gamlss(y~lo(x,span=0.4)+qrt,data=aids,family=PO) #plot(x,y)lines(x,fitted(aids1))rm(aids1)detach(aids)

lpred Extract Linear Predictor Values and Standard Errors For A GAMLSSModel

Description

lpred is the GAMLSS specific method which extracts the linear predictor and its (approximate)standard errors for a specified parameter from a GAMLSS objects. Thelpred can be also used toextract the fitted values (with its approximate standard errors) or specific terms in the model (withits approximate standard errors) in the same way that thepredict.lm() andpredict.glm()functions can be used forlm or glm objects. The functionlp extract only the linear predictor. Ifprediction is required for new data values then use the functionpredict.gamlss() .

Usage

lpred(obj, what = c("mu", "sigma", "nu", "tau"),type = c("link", "response", "terms"),terms = NULL, se.fit = FALSE, ...)

lp(obj, what = "mu", ...)

Arguments

obj a GAMLSS fitted model

what which distribution parameter is required, defaultwhat="mu"

type type="link" (the default) gets the linear predictor for the specified distribu-tion parameter.type="response" gets the fitted values for the parameterwhile type="terms" gets the fitted terms contribution

terms if type="terms" , which terms to be selected (default is all terms)

se.fit if TRUE the approximate standard errors of the appropriate type are extracted

... for extra arguments

Value

If se.fit=FALSE a vector (or a matrix) of the appropriatetype is extracted from the GAMLSSobject for the given parameter inwhat . If se.fit=TRUE a list containing the appropriatetype ,fit , and its (approximate) standard errors,se.fit .

Page 78: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

78 make.link.gamlss

Author(s)

Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

predict.gamlss

Examples

data(aids)mod<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #mod.t <- lpred(mod, type = "terms", terms= "qrt")mod.tmod.lp <- lp(mod)mod.lprm(mod, mod.t,mod.lp)

make.link.gamlss Create a Link for GAMLSS families

Description

This function is used with the ’family’ functions ingamlss() . Given a link, it returns a linkfunction, an inverse link function, the derivative dpar/deta where par is the appropriate distributionparameter and a function for domain checking. It differs from the usualmake.link of glm()by having extra links as thelogshifted , the logitshifted and theown. For the use of theown link see the example bellow.

show.link provides a way in which the user can identify the link functions available for eachgamlss distribution. If your required link function is not available for any of the gamlss distributionsyou can add it in.

Usage

make.link.gamlss(link, par = 1)show.link(family = "NO")

Arguments

link character or numeric; one of"logit" , "probit" , "cloglog" , "identity" ,"log" , "sqrt" , "1/mu^2" , "inverse" , "logshifted" , "logitshifted" ,or number, say lambda resulting in power linkµλ).

par The shifted parameter(s) forlogshifted and"logitshifted" i.epar=1for logshifted orpar=c(0,2) for logitshifted

family a gamlss distributionfamily

Page 79: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

make.link.gamlss 79

Details

Theown link function is added to allow the user greater flexibility. In order to used the own linkfunction for any of the parameters of the distribution theown link should appear in the availablelinks for this parameter. You can check this using the functionshow.link . If the own do notappear in the list you can create a new function for the distribution in whichown is added in thelist. For example the first line of the code of the binomial distribution,BI , has change from

"mstats <- checklink("mu.link", "Binomial", substitute(mu.link), c("logit", "probit", "cloglog", "log")),in version 1.0-0 of gamlss, to

"mstats <- checklink("mu.link", "Binomial", substitute(mu.link), c("logit", "probit", "cloglog", "log","own"))

in version 1.0-1. Given that the parameter hasown as an option the user needs also to define thefollowing four new functions in order to used anown link.

i) own.linkfun

ii) own.linkinv

iii) own.mu.eta and

iv) own.valideta.

An example is given below.

Only one parameter of the distribution at a time is allowed to have itscode link, (unless the samefour own functions above are suitable for more that one parameter of the distribution).

Value

For themake.link.gamlss a list with components

linkfun: Link function function(parameter)

linkinv: Inverse link functionfunction(eta)

mu.eta: Derivativefunction(eta) dparameter/deta

valideta:function(eta) ’TRUE’ if all of ’eta’ is in the domain oflinkinv .

For theshow.link a list with components the available links for the distribution parameters

Note

For the links involving parameters as inlogshifted and logitshifted the parameters canbe passed in the definition of the distribution by calling thechecklink function, for example inthe definition of thetau parameter in BCPE distribution the following call is made:tstats <-checklink( "tau.link", "Box Cox Power Exponential", substitute(tau.link),c("logshifted", "log", "identity"), par.link = c(1))

Author(s)

Mikis Stasinopoulos and Bob Rigby

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 80: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

80 make.link.gamlss

See Also

gamlss , gamlss.family

Examples

str(make.link.gamlss("logitshifted"), par=c(-1,1))l2<-make.link.gamlss("logitshifted", par=c(-1,1))l2$linkfun(0) # should be zerol2$linkfun(1) # should be Infl2$linkinv(-5:5)# now use the own link function# first if the distribution allows youshow.link(BI)# seems OK now define the four own functions# First try the probit link using the own link function# 1: the linkfun functionown.linkfun <- function(mu) eta <- qNO(p=mu)# 2: the inverse link functionown.linkinv <- function(eta)

thresh <- -qNO(.Machine$double.eps)eta <- pmin(thresh, pmax(eta, -thresh))

pNO(eta)# 3: the dmu/deta functionown.mu.eta <- function(eta) pmax(dNO(eta), .Machine$double.eps)own.valideta <- function(eta) TRUE# bring the datadata(aep)# fitting the model using "own"h1<-gamlss(y~ward+loglos+year, family=BI(mu.link="own"), data=aep)# model h1 should be identical toh2<-gamlss(y~ward+loglos+year, family=BI(mu.link="probit"), data=aep)# Second try the complementary log-log# using the Gumbel distributionown.linkfun <- function(mu) eta <- qGU(p=mu)own.linkinv <- function(eta)

thresh <- -qGU(.Machine$double.eps)eta <- pmin(thresh, pmax(eta, -thresh))

pGU(eta)own.mu.eta <- function(eta) pmax(dGU(eta), .Machine$double.eps)own.valideta <- function(eta) TRUE# h1 and h2 should be identicalh1<-gamlss(y~ward+loglos+year, family=BI(mu.link="own"), data=aep)h2<-gamlss(y~ward+loglos+year, family=BI(mu.link="cloglog"), data=aep)# note that the Gumbel distribution is negatively skew# for a positively skew link function we can used the Reverse Gumbelown.linkfun <- function(mu) eta <- qRG(p=mu)own.linkinv <- function(eta)

thresh <- -qRG(.Machine$double.eps)eta <- pmin(thresh, pmax(eta, -thresh))

pRG(eta)# third the dmu/deta functionown.mu.eta <- function(eta) pmax(dRG(eta), .Machine$double.eps)own.valideta <- function(eta) TRUEdata(aep)h1<-gamlss(y~ward+loglos+year, family=BI(mu.link="own"), data=aep)# a considerable improvement in the deviance

Page 81: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

model.frame.gamlss 81

model.frame.gamlss Extract a model.frame, a model matrix or terms from a GAMLSS ob-ject for a given distributional parameter

Description

model.frame.gamlss , model.matrix.gamlss andterms.gamlss are the gamlss ver-sions of the generic functionsmodel.frame , model.matrix andterms respectively.

Usage

model.frame.gamlss(formula, what = c("mu", "sigma", "nu", "tau"), ...)terms.gamlss(x, what = c("mu", "sigma", "nu", "tau"), ...)model.matrix.gamlss(object, what = c("mu", "sigma", "nu", "tau"), ...)

Arguments

formula a gamlss object

x a gamlss object

object a gamlss object

what for which parameter to extract the model.frame, terms or model.frame

... for extra arguments

Details

Value

a model.frame, a model.matrix or terms

Note

Author(s)

Mikis Stasinopoulos

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 82: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

82 Mums

See Also

gamlss

Examples

data(aids)mod<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #model.frame(mod)model.matrix(mod)terms(mod, "mu")rm(mod)

Mums Mothers encouragement data

Description

Mothers encouragement for participation in Higher Education. The response variable ismumsathree level factor which can be used in a multinomial Logistic model or mumsB a two level factorsuitable for binary logistic model.

Usage

data(Mums)

Format

A data frame with 871 observations on the following 7 variables.

mums mothers encouragement: factor with levels1 is for strong encouragement,2 is for someencouragement and3 for no encouragement/discouragement

class social class: a factor with levels1is C1,2 is C2,3 is D and4 is E

age age of the participants: a factor with levels1 is 16-18,2 is 19-20 and3 is 20-30

gender a factor with levels1 is male and2 is female

ethn ethnicity of the participants: a factor with levels1 is white, 2 is black,3 is asian and4 isother

qual qualifications of the participants: a factor with levels,1 is greater or equal to 2 A levels,2is HND or more than 5 GCSE’s,3 is less than 5 GSCSE’s ar none above and4 no formalqualification

mumsb mothers encouragement: a factor with levels,0 is no encouragement or some encourage-ment1 is for strong encouragement

Details

The data were collected as part of the Social Class and widening Participation in Higher Educa-tion Project based at the University of North London (now London Metropolitan University) andsupported by the University’s Development and Diversity Fund over the period 1998-2000.

Source

Professor Robert Gilchrist director of STORM at London Metropolitan

Page 83: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

NBII 83

References

Collier T., Gilchrist R. and Phillips D. (2003), Who Plans to Go to University? Statistical Modellingof potential Working-Class Participants, Education Research and Evaluation, Vol 9, No 3, pp 239-263.

Examples

data(Mums)MM<-xtabs(~mums+qual, data=Mums)mosaicplot(MM, color=TRUE)MM<-xtabs(~mums+ethn+gender, data=Mums)mosaicplot(MM, color=TRUE)

NBII Negative Binomial type II distribution for fitting a GAMLSS

Description

TheNBII() function defines the Negative Binomial type II distribution, a two parameter distribu-tion, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() .The functionsdNBII , pNBII , qNBII andrNBII define the density, distribution function, quan-tile function and random generation for the Negative Binomial type II,NBII() , distribution.

Usage

NBII(mu.link = "log", sigma.link = "log")dNBII(y, mu = 1, sigma = 1, log = FALSE)pNBII(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qNBII(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)rNBII(n, mu = 1, sigma = 1)

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y vector of (non-negative integer) quantiles

mu vector of positive means

sigma vector of positive despersion parameter

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Page 84: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

84 NBII

Details

Definition file for Negative Binomial type II distribution.

f(y|µ, σ) =Γ(y + (µ/σ))σy

Γ(µ/σ)Γ(y + 1)(1 + σ)y+(µ/σ)

for y = 0, 1, 2, ...,∞, µ > 0 andσ > 0. This parameterization was used by Evans (1953) ans alsoby Johnsonet al (1993) p 200.

Value

returns agamlss.family object which can be used to fit a Negative Binomial type II distributionin thegamlss() function.

Note

µ is the mean and[(1 + σ)µ]0.5 is the standard deviation of the Negative Binomial type II distribu-tion, soσ is a dispersion parameter

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

Evans, D. A. (1953). Experimental evidence concerning contagious distributions in ecology.Biometrika,40: 186-211.

Johnson, N. L., Kotz, S. and Kemp, A. W. (1993).Univariate Discrete Distributions, 2nd edn.Wiley, New York.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , NBII , PIG, SI

Examples

NBII() # gives information about the default links for the Negative Binomial type II distributiondata(aids)h<-gamlss(y~cs(x,df=7)+qrt, family=NBII, data=aids) # fits a modelplot(h)# plotting the distributionplot(function(y) dNBII(y, mu = 10, sigma = 0.5 ), from=0, to=40, n=40+1, type="h")pdf.plot(family=NBII, mu=10, sigma=0.5, min=0, max=40, step=1)# creating random variables and plot themtN <- table(Ni <- rNBII(1000, mu=5, sigma=0.5))r <- barplot(tN, col='lightblue')rm(h, tN, r)

Page 85: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

NBI 85

NBI Negative Binomial type I distribution for fitting a GAMLSS

Description

TheNBI() function defines the Negative Binomial type I distribution, a two parameter distribution,for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . ThefunctionsdNBI , pNBI , qNBI andrNBI define the density, distribution function, quantile functionand random generation for the Negative Binomial type I,NBI() , distribution.

Usage

NBI(mu.link = "log", sigma.link = "log")dNBI(y, mu = 1, sigma = 1, log = FALSE)pNBI(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qNBI(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)rNBI(n, mu = 1, sigma = 1)

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y vector of (non-negative integer) quantiles

mu vector of positive means

sigma vector of positive despersion parameter

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Details

Definition file for Negative Binomial type I distribution.

f(y|µ, σ) =Γ(y + 1/σ)

Γ(y + 1)Γ(1/σ)

[(µσ)y

(µσ + 1)

]y+(1/σ)

for y = 0, 1, 2, . . . ,∞, µ > 0 andσ > 0. This parameterization is equivalent to that used byAnscombe (1950) except he usedα = 1/σ instead ofσ.

Value

returns agamlss.family object which can be used to fit a Negative Binomial type I distributionin thegamlss() function.

Warning

For values ofσ < 0.0001 the d,p,q,r functions switch to the Poisson distribution

Page 86: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

86 NET

Note

µ is the mean and(µ+σµ2)0.5 is the standard deviation of the Negative Binomial type I distribution(soσ is the dispersion parameter in the usual GLM for the negative binomial type I distribution)

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

Anscombe, F. J. (1950) Sampling theory of the negative bimomial and logarithmic distributiona,Biometrika, 37, 358-382.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , NBII , PIG, SI

Examples

NBI() # gives information about the default links for the Negative Binomial type I distributiondata(aids)h<-gamlss(y~cs(x,df=7)+qrt, family=NBI, data=aids) # fits the modelplot(h)# plotting the distributionplot(function(y) dNBI(y, mu = 10, sigma = 0.5 ), from=0, to=40, n=40+1, type="h")pdf.plot(family=NBI, mu=10, sigma=0.5, min=0, max=40, step=1)# creating random variables and plot themtN <- table(Ni <- rNBI(1000, mu=5, sigma=0.5))r <- barplot(tN, col='lightblue')rm(h, tN, r)

NET Normal Exponential t distribution (NET) for fitting a GAMLSS

Description

This function defines the Power Exponential t distribution (NET), a four parameter distribution, fora gamlss.family object to be used for a GAMLSS fitting using the functiongamlss() . ThefunctionsdNET, pNETdefine the density and distribution function the NET distribution.

Usage

NET(mu.link = "identity", sigma.link = "log")pNET(q, mu = 5, sigma = 0.1, nu = 1, tau = 2)dNET(y, mu = 0, sigma = 1, nu = 1.5, tau = 2, log = FALSE)

Page 87: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

NET 87

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "inverse" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector ofnu parameter values

tau vector oftau parameter values

log logical; if TRUE, probabilities p are given as log(p).

Details

The NET distribution was introduced by Rigby and Stasinopoulos (1994) as a robust distribution fora response variable with heavier tails than the normal. The NET distribution is the abbreviation ofthe Normal Exponential Student t distribution. The NET distribution is a four parameter continuousdistribution, although in the GAMLSS implementation only the two parameters,muandsigma ,of the distribution are modelled withnu andtau fixed. The distribution takes its names becauseit is normal up tonu , Exponential fromnu to tau (henceabs(nu)<=abs(tau) ) and Student-twith nu*tau-1 degrees of freedom aftertau . Maximum likelihood estimator of the third andforth parameter can be obtained, using the GAMLSS functions,find.hyper or prof.dev .

Value

NET() returns agamlss.family object which can be used to fit a Box Cox Power Exponentialdistribution in thegamlss() function.dNET() gives the density,pNET() gives the distributionfunction.

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

Rigby, R. A. and Stasinopoulos, D. M. (1994), Robust fitting of an additive model for varianceheterogeneity,COMPSTAT : Proceedings in Computational Statistics, editors:R. Dutter and W.Grossmann, pp 263-268, Physica, Heidelberg.

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

Stasinopoulos D. M. Rigby R. A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , BCPE

Page 88: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

88 NO

Examples

NET() #data(abdom)# fit NET with nu=1 and tau=3h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=NET,

data=abdom, nu.start=2, tau.start=3)plot(h)rm(h)plot(function(x)dNET(x, mu=0,sigma=1,nu=2, tau=3), -5, 5)plot(function(x)pNET(x, mu=0,sigma=1,nu=2, tau=3), -5, 5)

NO Normal distribution for fitting a GAMLSS

Description

The functionNO() defines the normal distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() , with mean equal to the param-etermuandsigma equal the standard deviation. The functionsdNO, pNO, qNOandrNO define thedensity, distribution function, quantile function and random generation for theNOparameterizationof the normal distribution. [A alternative parameterization withsigma equal to the variance isgiven in the functionNO.var() ]

Usage

NO(mu.link = "identity", sigma.link = "log")dNO(y, mu = 0, sigma = 1, log = FALSE)pNO(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qNO(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rNO(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Page 89: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

NO 89

Details

The parametrization of the normal distribution given in the functionNO() is

f(y|µ, σ) =1√2πσ

exp[−1

2(y − µ

σ)2]

for y = (−∞,∞), µ = (−∞,+∞) andσ > 0.

Value

returns agamlss.family object which can be used to fit a normal distribution in thegamlss()function.

Note

For the functionNO() , µ is the mean andσ is the standard deviation (not the variance) of thenormal distribution.

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , NO.var

Examples

NO()# gives information about the default links for the normal distributiondat<-rNO(100)gamlss(dat~1,family=NO) # fits a constant for mu and sigmaplot(function(y) dNO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) pNO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) qNO(y, mu=10 ,sigma=2), 0, 1)

Page 90: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

90 NO.var

NO.var Normal distribution (with variance as sigma parameter) for fitting aGAMLSS

Description

The functionNO.var() defines the normal distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() with mean equal tomuand vari-ance equal tosigma . The functionsdNO.var , pNO.var , qNO.var andrNO.var define thedensity, distribution function, quantile function and random generation for this specific parameteri-zation of the normal distribution.

[A alternative parameterization withsigma as the standard deviation is given in the functionNO() ]

Usage

NO.var(mu.link = "identity", sigma.link = "log")dNO.var(y, mu = 0, sigma = 1, log = FALSE)pNO.var(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qNO.var(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rNO.var(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The parametrization of the normal distribution given in the functionNO.var() is

f(y|µ, σ) =1√2πσ

exp[−1

2(y − µ)2

σ

]for y = (−∞,∞), µ = (−∞,+∞) andσ > 0.

Value

returns agamlss.family object which can be used to fit a normal distribution in thegamlss()function.

Page 91: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

par.plot 91

Note

For the functionNO() , µ is the mean andσ is the standard deviation (not the variance) of the normaldistribution. [The functionNO.var() defines the normal distribution withσ as the variance.]

Author(s)

Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

NO()# gives information about the default links for the normal distributiondat<-rNO(100)gamlss(dat~1,family=NO) # fits a constant for mu and sigmaplot(function(y) dNO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) pNO(y, mu=10 ,sigma=2), 0, 20)plot(function(y) qNO(y, mu=10 ,sigma=2), 0, 1)

par.plot A function to plot parallel plot for repeated measurement data

Description

This function can be used to plot parallel plots for each individual in a repeated measurement study.It is based on thecoplot() function ofR.

Usage

par.plot(formula = NULL, data = NULL, subjects = NULL,color = TRUE, show.given = TRUE, ...)

Arguments

formula a formula describing the form of conditioning plot. A formula of the formy ~x | a indicates that plots ofy versusx should be produced conditional on thevariablea. A formula of the formy ~ x| a * b indicates that plots ofyversusx should be produced conditional on the two variablesa andb.

data a data frame containing values for any variables in the formula. By default theenvironment wherepar.plot was called from is used.

Page 92: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

92 par.plot

subjects a factor which distinguish between the individual participants

color whether the parallel plot are shown in colour,color=TRUE (the default) or notcolor=FALSE

show.given logical (possibly of length 2 for 2 conditioning variables): should conditioningplots be shown for the corresponding conditioning variables (default ’TRUE’)

... for extra arguments

Details

Value

It returns a plot.

Note

Note that similar plot can be fount in the librarynlme by Pinheiro and Bates

Author(s)

Mikis Stasinopoulos〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss

Examples

library(nlme)data(Orthodont)par.plot(distance~age,data=Orthodont,sub=Subject)par.plot(distance~age|Sex,data=Orthodont,sub=Subject)par.plot(distance~age|Subject,data=Orthodont,sub=Subject,show.given=FALSE)

Page 93: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

pdf.plot 93

pdf.plot Plots Probability Distribution Functions for GAMLSS Family

Description

A function to plot probability distribution functions (pdf) belonging to the gamlss family of distri-butions. This function allows either plotting of the fitted distributions for up to eight observationsor plotting specified distributions belonging in the gamlss family

Usage

pdf.plot(obj = NULL, obs = c(1), family = NO(), mu = NULL,sigma = NULL, nu = NULL, tau = NULL, min = NULL,max = NULL, step = NULL, allinone = FALSE,no.title = FALSE, ...)

Arguments

obj An gamlss object e.g.obj=model1 where model1 is a fitted gamlss object

obs A number or vector of up to length eight indicating the case numbers of the ob-servations for which fitted distributions are to be displayed, e.g.obs=c(23,58)will display the fitted distribution for the 23th and 58th observations

family This must be a gamlss family i.e.family=NO

mu The value(s) of the location parameter mu for which the distribution has to beevaluated e.gmu=c(3,7)

sigma The value(s) the scale parameter sigma for which the distribution has to be eval-uated e.gsigma=c(3,7)

nu The value(s) the parameter nu for which the distribution has to be evaluated e.g.nu=3

tau The value(s) the parameter tau for which the distribution has be evaluated e.g.tau=5

min Minimum value of the random variable y e.g.min=0

max Maximum value of y e.g.max=10

step Steps for the evaluation of y e.g.step=0.5

allinone This will go

no.title Whether you need title in the plot, default isno.title=FALSE

... for extra arguments

Details

This function can be used to plot distributions of the GAMLSS family. If the first argumentobjis specified and it is a GAMLSS fitted object, then the fitted distribution of this model at specifiedobservation values (given by the second argumentobs ) is plotted for a specified y-variable range(argumentsmin , max, andstep ).

If the first argument is not given then thefamily argument has to be specified and the pdf is plottedat specified values of the parametersmu, sigma , nu , tau . Again the range of the y-variable hasto be given.

Page 94: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

94 PE

Value

plot(s) of the required pdf(s) are returned

Warning

The range of some distributions depends on the fitted parameters

Note

The range of the y values given by min, max and step are very important in the plot

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss

Examples

pdf.plot(family=BCT, min=1, max=20, step=.05, mu=10, sigma=0.15, nu=-1, tau=c(4,10,20,40) )# now using an gamlss objectdata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom) # fitspdf.plot(obj=h , obs=c(23,67), min=50, max=150, step=.5)rm(h)

PE Power Exponential distribution for fitting a GAMLSS

Description

This function defines the Power Exponential distribution, a three parameter distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . ThefunctionsdPE, pPE, qPE andrPE define the density, distribution function, quantile function andrandom generation for the specific parameterization of the power exponential distribution.

Usage

PE(mu.link = "identity", sigma.link = "log", nu.link = "log")dPE(y, mu = 0, sigma = 1, nu = 2, log = FALSE)pPE(q, mu = 0, sigma = 1, nu = 2, lower.tail = TRUE, log.p = FALSE)qPE(p, mu = 0, sigma = 1, nu = 2, lower.tail = TRUE, log.p = FALSE)rPE(n, mu = 0, sigma = 1, nu = 2)

Page 95: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

PE 95

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

nu.link Defines thenu.link , with "log" link as the default for the nu parameter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of kurtosis parameter

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

Power Exponential distribution is defined as

f(y|µ, σ, ν) =ν exp[−( 1

2 )| zc |ν ]

σc2(1+1/ν)Γ( 1ν )

wherec = [2−2/νΓ(1/ν)/Γ(3/ν)]0.5, for y = (−∞,+∞), µ = (−∞,+∞), σ > 0 andν > 0.This parametrization was used by Nelson (1991) and ensuresµ is the mean andσ is the standarddeviation of y (for all parameter values ofµ, σ andν within the rages above)

Value

returns agamlss.family object which can be used to fit a Power Exponential distribution in thegamlss() function.

Note

µ is the mean andσ is the standard deviation of the Power Exponential distribution

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

Nelson, D.B. (1991) Conditional heteroskedasticity in asset returns: a new approach.Econometrica,57, 347-370.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 96: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

96 PIG

See Also

gamlss , gamlss.family

Examples

PE()# gives information about the default links for the Power Exponential distributiondata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=PE, data=abdom) # fitsplot(h)rm(h)# leptokurtoticplot(function(x) dPE(x, mu=10,sigma=2,nu=1), 0.0, 20,

main = "The PE density mu=10,sigma=2,nu=1")# platykurtoticplot(function(x) dPE(x, mu=10,sigma=2,nu=4), 0.0, 20,

main = "The PE density mu=10,sigma=2,nu=4")

PIG The Poisson-inverse Gaussian distribution for fitting a GAMLSS model

Description

The PIG() function defines the Poisson-inverse Gaussian distribution, a two parameter distribu-tion, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() .The functionsdPIG , pPIG , qPIG and rPIG define the density, distribution function, quantilefunction and random generation for the Poisson-inverse GaussianPIG() , distribution.

Usage

PIG(mu.link = "log", sigma.link = "log")dPIG(y, mu = 0.5, sigma = 0.02, log = FALSE)pPIG(q, mu = 0.5, sigma = 0.02, lower.tail = TRUE, log.p = FALSE)qPIG(p, mu = 0.5, sigma = 0.02, lower.tail = TRUE, log.p = FALSE,

max.value = 10000)rPIG(n, mu = 0.5, sigma = 0.02)

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

y vector of (non-negative integer) quantiles

mu vector of positive means

sigma vector of positive despersion parameter

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

max.value a constant, set to the default value of 10000 for how far the algorithm shouldlook for q

Page 97: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

PIG 97

Details

The probability function of the Poisson-inverse Gaussian distribution, is given by

f(y|µ, σ) =

(2α

π

12

)µye

1σ Ky− 1

2(α)

(ασ)yy!

whereα2 = 1σ2 + 2µ

σ , for y = 0, 1, 2, ...,∞whereµ > 0 andσ > 0 andKλ(t) = 12

∫∞0

xλ−1 exp− 12 t(x+

x−1)dx is the modified Bessel function of the third kind. [Note that the above parameterizationwas used by Dean, Lawless and Willmot(1989). It is also a special case of the Sichel distributionSI() whenν = − 1

2 .]

Value

Returns agamlss.family object which can be used to fit a Poisson-inverse Gaussian distributionin thegamlss() function.

Note

Author(s)

References

Dean, C., Lawless, J. F. and Willmot, G. E., A mixed poisson-inverse-Gaussian regression model,Canadian J. Statist., 17, 2, pp 171-181

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , NBI , NBII , SI

Examples

PIG()# gives information about the default links for the Poisson-inverse Gaussian distribution#plot the pdf using plotplot(function(y) dPIG(y, mu=10, sigma = 1 ), from=0, to=50, n=50+1, type="h") # pdf# plot the cdfplot(seq(from=0,to=50),pPIG(seq(from=0,to=50), mu=10, sigma=1), type="h") # cdf# generate random sampletN <- table(Ni <- rPIG(100, mu=5, sigma=1))r <- barplot(tN, col='lightblue')# fit a model to the datagamlss(Ni~1,family=PIG)

Page 98: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

98 plot.gamlss

plot.gamlss Plot Residual Diagnostics for an GAMLSS Object

Description

This function provides four plots for checking the normalized (randomized for a discrete responsedistribution) quantile residuals of a fitted GAMLSS object, referred to as residuals below : a plotof residuals against fitted values, a plot of the residuals against an index or a specific explana-tory variable, a density plot of the residuals and a normal Q-Q plot of the residuals. If argumentts=TRUE then the first two plots are replaced by the autocorrelation function (ACF) and partialautocorrelation function (PACF) of the residuals

Usage

plot.gamlss(x, xvar = NULL, parameters = NULL, ts = FALSE,summaries = TRUE, ...)

Arguments

x a GAMLSS fitted object

xvar an explanatory variable to plot the residuals against

parameters plotting parameters can be specified here

ts set this to TRUE if ACF and PACF plots of the residuals are required

summaries set this to FALSE if no summary statistics of the residuals are required

... further arguments passed to or from other methods.

Details

This function provides four plots for checking the normalized (randomized) quantile residuals(calledresiduals ) of a fitted GAMLSS object. Randomization is only performed for discreteresponse variables. The four plots are

• residuals against the fitted values (or ACF of the residuals ifts=TRUE )

• residuals against an index or specified x-variable (or PACF of the residuals ifts=TRUE )

• kernel density estimate of the residuals

• QQ-normal plot of the residuals

For time series response variables optionts=TRUE can be used to plot the ACF and PACF functionsof the residuals.

Value

Returns four plots related to the residuals of the fitted GAMLSS model and prints summary statisticsfor the residuals if thesummary=T

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Kalliope Akantziliotou

Page 99: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

polyS 99

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss

Examples

data(aids)a<-gamlss(y~cs(x,df=7)+qrt,family=PO,data=aids)plot(a)rm(a)

polyS Auxiliary support for the GAMLSS

Description

These two functions are similar to thepoly andpolym in R. Are needed for thegamlss.lofunction of GAMLSS and should not be used on their own.

Usage

polyS(x, ...)poly.matrix(m, degree = 1)

Arguments

x a variable

m a variable

degree the degree of the polynomial

... for extra arguments

Value

Returns a matrix of orthogonal polynomials

Warning

Not be use by the user

Author(s)

Mikis Stasinopoulos〈[email protected]

Page 100: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

100 PO

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.lo

PO Poisson distribution for fitting a GAMLSS model

Description

This functionPOdefines the Poisson distribution, an one parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The functionsdPO, pPO, qPOandrPO define the density, distribution function, quantile function and random generation for thePoisson,PO() , distribution.

Usage

PO(mu.link = "log")dPO(y, mu = 1, log = FALSE)pPO(q, mu = 1, lower.tail = TRUE, log.p = FALSE)qPO(p, mu = 1, lower.tail = TRUE, log.p = FALSE)rPO(n, mu = 1)

Arguments

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

y vector of (non-negative integer) quantiles

mu vector of positive means

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Details

Definition file for Poisson distribution.

f(y|µ) =e−µµy

Γ(y + 1)

for y = 0, 1, 2, ... andµ > 0.

Page 101: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

predict.gamlss 101

Value

returns agamlss.family object which can be used to fit a Poisson distribution in thegamlss()function.

Note

µ is the mean of the Poisson distribution

Author(s)

Bob Rigby〈[email protected]〉, Mikis Stasinopoulos〈[email protected]〉,and Kalliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

PO()# gives information about the default links for the Poisson distribution# fitting data using PO()data(aids)h<-gamlss(y~cs(x,df=7)+qrt, family=PO, data=aids) # fits the constant+x+qrt modelplot(h)# plotting the distributionplot(function(y) dPO(y, mu=10 ), from=0, to=20, n=20+1, type="h")pdf.plot(family=PO, mu=10, min=0, max=20, step=1)# creating random variables and plot themtN <- table(Ni <- rPO(1000, mu=5))

r <- barplot(tN, col='lightblue')rm(h, tN, r)

predict.gamlss Extract Predictor Values and Standard Errors For New Data In AGAMLSS Model

Description

predict.gamlss is the GAMLSS specific method which produce predictors for a new dataset for a specified parameter from a GAMLSS objects. Thepredict.gamlss can be used toextract the linear predictors, fitted values and specific terms in the model at new data values in thesame way that thepredict.lm() andpredict.glm() functions can be used forlm or glmobjects. Note that linear predictors, fitted values and specific terms in the model at the current datavalues can also be extracted using the functionlpred() (which is called from predict if new datais NULL).

Page 102: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

102 predict.gamlss

Usage

predict.gamlss(object, what = c("mu", "sigma", "nu", "tau"),newdata = NULL, type = c("link", "response", "terms"),terms = NULL, se.fit = FALSE, data = NULL, ...)

Arguments

object a GAMLSS fitted model

what which distribution parameter is required, defaultwhat="mu"

newdata a data frame containing new values for the explanatory variables used in themodel

type the default, gets the linear predictor for the specified distribution parameter.type="response" gets the fitted values for the parameter whiletype="terms"gets the fitted terms contribution

terms if type="terms" , which terms to be selected (default is all terms)

se.fit if TRUE the approximate standard errors of the appropriate type are extracted ifexist

data the data frame used in the original fit if is not defined in the call

... for extra arguments

Details

The predict function assumes that the object given innewdata is a data frame containing theright x-variables used in the model. This could possible cause problems if transformed vari-ables are used in the fitting of the original model. For example, let us assume that a transfor-mation of age is needed in the model i.e.nage<-age^.5 . This could be fitted asmod<-gamlss(y~cs(age^.5),data=mydata) or asnage<-age^.5; mod<-gamlss(y~cs(nage),data=mydata) . The later could more efficient if the data are in thousands rather in hundreds. Inthe first case, the codepredict(mod,newdata=data.frame(age=c(34,56))) wouldproduce the right results. In the second case a new data frame has to be created containing the olddata plus any new transform data. This data frame has to be declared in thedata option. Theoption newdata should contain a data.frame with the new names and the transformed values inwhich prediction is required, (see the last example).

Value

A vector or a matrix depending on the options.

Note

This function is under development

Author(s)

Mikis Stasinopoulos

Page 103: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

print.gamlss 103

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

lp , lpred

Examples

data(aids)a<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #newaids<-data.frame(x=c(45,46,47), qrt=c(2,3,4))ap <- predict(a, newdata=newaids, type = "response")aprm(a, ap)data(abdom)# transform xaa<-gamlss(y~cs(x^.5),data=abdom)# predict at old valuespredict(aa)[610]# predict at new valuespredict(aa,newdata=data.frame(x=42.43))# now transform x firstnx<-abdom$x^.5aaa<-gamlss(y~cs(nx),data=abdom)# create a new data framenewd<-data.frame( abdom, nx=abdom$x^0.5)# predict at old valuespredict(aaa)[610]# predict at new valuespredict(aaa,newdata=data.frame(nx=42.43^.5), data=newd)

print.gamlss Prints a GAMLSS fitted model

Description

print.gamlss is the GAMLSS specific method for the generic functionprint which printsobjects returned by modelling functions.

Usage

print.gamlss(x, digits = max(3, getOption("digits") - 3), ...)

Arguments

x a GAMLSS fitted model

digits the number of significant digits to use when printing

... for extra arguments

Page 104: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

104 prof.dev

Details

Value

Prints a gamlss object

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , deviance.gamlss , fitted.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids)print(h) # or just hrm(h)

prof.dev Plotting the Profile Deviance for one of the Parameters in a GAMLSSmodel

Description

This functions plots the profile deviance of one of the (four) parameters in a GAMLSS model. It canbe used if one of the parametersmu, sigma , nu or tau is a constant (not a function of explanatoryvariables) to obtain a profile confidence intervals.

Usage

prof.dev(object, which = NULL, min = NULL, max = NULL, step = NULL,startlastfit = TRUE, type = "o", plot = TRUE, perc = 95,...)

Page 105: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

prof.dev 105

Arguments

object A fitted GAMLSS model

which which parameter to get the profile deviance e.g.which="tau"

min the minimum value for the parameter e.g.min=1

max the maximum value for the parameter e.g.max=20

step how often to evaluate the global deviance (defines the step length of the grid forthe parameter) e.g.step=1

startlastfit whether to start fitting from the last fit or not, default value isstartlastfit=TRUE

type what type of plot required. This is the same as intype for plot , default valueis type="o" , that is, both line and points

plot whether to plot,plot=TRUE or save the results,plot=FALSE

perc what % confidence interval is required

... for extra arguments

Details

This function can be use to provide likelihood based confidence intervals for a parameter for whicha constant model (i.e. no explanatory model) is fitted and consequently for checking the adequacy ofa particular values of the parameter. This can be used to check the adequacy of one distribution (e.g.Box-Cox Cole and Green) nested within another (e.g. Box-Cox power exponential). For exampleone can test whether a Box-Cox Cole and Green (Box-Cox-normal) distribution or a Box-Coxpower exponential is appropriate by plotting the profile of the parametertau . A profile devianceshowing support fortau=2 indicates adequacy of the Box-Cox Cole and Green (i.e. Box-Coxnormal) distribution.

Value

A plot of profile global deviance

Warning

A dense grid (i.e. small step) evaluation of the global deviance can take a long time, so start with asparse grid (i.e. large step) and decrease gradually the step length for more accuracy.

Author(s)

Calliope Akantziliotou, Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , prof.term

Page 106: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

106 prof.term

Examples

data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom)prof.dev(h,"nu",min=-2.000,max=2,step=0.25,type="l")rm(h)

prof.term Plotting the Profile: deviance or information criterion for one of theterms (or hyper-parameters) in a GAMLSS model

Description

This functions plots the profile deviance for a chosen parameter included in the linear predictor ofany of themu, sigma , nu or tau models so profile confidence intervals can be obtained. In canalso be used to plot the profile of a specified information criterion for any hyperparameter.

Usage

prof.term(model = NULL, criterion = "GD", penalty = 2.5, other = NULL,min = NULL, max = NULL, step = NULL, type = "o", xlabel = NULL,plot = TRUE, term = TRUE, perc = 95, ... )

Arguments

model this is a GAMLSS model, e.g.model=gamlss(y~cs(x,df=this),sigma.fo=~cs(x,df=3),data=abdom) ,wherethis indicates the (hyper)parameter to be profiled

criterion whether global deviance ("GD") or information criterion ("IC") is profiled. Thedefault iscriterion="GD"

penalty The penalty value if information criterion is used incriterion , defaultpenalty=2.5

other this can be used to evaluate an expression before the actual fitting of the model

min the minimum value for the parameter e.g.min=1

max the maximum value for the parameter e.g.max=20

step how often to evaluate the global deviance (defines the step length of the grid forthe parameter) e.g.step=1

type what type of plot required. This is the same as intype for plot , default valueis type="o" , that is, both line and points

xlabel if a label for the axis is required

plot whether to plot,plot=TRUE or save the results,plot=FALSE

term this has the value TRUE and it should be changed to FALSE if a profile globaldeviance is required for a hyperparameter so the IC are suppressed

perc what % confidence interval is required

... for extra arguments

Page 107: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

prof.term 107

Details

This function can be use to provide likelihood based confidence intervals for a parameter involved interms in the linear predictor(s). These confidence intervals are more accurate than the ones obtainedfrom the parameters’ standard errors. The function can also be used to plot a profile informationcriterion (with a given penalty) against a hyperparameter. This can be used to check the uniquenessin hyperparameter determination using for examplefind.df .

Value

Return a profile plot (if the argumentplot=TRUE ) or the values of the parameters and the IC orGD values otherwise

Warning

A dense grid (i.e. small step) evaluation of the global deviance can take a long time, so start with asparse grid (i.e. large step) and decrease gradually the step length for more accuracy.

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , prof.dev

Examples

data(aids)gamlss(y~x+qrt,family=NBI,data=aids)mod<-quote(gamlss(y ~ offset(this * x) + qrt, data = aids, family = NBI))prof.term(mod, min=0.06, max=0.11, step=0.001)mod1<-quote(gamlss(y ~ cs(x,df=this) + qrt, data = aids, family = NBI))prof.term(mod1, min=1, max=15, step=1, criterion="IC")mod2 <- quote(gamlss(y ~ x+I((x>this)*(x-this))+qrt,family=NBI,data=aids))prof.term(mod2, min=1, max=45, step=1, criterion="GD")rm(mod,mod1,mod2)

Page 108: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

108 ps

ps Specify a Penalised Spline Fit in a GAMLSS Formula

Description

The function takes a vector and returns it with several attributes. The vector is used in the con-struction of the model matrix. The functionps() does no smoothing, but assigns the attributes tothe vector to aid gamlss in the smoothing. The function doing the smoothing isgamlss.cs () (amodified version of the R functionsmooth.spline() ) which is used at the backfitting functionadditive.fit .

Usage

ps(x, df = 3, lambda = NULL, ps.intervals = 20, degree = 3, order = 3)

Arguments

x the univariate predictor, (or expression, that evaluates to a numeric vector).

df the desired equivalent number of degrees of freedom (trace of the smoother ma-trix minus two for the constant and linear fit

lambda the smoothing parameter,

ps.intervals the no of break points in the x-axis

degree the degree of the piecewise polynomial

order the difference in the coefficients

Details

Theps() function is based on Brian Marx function which can be found inhttp://www.stat.lsu.edu/faculty/marx/

Value

the vector x is returned, endowed with a number of attributes. The vector itself is used in theconstruction of the model matrix, while the attributes are needed for the backfitting algorithmsadditive.fit() .

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

http://www.stat.lsu.edu/faculty/marx/

Eilers, P. H. C. and Marx, B. D. (1996). Flexible smoothing with B-splines and penalties (withcomments and rejoinder).Statist. Sci, 11, 89-121.

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

Page 109: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

Q.stats 109

See Also

gamlss , gamlss.ps , cs

Examples

data(aids)attach(aids)# fitting a smoothing cubic spline with 7 degrees of freedom# plus the a quarterly effectaids1<-gamlss(y~ps(x,df=7)+qrt,data=aids,family=PO) #plot(x,y)lines(x,fitted(aids1))rm(aids1)detach(aids)

Q.stats A function to calculate the Q-statistics

Description

This function calculates and prints the Q-statistics which are useful to test normality of the residualswithin a range of an independent variable, for example age in centile estimation, see Royston andWright (2000).

Usage

Q.stats(obj, xvar = NULL, xcut.points = NULL, n.inter = 10, zvals = TRUE,save = TRUE, ...)

Arguments

obj a GAMLSS object or any other residual vector

xvar a unique explanatory variable

xcut.points the x-axis cut off points e.g.c(20,30) . If xcut.points=NULL then then.inter argument is activated

n.inter if xcut.points=NULL this argument gives the number of intervals in whichthe x-variable will be split, with default 4

zvals if TRUEthe output matix contains the individual z’s rather that Q statistics

save whether to save the Q-statistics or not with default equal toTRUE. In this casethe functions produce a matrix giving individual Q (or z) statistics and the finalaggregate Q’s

... for extra arguments

Details

Value

A matrix containing the individual Q’s and the aggregate Q-statistics

Page 110: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

110 random

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉,with contributions from Elaine Borghie

References

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

Royston P. and Wright E. M. (2000) Goodness of fit statistics for the age-specific reference intervals.Statistics in Medicine, 19, pp 2943-2962.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , centiles.split , wp

Examples

data(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=BCT, data=abdom)Q.stats(h,xvar=abdom$x,n.inter=8)Q.stats(h,xvar=abdom$x,n.inter=8,zvals=FALSE)rm(h)

random Specify a simple random effect in a GAMLSS Formula

Description

Includes random effect terms in an GAMLSS model.

Usage

random(xvar, df = NULL, lambda = 0)

Arguments

xvar a factor

df the target degrees of freedom

lambda the smoothing parameter lambda which can be viewed as a shrinkage parameter.

Page 111: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

random 111

Details

This is an experimental smoother for use with factors in gamlss(). It allows the fitted values fora factor predictor to be shrunk towards the overall mean, where the amount of shrinking dependseither on lambda, or on the equivalent degrees of freedom. Similar in spirit to smoothing splines,this fitting method can be justified on Bayesian grounds or by a random effects model.

Since factors are coded by model.matrix() into a set of contrasts, care has been taken to add anappropriate "contrast" attribute to the output of random(). This zero contrast results in a column ofzeros in the model matrix, which is aliased with any column and is hence ignored

Value

x is returned with class "smooth", with an attribute named "call" which is to be evaluated in thebackfittingadditive.fit() called bygamlss()

Author(s)

Trevor Hastie (amended by Mikis Stasinopoulos)

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.random

Examples

data(aids)attach(aids)# fitting a loess curve with span=0.4 plus the a quarterly effectaids1<-gamlss(y~lo(x,span=0.4)+qrt,data=aids,family=PO) ## now we string the quarterly effect using randomaids2<-gamlss(y~lo(x,span=0.4)+random(qrt,df=2),data=aids,family=PO) #plot(x,y)lines(x,fitted(aids1),col="red")lines(x,fitted(aids2),col="purple")rm(aids1,aids2)detach(aids)

Page 112: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

112 ra

ra Specify Simple Random Effect In A GAMLSS Formula

Description

This is an experimental smoother for use with factors in gamlss(). It allows the fitted values fora factor predictor to be shrunk towards the overall mean, where the amount of shrinking dependseither on lambda, or on the equivalent degrees of freedom (df).

This function is slightly more general, but considerably slower than therandom function .

Usage

ra(xfactor, xvector = NULL, df = NULL, lambda = NULL, order = 0,estimate = FALSE, expl = NULL, data1 = NULL)

Arguments

xfactor a factor defining the subjects grouping in a one factor random effect model terme.g.xfactor=Subjects

xvector a variable if interaction with thexfactor is requiredxvector (experimental)

df required equivalent degrees of freedom e.g.df=10

lambda the smoothing parameter which is the reciprocal (i.e. inverse) of the variance ofthe random effect

order the order of the difference in the matrix D,order=1 is for simple randomeffects,order=2 is for random walk order 1 andorder=3 is for randomwalk order 2

estimate whether to estimate the lambda parameter within the backfitting iterations (veryunreliable). Set by default toestimate=FALSE . [The lambda parameter canbe more accurately estimated by selecting the corresponding smoothing degreesof freedom usingfind.hyper ]

expl this allows an explanatory variable at the subject level to be fitted e.g.expl=~x1+x2

data1 the data frame for the subject level variablesdata1

Details

Value

xfactor is returned with class "smooth", with an attribute named "call" which is to be evaluated inthe backfittingadditive.fit() called bygamlss()

Warning

This is experimental and likely to change soon

Note

Page 113: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

rc 113

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

random , gamlss

Examples

data(aids)attach(aids)# fitting a loess curve with span=0.4 plus the a quarterly effectaids1<-gamlss(y~lo(x,span=0.4)+qrt,data=aids,family=PO) ## now we string the quarterly effect using randomaids2<-gamlss(y~lo(x,span=0.4)+ra(qrt,df=2),data=aids,family=PO) #plot(x,y)lines(x,fitted(aids1),col="red")lines(x,fitted(aids2),col="purple")rm(aids1,aids2)detach(aids)

rc Specify Random Coefficients In A GAMLSS Formula

Description

Fits Random Coefficients In A GAMLSS Model.

Usage

rc(formula, lambda = NULL)

Arguments

formula a model formula to specify the explanatory variable and the subject groupingfactor e.g.formula=~x1|Subjects will fit random constant and slopes forx1 for each level of Subjects

lambda a matrix specifying the variance-covariance matrix for the random coefficientse.g. lambda=diag2,5

Details

This is an experimental function and it is likely to change in the near future. For a chosen fixedvariance-covariance matrix for the random coefficients, this function finds the MAP estimates forthe constant and slope random effects for the different subjects

Page 114: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

114 refit

Value

The variables in the left side of the formula are returned with class "smooth", and attribute named"call" which is to be evaluated in the backfittingadditive.fit() called bygamlss()

Warning

This is experimental

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

random , ra , gamlss

Examples

refit Refit a GAMLSS model

Description

This function refits a GAMLSS model. It is useful when the algorithm has not converged after 20outer iteration (the default value)

Usage

refit(object, ...)

Arguments

object a GAMLSS fitted model which has not converged

... for extra arguments

Page 115: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

rent 115

Details

This function is useful when the iterations have reach the maximum value set by the code(n.cyc) ofthegamlss.control function and the model has not converged yet

Value

Returns a GAMLSS fitted model

Note

The functionupdate does a very similar job

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

codegamlss, update.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #refit(h)rm(h)

rent Rent data

Description

A survey was conducted in April 1993 by Infratest Sozialforschung. A random sample of accommo-dation with new tenancy agreements or increases of rents within the last four years in Munich wasselected including: i) single rooms, ii) small apartments, iii) flats, iv) two-family houses. Accom-modation subject to price control rents, one family houses and special houses, such as penthouses,were excluded because they are rather different from the rest and are considered a separate market.For the purpose of this study, 1967 observations of the variables listed below were used, i.e. the rentresponse variable R followed by the explanatory variables found to be appropriate for a regressionanalysis approach by Fahrmeiret al. (1994, 1995):

Usage

data(rent)

Page 116: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

116 rent

Format

A data frame with 1969 observations on the following 9 variables.

R : rent response variable, the monthly net rent in DM, i.e. the monthly rent minus calculated orestimated utility cost

Fl : floor space in square meters

A : year of construction

Sp : a variable indicating whether the location is above average,1, (550 observations) or not,0,(1419 observations)

Sm : a variable indicating whether the location is below,1, average (172 obs.) or not,0, (1797obs.)

B : a factor with levels indicating whether there is a bathroom,1, (1925 obs.) or not,0, (44 obs.)

H : a factor with levels indicating whether there is central heating,1, (1580 obs.) or not,0, (389obs.)

L : a factor with levels indicating whether the kitchen equipment is above average,1, (161 obs.)or not,0, (1808 obs.)

loc : a factor (combination of Sp and Sm) indicating whether the location is below,1, average,2,or above average3

Details

This set of data were used by Stasinopouloset al. (2000) to fit a model where both the mean andthe dispersion parameter of a Gamma distribution were modelled using the explanatory variables.

Source

Provide by Prof. L. Fahrmeir

References

Fahrmeir L., Gieger C., Mathes H. and Schneeweiss H. (1994) Gutachten zur Erstellung des Miet-spiegels fur Munchen 1994, Teil B: Statistiche Analyse der Nettomieten. Hrsg: LandeshaupttstadtMunchen, Sozialreferat-Amt fur Wohnungswesen.

Fahrmeir L., Gieger C., and Klinger, A. (1995) Additive, dynamic and multiplicative regression. InApplied Statistics: Recent Developments, Vandenhoeck and Ruprecht, Gottingen.

Stasinopoulos, D. M., Rigby, R. A. and Fahrmeir, L., (2000), Modelling rental guide data usingmean and dispersion additive models,Statistician, 49 , 479-493.

Examples

data(rent)attach(rent)plot(Fl,R)

Page 117: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

residuals.gamlss 117

residuals.gamlss Extract Residuals from GAMLSS model

Description

residuals.gamlss is the GAMLSS specific method for the generic functionresidualswhich extracts the residuals for a fitted model. The abbreviated formresid is an alias forresiduals .

Usage

residuals.gamlss(object, what = c("z-scores", "mu", "sigma", "nu", "tau"),type = c("simple", "weighted", "partial"), ...)

Arguments

object a GAMLSS fitted model

what specify whether the standardized residuals are required, called here the "z-scores",or residuals for a specific parameter

type the type of residual if residuals for a parameter are required

... for extra arguments

Details

The "z-scores" residuals saved in a GAMLSS object are the normalized (randomized) quantile resid-uals (see Dunn and Smyth, 1996). Randomization is only needed for the discrete family distribu-tions, see alsorqres.plot . Residuals for a specific parameter can be "simple" = (working vari-able - linear predictor), "weighted"= sqrt(working weights)*(working variable - linear predictor) or"partial"= (working variable - linear predictor)+contribution of specific terms.

Value

a vector or a matrix of the appropriate residuals of a GAMLSS model

Note

The "weighted" residuals of a specified parameter can be zero and one if the square of first derivativehave been used in the fitting of this parameter

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Page 118: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

118 RG

See Also

print.gamlss , summary.gamlss , fitted.gamlss , coef.gamlss , residuals.gamlss ,update.gamlss , plot.gamlss , deviance.gamlss , formula.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=NBI, data=aids) #plot(aids$x,resid(h))plot(aids$x,resid(h,"sigma") )rm(h)

RG The Reverse Gumbel distribution for fitting a GAMLSS

Description

The functionRGdefines the reverse Gumbel distribution, a two parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The functionsdRG, pRG, qRGandrRG define the density, distribution function, quantile function and random generation for thespecific parameterization of the reverse Gumbel distribution.

Usage

RG(mu.link = "identity", sigma.link = "log")dRG(y, mu = 0, sigma = 1, log = FALSE)pRG(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)qRG(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE)rRG(n, mu = 0, sigma = 1)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter.other available link is "log"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other links are the "inverse" and "identity"

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Page 119: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

RG 119

Details

The specific parameterization of the reverse Gumbel distribution used inRGis

f(y|µ, σ) =1σ

exp−(

y − µ

σ

)− exp

[− (y − µ)

σ

]for y = (−∞,∞), µ = (−∞,+∞) andσ > 0.

Value

RG() returns agamlss.family object which can be used to fit a Gumbel distribution in thegamlss() function. dRG() gives the density,pGU() gives the distribution function,qRG()gives the quantile function, andrRG() generates random deviates.

Note

The mean of the distribution isµ + 0.57722σ and the variance isπ2σ2/6.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

plot(function(x) dRG(x, mu=0,sigma=1), -3, 6,main = "Reverse Gumbel density mu=0,sigma=1")

RG()# gives information about the default links for the Gumbel distributiondat<-rRG(100, mu=10, sigma=2) # generates 100 random observationsgamlss(dat~1,family=RG) # fits a constant for each parameter mu and sigma

Page 120: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

120 rqres.plot

rqres.plot Plotting Randomized Quantile Residuals

Description

This function plots QQ-plots of the normalized randomized quantile residuals (see Dunn and Smyth,1996) for a model using a discrete GAMLSS family distribution.

Usage

rqres.plot(obj = NULL, howmany = 6, all = TRUE, save = FALSE, ...)

Arguments

obj a fitted GAMLSS model object from a "discrete" type of family

howmany The number of QQ-plots required up to ten i.e.howmany=6

all if TRUE QQ-plots fromhowmany realizations are plotted. If FALSE then asingle qq-plot of the median of thehowmany realizations is plotted

save If TRUE the median residuals can be saved

... for extra arguments

Details

For discrete family distributions, thegamlss () function saves on exit one realization of ran-domized quantile residuals which can be plotted using the generic functionplot which calls theplot.gamlss . Looking at only one realization can be misleading, so the current function createsQQ-plots for several realizations. The function allows up to 10 QQ-plots to be plotted. Occasion-ally one wishes to create a lot of realizations and then take a median of them (separately for eachordered value) to create a single median realization. The optionall in combinations with the op-tion howmany creates a QQ-plot of the medians of the normalized randomized quantile residuals.These ’median’ randomized quantile residuals can be saved using the option (save=TRUE).

Value

If save it is TRUE then the vector of the median residuals is saved.

Warning

....

Note

Author(s)

Mikis Stasinopoulos〈[email protected]

Page 121: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

SEP 121

References

Dunn, P. K. and Smyth, G. K. (1996) Randomised quantile residuals,J. Comput. Graph. Statist., 5,236–244

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

plot.gamlss , gamlss

Examples

data(aids) # fitting a model from a discrete distributionh<-gamlss(y~cs(x,df=7)+qrt, family=NBI, data=aids) #plot(h)# plot qq- plots from 6 realization of the randomized quantile residualsrqres.plot(h)# a qq-plot from the medians from 40 realizationsrqres.plot(h,howmany=40,all=FALSE) #

SEP The Skew Power exponential (SEP) distribution for fitting a GAMLSS

Description

This function defines the Skew Power exponential (SEP) distribution, a four parameter distribution,for a gamlss.family object to be used for a GAMLSS fitting using the functiongamlss() .The functionsdSEP, pSEP, qSEP and rSEP define the density, distribution function, quantilefunction and random generation for the Skew Power exponential (SEP) distribution.

Usage

SEP(mu.link = "identity", sigma.link = "log", nu.link = "identity",tau.link = "log")

dSEP(y, mu = 0, sigma = 1, nu = 0, tau = 2, log = FALSE)pSEP(q, mu = 0, sigma = 1, nu = 0, tau = 2, lower.tail = TRUE,

log.p = FALSE)qSEP(p, mu = 0, sigma = 1, nu = 0, tau = 2, lower.tail = TRUE,

log.p = FALSE, lower.limit = mu - 10 * sigma,upper.limit = mu + 10 * sigma)

rSEP(n, mu = 0, sigma = 1, nu = 0, tau = 2)

Arguments

mu.link Defines themu.link , with "identity" link as the default for themuparameter.Other links are "1/mu2" and "log"

sigma.link Defines thesigma.link , with "log" link as the default for thesigma param-eter. Other links are "inverse" and "identity"

Page 122: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

122 SEP

nu.link Defines thenu.link , with "identity" link as the default for thenu parameter.Other links are "1/nu2" and "log"

tau.link Defines thetau.link , with "log" link as the default for thetau parameter.Other links are "1/tau2", and "identity

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of skewnessnu parameter values

tau vector of kurtosistau parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

lower.limit lower limit for the golden search to find quantiles from probabilities

upper.limit upper limit for the golden search to find quantiles from probabilities

Details

The probability density function of the Skew Power exponential distribution, (SEP), is defined as

f(y|n, µ, σ ν, τ) ==z

σΦ(ω) fEP (z, 0, 1, τ)

for −∞ < y < ∞, µ = (−∞,+∞), σ > 0, ν = (−∞,+∞) andτ > 0. wherez = y−µσ ,

ω = sign(z)|z|τ/2ν√

2/τ andfEP (z, 0, 1, τ) is the pdf of an Exponential Power distribution.

This is a reparameterization of the original Johnson Su distribution, Johnson (1954), so the param-etersmu andsigma are the mean and the standard deviation of the distribution. The parameternu determines the skewness of the distribution withnu>0 indicating positive skewness andnu<0negative. The parametertau determines the kurtosis of the distribution.tau should be positiveand most likely in the region from zero to 1. Astau goes to 0 (and fornu=0 ) the distributionapproaches the the Normal density function. The distribution is appropriate for leptokurtic data thatis data with kurtosis larger that the Normal distribution one.

Value

SEP() returns agamlss.family object which can be used to fit the SEP distribution in thegamlss() function.dSEP() gives the density,pSEP() gives the distribution function,qSEP()gives the quantile function, andrSEP() generates random deviates.

Warning

The qSEP and rSEP are slow since they are relying on golden section for finding the quantiles

Note

Page 123: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

SI 123

Author(s)

Bob Rigby〈[email protected]〉 and Mikis Stasinopoulos〈[email protected]

References

Diciccio, T. J. and Mondi A. C. (2004). Inferential Aspects of the Skew Exponential Power distri-bution.,JASA, 99, 439-450.

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

Stasinopoulos D. M. Rigby R. A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , JSU, BCT

Examples

SEP() #plot(function(x)dSEP(x, mu=0,sigma=1, nu=1, tau=2), -5, 5,

main = "The SEP density mu=0,sigma=1,nu=1, tau=2")plot(function(x) pSEP(x, mu=0,sigma=1,nu=1, tau=2), -5, 5,

main = "The BCPE cdf mu=0, sigma=1, nu=1, tau=2")dat<-rSEP(100,mu=10,sigma=1,nu=-1,tau=1.5)gamlss(dat~1,family=SEP, control=gamlss.control(n.cyc=30))

SI The Sichel dustribution for fitting a GAMLSS model

Description

The SI() function defines the Sichel distribution, a three parameter discrete distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . The func-tionsdSI , pSI , qSI andrSI define the density, distribution function, quantile function and ran-dom generation for the SichelSI() , distribution.

Usage

SI(mu.link = "log", sigma.link = "log", nu.link = "identity")dSI(y, mu = 0.5, sigma = 0.02, nu = -0.5, log = FALSE)pSI(q, mu = 0.5, sigma = 0.02, nu = -0.5, lower.tail = TRUE,

log.p = FALSE)qSI(p, mu = 0.5, sigma = 0.02, nu = -0.5, lower.tail = TRUE,

log.p = FALSE, max.value = 10000)rSI(n, mu = 0.5, sigma = 0.02, nu = -0.5)

Page 124: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

124 SI

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

nu.link Defines thenu.link , with "identity" link as the default for the nu parameter

y vector of (non-negative integer) quantiles

mu vector of positive mu

sigma vector of positive despersion parameter

nu vector of nu

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

max.value a constant, set to the default value of 10000 for how far the algorithm shouldlook for q

Details

The probability function of the Sichel distribution is given by

f(y|µ, σ, ν) =µyKy+ν(α)

(ασ)y+νy!Kν( 1σ )

whereα2 = 1σ2 + 2µ

σ , for y = 0, 1, 2, ...,∞ whereµ > 0 , σ > 0 and−∞ < ν < ∞ andKλ(t) = 1

2

∫∞0

xλ−1 exp− 12 t(x + x−1)dx is the modified Bessel function of the third kind.

Note that the above parameterization is different from Stein, Zucchini and Juritz (1988) who use theabove probability function but treatµ, α andν as the parameters. Note thatσ = [(µ2+α2)

12 −µ]−1.

Value

Returns agamlss.family object which can be used to fit a Sichel distribution in thegamlss()function.

Note

Author(s)

Akantziliotou C., Rigby, R. A. and Stasinopoulos D. M.

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2003) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Stein, G. Z., Zucchini, W. and Juritz, J. M. (1987). Parameter Estimation of the Sichel Distributionand its Multivariate Extension.Journal of American Statistical Association, 82, 938-944.

Page 125: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

stepGAIC 125

See Also

gamlss , gamlss.family , PIG, NBI , NBII

Examples

SI()# gives information about the default links for the Sichel distribution#plot the pdf using plotplot(function(y) dSI(y, mu=10, sigma=1, nu=1), from=0, to=100, n=100+1, type="h") # pdf# plot the cdfplot(seq(from=0,to=100),pSI(seq(from=0,to=100), mu=10, sigma=1, nu=1), type="h") # cdf# generate random sampletN <- table(Ni <- rSI(100, mu=5, sigma=1, nu=1))r <- barplot(tN, col='lightblue')# fit a model to the datagamlss(Ni~1,family=SI, control=gamlss.control(n.cyc=50))

stepGAIC Choose a model by GAIC in a Stepwise Algorithm

Description

The functionstepGAIC() performs stepwise model selection using a Generalized Akaike Infor-mation Criterion. The functionstepGAIC() calls one of the two functionsstepGAIC.VR()or stepGAIC.CH() depending on the argumentadditive . The functionstepGAIC.VR()is based on the functionstepAIC() given in the library MASS of Venables and Ripley (2002).The functionstepGAIC.CH is based on the S functionstep.gam() (see Chambers and Hastie(1991)) and it is more suited for model with smoothing additive terms. Both functions havebeen adapted to work with gamlss objects. The main difference for the user is thescope argu-ment, see below. If thestepGAIC() is called with the argumentadditive=FALSE then thestepGAIC.VR() is called else thestepGAIC.CH() .

Usage

stepGAIC.VR(object, scope, direction = c("both", "backward", "forward"),trace = T, keep = NULL, steps = 1000, scale = 0,what = c("mu", "sigma", "nu", "tau"), k = 2, ...)

stepGAIC.CH(object, scope = gamlss.scope(model.frame(object)),direction = c("both", "backward", "forward"), trace = T, keep = NULL,steps = 1000, what = c("mu", "sigma", "nu", "tau"), k = 2, ...)

stepGAIC(object, scope = gamlss.scope(model.frame(object)),direction = c("both", "backward", "forward"),trace = T, keep = NULL, steps = 1000,what = c("mu", "sigma", "nu", "tau"), k = 2,additive = FALSE, ...)

Page 126: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

126 stepGAIC

Arguments

object an gamlss object. This is used as the initial model in the stepwise search.

scope defines the range of models examined in the stepwise search. For the functionstepAIC() this should be either a single formula, or a list containing compo-nentsupper andlower , both formulae. See the details for how to specify theformulae and how they are used. For the functionstepGAIC the scope definesthe range of models examined in the step-wise search. It is a list of formulas,with each formula corresponding to a term in the model. A 1 in the formulaallows the additional option of leaving the term out of the model entirely. +

direction the mode of stepwise search, can be one ofboth , backward , or forward ,with a default ofboth . If the scope argument is missing the default fordirection is backward

trace if positive, information is printed during the running ofstepAIC . Larger valuesmay give more information on the fitting process.

keep a filter function whose input is a fitted model object and the associated ’AIC’statistic, and whose output is arbitrary. Typically ’keep’ will select a subsetof the components of the object and return them. The default is not to keepanything.

steps the maximum number of steps to be considered. The default is 1000 (essentiallyas many as required). It is typically used to stop the process early.

scale scale is nor used in gamlss

what which distribution parameter is required, defaultwhat="mu"

k the multiple of the number of degrees of freedom used for the penalty. Only ’k =2’ gives the genuine AIC: ’k = log(n)’ is sometimes referred to as BIC or SBC.

additive if additive=TRUE thenstepGAIC.CH is used elsestepGAIC.CH , de-fault value is FALSE

... any additional arguments to ’extractAIC’. (None are currently used.)

Details

The set of models searched is determined by thescope argument.

For the functionstepGAIC.VR() the right-hand-side of itslower component is always includedin the model, and right-hand-side of the model is included in theupper component. Ifscope isa single formula, it specifies theupper component, and thelower model is empty. Ifscope ismissing, the initial model is used as theupper model.

Models specified byscope can be templates to updateobject as used byupdate.formula .

For the functionstepGAIC.CH() each of the formulas in scope specifies a "regimen" of candidateforms in which the particular term may enter the model. For example, a term formula might be

x1 + log(x1) + cs(x1, df=3)

This means that x1 could either appear linearly, linearly in its logarithm, or as a smooth functionestimated non-parametrically. Every term in the model is described by such a term formula, and thefinal model is built up by selecting a component from each formula.

The functiongamlss.scope similar to the Sgam.scope() in Chambers and Hastie (1991)can be used to create automatically term formulae from specified data or model frames.

The supplied model object is used as the starting model, and hence there is the requirement that oneterm from each of the term formulas of the parameters be present in the formula of the distributionparameter. This also implies that any terms in formula of the distribution parameter not containedin any of the term formulas will be forced to be present in every model considered.

Page 127: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

stepGAIC 127

Value

the stepwise-selected model is returned, with up to two additional components. There is an ’"anova"’component corresponding to the steps taken in the search, as well as a ’"keep"’ component if the’keep=’ argument was supplied in the call. The ’"Resid. Dev"’ column of the analysis of deviancetable refers to a constant minus twice the maximized log likelihood

Note

Author(s)

Mikis Stasinopoulos based on functions in MASS library and in Statistical Models in S

References

Chambers, J. M. and Hastie, T. J. (1991).Statistical Models in S, Chapman and Hall, London.

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

Venables, W. N. and Ripley, B. D. (2002)Modern Applied Statistics with S. Fourth edition. Springer.

See Also

gamlss.scope

Examples

data(usair)# Note default of additive=FALSE# fitting all variables linearlymod1<-gamlss(y~., data=usair, family=GA)# find the best subset for the mumod2<-stepGAIC(mod1)mod2$anova# find the best subset for sigmamod3<-stepGAIC(mod2, what="sigma", scope=~x1+x2+x3+x4+x5+x6)mod3$anova# now use the stepGAIC.CH function# creating a scope from the usair model framegs<-gamlss.scope(model.frame(y~x1+x2+x3+x4+x5+x6, data=usair))gsmod4<-gamlss(y~1, data=usair, family=GA)mod5<-stepGAIC(mod4,gs, additive=TRUE)mod5$anovamod6<-stepGAIC(mod5, what="sigma", scope=~x1+x2+x3+x4+x5+x6)mod6$anovamod6

Page 128: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

128 summary.gamlss

summary.gamlss Summarizes a GAMLSS fitted model

Description

summary.gamlss is the GAMLSS specific method for the generic functionsummary whichsummarize objects returned by modelling functions.

Usage

summary.gamlss(object, dispersion = NULL, ...)

Arguments

object a GAMLSS fitted model

dispersion always equal to NULL

... for extra arguments

Details

Value

Print summary of a GAMLSS object

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2003) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , deviance.gamlss , fitted.gamlss

Examples

data(aids)h<-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) #summary(h)rm(h)

Page 129: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

term.plot 129

term.plot Plot regression terms for a specified parameter of a GAMLSS object

Description

Plots regression terms against their predictors, optionally with standard errors and partial residualsadded. It is almost identical to the R functiontermplot suitable changed to apply to GAMLSSobjects.

Usage

term.plot(object, what = c("mu", "sigma", "nu", "tau"), data = NULL,envir = environment(formula(object)),partial.resid = FALSE, rug = FALSE,terms = NULL, se = FALSE, xlabs = NULL, ylabs = NULL,main = NULL, col.term = 2, lwd.term = 1.5,col.se = "orange", lty.se = 2, lwd.se = 1,col.res = "gray", cex = 1, pch = par("pch"),col.smth = "darkred", lty.smth = 2,span.smth = 2/3,ask = interactive() && nb.fig < n.tms && .Device != "postscript",use.factor.levels = TRUE, smooth = NULL, ...)

Arguments

object a GAMLSS object

what the required parameter of the GAMLSS distribution

data data frame in which variables inobject can be found

envir environment in which variables inobject can be foundpartial.resid

logical; should partial residuals be plotted?

rug add rugplots (jittered 1-d histograms) to the axes?

terms which terms to plot (default ’NULL’ means all terms)

se plot pointwise standard errors?

xlabs vector of labels for the x axes

ylabs vector of labels for the y axes

main logical, or vector of main titles; if ’TRUE’, the model’s call is taken as maintitle, ’NULL’ or ’FALSE’ mean no titles.

col.term, lwd.termcolor and width for the "term curve", see ’lines’.

col.se, lty.se, lwd.secolor, line type and line width for the "twice-standard-error curve" when ’se =TRUE’.

col.res, cex, pchcolor, plotting character expansion and type for partial residuals, when ’par-tial.resid = TRUE’, see ’points’.

lty.smth,col.smth, span.smthPassed to ’smooth’

Page 130: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

130 term.plot

ask logical; if ’TRUE’, the user is asked before each plot, see ’par(ask=.)’.

use.factor.levelsShould x-axis ticks use factor levels or numbers for factor terms?

smooth ’NULL’ or a function with the same arguments as ’panel.smooth’ to draw asmooth through the partial residuals for non-factor terms

... other graphical parameters

Details

The function uses thelpred function of GAMLSS. The ’data’ argument should rarely be needed,but in some cases ’termplot’ may be unable to reconstruct the original data frame. Using ’na.action=na.exclude’makes these problems less likely. Nothing sensible happens for interaction terms.

Value

a plot of fitted terms.

Note

Author(s)

Mikis Stasinopoulos based on the existing termplot() function

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

termplot

Examples

data(aids)a<-gamlss(y~cs(x,df=8)+qrt,data=aids,family=NBI)term.plot(a, se=TRUE)rm(a)

Page 131: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

TF 131

TF t family distribution for fitting a GAMLSS

Description

The functionTF defines the t-family distribution, a three parameter distribution, for agamlss.familyobject to be used in GAMLSS fitting using the functiongamlss() . The functionsdTF, pTF, qTFandrTF define the density, distribution function, quantile function and random generation for thespecific parameterization of the t distribution given in details below, with mean equal toµ andstandard deviation equal toσ( ν

ν−2 )0.5 with the degrees of freedomν

Usage

TF(mu.link = "identity", sigma.link = "log", nu.link = "log")dTF(y, mu = 0, sigma = 1, nu = 10, log = FALSE)pTF(q, mu = 0, sigma = 1, nu = 10, lower.tail = TRUE, log.p = FALSE)qTF(p, mu = 0, sigma = 1, nu = 10, lower.tail = TRUE, log.p = FALSE)rTF(n, mu = 0, sigma = 1, nu = 10)

Arguments

mu.link Defines themu.link , with "identity" link as the default for the mu parameter

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

nu.link Defines thenu.link , with "log" link as the default for the nu parameter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of the degrees of freedom parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

Definition file for t family distribution.

f(y|µ, σ, ν) =Γ((ν + 1)/2)

σΓ(1/2)Γ(ν/2)ν0.5

[1 +

(y − µ)2

νσ2

]−(ν+1)/2

y = (−∞,+∞), µ = (−∞,+∞), σ > 0 andν > 0. Note thatz = (y − µ)/σ has a standard tdistribution with degrees of freedomν.

Page 132: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

132 update.gamlss

Value

TF() returns agamlss.family object which can be used to fit a t distribution in thegamlss()function. dTF() gives the density,pTF() gives the distribution function,qTF() gives the quan-tile function, andrTF() generates random deviates. The latest functions are based on the equiva-lentR functions for gamma distribution.

Note

µ is the mean andσ[ν/(ν − 2)]0.5 is the standard deviation of the t family distribution.ν > 0 is apositive real valued parameter.

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Kalliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family

Examples

TF()# gives information about the default links for the t-family distributiondata(abdom)h<-gamlss(y~cs(x,df=3), sigma.formula=~cs(x,1), family=TF, data=abdom) # fitsplot(h)newdata<-rTF(1000,mu=0,sigma=1,nu=5) # generates 1000 random observationshist(newdata)rm(h,newdata)

update.gamlss Update and Re-fit a GAMLSS Model

Description

update.gamlss is the GAMLSS specific method for the generic functionupdate which up-dates and (by default) refits a GAMLSS model.

Usage

update.gamlss(object, formula., ..., what = c("mu", "sigma", "nu", "tau"),evaluate = TRUE)

Page 133: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

update.gamlss 133

Arguments

object a GAMLSS fitted model

formula. the formula to update

... for updating argument ingamlss()

what the parameter in which the formula needs updating

evaluate whether to evaluate the call or not

Value

Returns a GAMLSS object

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

print.gamlss , summary.gamlss , fitted.gamlss , coef.gamlss , residuals.gamlss ,plot.gamlss , deviance.gamlss , formula.gamlss

Examples

data(aids)# fit a poisson modelh.po <-gamlss(y~cs(x,2)+qrt, family=PO, data=aids)# update with a negative binomialh.nb <-update(h.po, family=NBI)# update the smoothingh.nb1 <-update(h.nb,~cs(x,8)+qrt)# remove qrth.nb2 <-update(h.nb1,~.-qrt)# put back qrt take log of y and fit a normal distributionh.nb3 <-update(h.nb1,log(.)~.+qrt, family=NO)# verify that it is the sameh.no<-gamlss(log(y)~cs(x,8)+qrt,data=aids )

Page 134: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

134 usair

usair US air pollution data set

Description

US air pollution data set taken from Hand et al. (1994) data set 26, USAIR.DAT, originally fromSokal and Rohlf (1981).

Usage

data(usair)

Format

A data frame with 41 observations on the following 7 variables.

y a numeric vector: sulpher dioxide concentration in air mgs. per cubic metre in 41 cities in theUSA

x1 a numeric vector: average annual temperature in degrees F

x2 a numeric vector: number of manufacturers employing >20 workers

x3 a numeric vector: population size in thousands

x4 a numeric vector: average annual wind speed in miles per hour

x5 a numeric vector: average annual rainfall in inches

x6 a numeric vector: average number of days rainfall per year

Details

Source

Hand et al. (1994) data set 26, USAIR.DAT, originally from Sokal and Rohlf (1981)

References

Hand, D. J., Daly, F., Lunn, A. D., McConway, K. J. and Ostrowski, E. (1994), A handbook of smalldata sets, Chapman and Hall, London.

Examples

data(usair)str(usair)plot(usair)# a possible gamlss modelap<-gamlss(y~cs(x1,2)+x2+x3+cs(x4,2)+x5+cs(x6,3)+x4:x5,

data=usair, family=GA(mu.link="inverse"))

Page 135: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

VGD 135

VGD Validation global deviance

Description

This function helps to validate a GAMLSS model by randomly splitting the data into training(around 60%) and validation (around 40%) sets. It minimizes the global deviance for the trainingdata set and then uses the validation set to calculate the global deviance. The resulting validationglobal deviance (VGD) can be used for selecting the distribution, the terms in the model or a degreesof freedom for smoothing.

Usage

VGD(family = NO, formula = y ~ 1, sigma.fo = ~1, nu.fo = ~1, tau.fo = ~1,data = NULL, control = gamlss.control(trace = FALSE), rand = NULL, ...)

Arguments

family agamlss.family object

formula a gamlss formula formu(including the response on the left)

sigma.fo a formula forsigma

nu.fo a formula fornu

tau.fo a formula fortau

data the data set used for the fitting

control gamlss.control to be passed togamlss

rand a random vector of one and two indicating whether is the trainining set (1)or the validation set (2) i.e. created in advance using something likerand<- sample(2, N, replace=T, prob=c(0.6,0.4)) where N is thelength of the data

... for extra arguments to be passed in thegamlss fit

Details

Value

Rerurns a validated global deviance

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉 and Bob Rigby〈[email protected]

Page 136: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

136 WEI2

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss.family , gamlss , deviance.gamlss

Examples

data(abdom)# generate the random split of the datarand <- sample(2, 610, replace=TRUE, prob=c(0.6,0.4))# the proportions in the sampletable(rand)/610VGD(LO,form=y~cs(x,df=2),sigma.fo=~cs(x,df=1), data=abdom, rand=rand)

WEI2 A specific parameterization of the Weibull distribution for fitting aGAMLSS

Description

The functionWEI2 can be used to define the Weibull distribution, a two parameter distribution, fora gamlss.family object to be used in GAMLSS fitting using the functiongamlss() . This isthe parameterization of the Weibull distribution usually used in proportional hazard models and isdefined in details below. [Note that the GAMLSS functionWEI uses a different parameterizationfor fitting the Weibull distribution.] The functionsdWEI2, pWEI2, qWEI2 andrWEI2 define thedensity, distribution function, quantile function and random generation for the specific parameteri-zation of the Weibull distribution.

Usage

WEI2(mu.link = "log", sigma.link = "log")dWEI2(y, mu = 1, sigma = 1, log = FALSE)pWEI2(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qWEI2(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)rWEI2(n, mu = 1, sigma = 1)

Arguments

mu.link Defines themu.link , with "log" link as the default for the mu parameter, otherlinks are "inverse" and "identity"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other link is the "inverse" and "identity"

y,q vector of quantiles

mu vector of the mu parameter values

Page 137: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

WEI2 137

sigma vector of sigma parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The parameterization of the functionWEI2 is given by

f(y|µ, σ) = σµyσ−1e−µyσ

for y > 0, µ > 0 andσ > 0. The GAMLSS functionsdWEI2, pWEI2, qWEI2, andrWEI2 canbe used to provide the pdf, the cdf, the quantiles and random generated numbers for the Weibulldistribution with argumentmu, andsigma . [See the GAMLSS functionWEI for a different param-eterization of the Weibull.]

Value

WEI2() returns agamlss.family object which can be used to fit a Weibull distribution inthe gamlss() function. dWEI2() gives the density,pWEI2() gives the distribution function,qWEI2() gives the quantile function, andrWEI2() generates random deviates. The latest func-tions are based on the equivalentR functions for Weibull distribution.

Warning

In WEI2 the estimated parametersmuandsigma can be highly correlated so it is advisable to usetheCG() method for fitting [as the RS() method can be veru slow in this situation.]

Note

The mean inWEI2 is given byµ−1/σΓ( 1σ + 1) and the varianceµ−2/σ(Γ( 2

σ + 1)−[Γ( 1

σ + 1)]2)

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , WEI

Page 138: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

138 WEI

Examples

WEI2()dat<-rWEI(100, mu=.1, sigma=2)gamlss(dat~1, family=WEI2, method=CG())

WEI Weibull distribution for fitting a GAMLSS

Description

The functionWEI can be used to define the Weibull distribution, a two parameter distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . [Note thatthe GAMLSS functionWEI2 uses a different parameterization for fitting the Weibull distribution.]The functionsdWEI, pWEI, qWEI and rWEI define the density, distribution function, quantilefunction and random generation for the specific parameterization of the Weibul distribution.

Usage

WEI(mu.link = "log", sigma.link = "log")dWEI(y, mu = 1, sigma = 1, log = FALSE)pWEI(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)qWEI(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)rWEI(n, mu = 1, sigma = 1)

Arguments

mu.link Defines themu.link , with "log" link as the default for the mu parameter, otherlinks are "inverse" and "identity"

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter, other link is the "inverse" and "identity"

y,q vector of quantiles

mu vector of the mu parameter

sigma vector of sigma parameter

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

Details

The parameterization of the functionWEI is given by

f(y|µ, σ) =σyσ−1

µσexp

[−(

y

µ

)σ]for y > 0, µ > 0 andσ > 0. The GAMLSS functionsdWEI, pWEI, qWEI, andrWEI can be usedto provide the pdf, the cdf, the quantiles and random generated numbers for the Weibull distributionwith argumentmu, andsigma . [See the GAMLSS functionWEI2 for a different parameterizationof the Weibull.]

Page 139: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

wp 139

Value

WEI() returns agamlss.family object which can be used to fit a Weibull distribution in thegamlss() function.dWEI() gives the density,pWEI() gives the distribution function,qWEI()gives the quantile function, andrWEI() generates random deviates. The latest functions are basedon the equivalentR functions for Weibull distribution.

Note

The mean inWEI is given byµΓ( 1σ + 1) and the varianceµ2

[Γ( 2

σ + 1)− (Γ( 1σ + 1))2

]Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]〉and Calliope Akantziliotou

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , WEI2

Examples

WEI()dat<-rWEI(100, mu=10, sigma=2)gamlss(dat~1, family=WEI)

wp Worm plot

Description

Provides single or multiple worm plots for GAMLSS fitted objects. This is a diagnostic tool forchecking the residuals within different ranges (by default not overlapping) of the explanatory vari-able

Usage

wp(object, xvar = NULL, n.inter = 4, xcut.points = NULL,overlap = 0, xlim.all = 4, xlim.worm = 3.5,show.given = TRUE, line = TRUE,ylim.all = 12 * sqrt(1/length(fitted(object))),ylim.worm = 12 * sqrt(n.inter/length(fitted(object))),cex = 1, pch = 21, ...)

Page 140: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

140 wp

Arguments

object a GAMLSS fitted object

xvar the explanatory variable against which the worm plots will be plotted

n.inter the number of intervals in which the explanatory variablexvar will be cut

xcut.points the x-axis cut off points e.g.c(20,30) . If xcut.points=NULL then then.inter argument is activated

overlap how much overlapping in thexvar intervals. Default value isoverlap=0 fornon overlapping intervals

xlim.all for the single plot, this value is the x-variable limit, default isxlim.all=4

xlim.worm for multiple plots, this value is the x-variable limit, default isxlim.worm=3.5

show.given whether to show the x-variable intervals in the top of the graph, default isshow.given=TRUE

line whether to plot the polynomial line in the worm plot, default value isline=TRUE

ylim.all for the single plot, this value is the y-variable limit, default value isylim.all=12*sqrt(1/length(fitted(object)))

ylim.worm for multiple plots, this values is the y-variable limit, default value isylim.worm=12*sqrt(n.inter/length(fitted(object)))

cex the cex plotting parameter with defaultcex=1

pch the pch plotting parameter with defaultpch=21

... for extra arguments

Details

If the xvar argument is not specified then a single worm plot is used. In this case a worm plot isa detrended normal QQ-plot so departure from normality is highlighted. If thexvar is specifiedthen we have as many worm plot asn.iter . In this case the x-variable is cut inton.iterintervals with an equal number observations and detrended normal QQ (i.e. worm) plots for eachinterval are plotted. This is a way of highlighting failures of the model within different ranges of theexplanatory variable. The fitted coefficients from fitting cubic polynomials to the residuals (withineach x-variable interval) can be obtain by e.g.coeffs<-wp(model1,xvar=x,n.iner=9) .van Buurenet al. (2001) used these residuals to identify regions (intervals) of the explanatoryvariable within which the model does not fit adequately the data (called "model violation")

Value

For multiple plots thexvar intervals and the coefficients of the fitted cubic polynomials to theresiduals (within eachxvar interval) are returned.

Note

Author(s)

Mikis Stasinopoulos and Bob Rigby

Page 141: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

ZAIG 141

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale andshape,(with discussion),Appl. Statist., 54, part 3, 1-38.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

van Buuren and Fredriks M. (2001) Worm plot: simple diagnostic device for modelling growthreference curves.Statistics in Medicine, 20, 1259–1277

See Also

gamlss , plot.gamlss

Examples

data(abdom)a<-gamlss(y~cs(x,df=3),sigma.fo=~cs(x,1),family=LO,data=abdom)wp(a)coeff1<-wp(a,abdom$x)coeff1rm(a,a1)

ZAIG The zero adjusted Inverse Gaussian distribution for fitting a GAMLSSmodel

Description

The functionZAIG() defines the zero adjusted Inverse Gaussian distribution, a three parame-ter distribution, for agamlss.family object to be used in GAMLSS fitting using the functiongamlss() . The zero adjusted Inverse Gaussian distribution is similar to the Inverse Gaussiandistribution but allows zeros as y values. The extra parameter models the probabilities at zero.The functionsdZAIG , pZAIG , qZAIG andrZAIG define the density, distribution function, quan-tile function and random generation for theZAIG parameterization of the zero adjusted InverseGaussian distribution.plotZAIG can be used to plot the distribution.meanZAIG calculates theexpected value of the response for a fitted model.

Usage

ZAIG(mu.link = "log", sigma.link = "log", nu.link = "logit")dZAIG(y, mu = 1, sigma = 1, nu = 0.1, log = FALSE)pZAIG(q, mu = 1, sigma = 1, nu = 0.1, lower.tail = TRUE, log.p = FALSE)qZAIG(p, mu = 1, sigma = 1, nu = 0.1, lower.tail = TRUE, log.p = FALSE,

lower.limit = nu, upper.limit = mu + 10 * sqrt(sigma^2 * mu^3))rZAIG(n, mu = 1, sigma = 1, nu = 0.1, ...)plotZAIG(mu = 5, sigma = 1, nu = 0.1, from = 0, to = 10, n = 101, ...)meanZAIG(obj)

Page 142: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

142 ZAIG

Arguments

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

sigma.link Defines thesigma.link , with "log" link as the default for the sigma parame-ter

nu.link Defines thenu.link , with "logit" link as the default for the sigma parameter

y,q vector of quantiles

mu vector of location parameter values

sigma vector of scale parameter values

nu vector of probability at zero parameter values

log, log.p logical; if TRUE, probabilities p are given as log(p).

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

lower.limit the argumentlower.limit sets the lower limit in the golden section searchfor q, the default is nu

upper.limit the argumentupper.limit sets the upper limit in the golden section searchfor q, the default is 10 time its standard deviation

p vector of probabilities.

n number of observations. Iflength(n) > 1 , the length is taken to be thenumber required

from where to start plotting the distribution from

to up to where to plot the distribution

obj a fittedBEINF object

... ... can be used to pass the uppr.limit argument toqIG

Details

The Zero adjusted IG distribution is given as

f(y|µ, σ ν) = ν

if (y=0)

f(y|µ, σ, ν) = (1− ν)1√

2πσ2y3exp(− (y − µ)2

2µ2σ2y)

otherwise

for y = (0,∞), µ > 0, σ > 0 and0 < ν < 1. E(y) = (1−ν)µ andV ar(y) = (1−ν)µ2(ν+µσ2).

Value

returns agamlss.family object which can be used to fit a zero adjusted inverse Gaussian dis-tribution in thegamlss() function.

Note

Author(s)

Bob Rigby and Mikis Stasinopoulos

Page 143: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

ZIP 143

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , IG

Examples

ZAIG()# gives information about the default links for the ZAIG distribution# plotting the distributionplotZAIG( mu =10 , sigma=.5, nu = 0.1, from = 0, to=10, n = 101)# plotting the cdfplot(function(y) pZAIG(y, mu=10 ,sigma=.5, nu = 0.1 ), 0, 1)# plotting the inverse cdfplot(function(y) qZAIG(y, mu=10 ,sigma=.5, nu = 0.1 ), 0.001, .99)# generate random numbersdat <- rZAIG(100,mu=10,sigma=.5, nu=.1)# fit a model to the datam1<-gamlss(dat~1,family=ZAIG)meanZAIG(m1)[1]

ZIP Zero inflated poisson distribution for fitting a GAMLSS model

Description

The functionZIP defines the zero inflated Poisson distribution, a two parameter distribution, fora gamlss.family object to be used in GAMLSS fitting using the functiongamlss() . ThefunctionsdZIP , pZIP , qZIP andrZIP define the density, distribution function, quantile functionand random generation for the inflated poisson,ZIP() , distribution.

Usage

ZIP(mu.link = "log", sigma.link = "logit")dZIP(y, mu = 5, sigma = 0.1, log = FALSE)pZIP(q, mu = 5, sigma = 0.1, lower.tail = TRUE, log.p = FALSE)qZIP(p, mu = 5, sigma = 0.1, lower.tail = TRUE, log.p = FALSE)rZIP(n, mu = 5, sigma = 0.1)

Arguments

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

sigma.link defines thesigma.link , with "logit" link as the default for the sigma param-eter which in this case is the probability at zero. Other links are "probit" and"cloglog"’(complementary log-log)

Page 144: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

144 ZIP

y vector of (non-negative integer) quantiles

mu vector of positive means

sigma vector of probabilities at zero

p vector of probabilities

q vector of quantiles

n number of random values to return

log, log.p logical; if TRUE, probabilities p are given as log(p)

lower.tail logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Details

Let Y = 0 with probabilityσ andY ∼ Po(µ) with probability (1 − σ) the Y has a Zero inflatedPoisson Distribution given by

f(y) = σ + (1− σ)e−µ

if (y=0)

f(y) = (1− σ)e−µµy

y!

if (y>0) for y = 0, 1, ...,.

Value

returns agamlss.family object which can be used to fit a zero inflated poisson distribution inthegamlss() function.

Note

Author(s)

Mikis Stasinopoulos〈[email protected]〉, Bob Rigby〈[email protected]

References

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

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use theGAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (seealsohttp://www.londonmet.ac.uk/gamlss/ ).

See Also

gamlss , gamlss.family , PO

Page 145: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

ZIP 145

Examples

ZIP()# gives information about the default links for the normal distribution# creating data and plotting themdat<-rZIP(1000, mu=5, sigma=.1)r <- barplot(table(dat), col='lightblue')# fit the disteibutionmod1<-gamlss(dat~1, family=ZIP)# fits a constant for mu and sigmafitted(mod1)[1]fitted(mod1,"sigma")[1]

Page 146: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

Index

∗Topic datasetsabdom, 1aep , 4aids , 5db , 14fabric , 35hodges , 63Mums, 81rent , 114usair , 133

∗Topic distributionBB, 6BCCG, 8BCPE, 10BCT, 12BE, 17BEINF, 15BI , 21GA, 57GU, 60IG , 65JSU, 69JSUo, 67LNO, 71LO, 73NBI , 84NBII , 82NET, 85NO, 87NO.var , 89PE, 93PIG, 95PO, 99RG, 117SEP, 120SI , 122TF, 130WEI, 137WEI2, 135ZAIG, 140ZIP , 142

∗Topic packagegamlss-package , 47

∗Topic regressionadditive.fit , 2BB, 6BCCG, 8BCPE, 10BCT, 12BE, 17BEINF, 15bfp , 19BI , 21centiles , 26centiles.com , 22centiles.pred , 24centiles.split , 28checklink , 29coef.gamlss , 30cs , 31deviance.gamlss , 34find.hyper , 36fitted.gamlss , 38fitted.plot , 39formula.gamlss , 40GA, 57gamlss , 52gamlss.control , 41gamlss.cs , 42gamlss.family , 43gamlss.fp , 45gamlss.lo , 46gamlss.ps , 48gamlss.ra , 50gamlss.random , 49gamlss.rc , 51gamlss.scope , 56glim.control , 59GU, 60histDist , 61IC , 64IG , 65JSU, 69JSUo, 67LNO, 71LO, 73

146

Page 147: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

INDEX 147

lo , 74lpred , 76make.link.gamlss , 77model.frame.gamlss , 80NBI , 84NBII , 82NET, 85NO, 87NO.var , 89par.plot , 90pdf.plot , 92PE, 93PIG, 95plot.gamlss , 97PO, 99polyS , 98predict.gamlss , 100print.gamlss , 102prof.dev , 103prof.term , 105ps , 107Q.stats , 108ra , 111random , 109rc , 112refit , 113residuals.gamlss , 116RG, 117rqres.plot , 119SEP, 120SI , 122stepGAIC , 124summary.gamlss , 127term.plot , 128TF, 130update.gamlss , 131VGD, 134WEI, 137WEI2, 135wp, 138ZAIG, 140ZIP , 142

abdom, 1additive.fit , 2, 19, 31, 107aep , 4AIC.gamlss (IC ), 64aids , 5as.family (gamlss.family ), 43as.gamlss.family (gamlss.family ),

43

BB, 6, 44, 45

BCCG, 8, 44, 45, 71, 72BCCGuntr (BCCG), 8BCPE, 10, 44, 45, 86BCPEuntr (BCPE), 10BCT, 12, 12, 44, 45, 68, 70, 122BCTuntr (BCT), 12BE, 17, 17, 44, 45BEINF, 15, 18, 44, 45bfp , 19BI , 21, 44, 45

centiles , 24, 25, 26, 28, 29, 39centiles.com , 22, 27, 29centiles.pred , 24centiles.split , 24, 25, 27, 28, 39, 109checkBCPE (BCPE), 10checklink , 29coef.gamlss , 30, 34, 38, 117, 132cs , 31, 42, 43, 76, 108

db , 14dBB (BB), 6dBCCG(BCCG), 8dBCPE(BCPE), 10dBCT(BCT), 12dBE (BE), 17dBEINF (BEINF), 15dBI (BI ), 21deviance.gamlss , 31, 34, 38, 40, 103,

117, 127, 132, 135dGA(GA), 57dGU(GU), 60dIG (IG ), 65dJSU (JSU), 69dJSUo (JSUo), 67dLNO(LNO), 71dLO (LO), 73dLOGNO(LNO), 71dNBI (NBI ), 84dNBII (NBII ), 82dNET(NET), 85dNO(NO), 87dNO.var (NO.var ), 89dPE (PE), 93dPIG (PIG), 95dPO(PO), 99dRG(RG), 117dSEP(SEP), 120dSI (SI ), 122dTF (TF), 130dWEI (WEI), 137dWEI2 (WEI2), 135dZAIG (ZAIG), 140

Page 148: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

148 INDEX

dZIP (ZIP ), 142

extractAIC.gamlss (IC ), 64

fabric , 35find.hyper , 36, 56, 111fitted.gamlss , 31, 34, 38, 38, 40, 103,

117, 127, 132fitted.plot , 39formula.gamlss , 38, 40, 117, 132fp , 46fp (bfp ), 19fv (fitted.gamlss ), 38

GA, 44, 45, 57GAIC (IC ), 64gamlss , 3, 7, 10, 12, 14, 17, 18, 20, 22, 24,

25, 27, 29–31, 33, 37, 39, 40, 42, 43,45–47, 49–51, 52, 52, 58, 60–62, 65,67, 68, 70, 72, 74, 79, 81, 83, 85, 86,88, 90, 91, 93, 95, 96, 98–100, 103,104, 106, 108–110, 112–114,118–120, 122, 124, 127, 131, 135,136, 138, 140, 142, 143

gamlss-package , 47gamlss.control , 41, 54gamlss.cs , 31, 33, 42, 107gamlss.family , 7, 10, 12, 14, 17, 18, 20,

22, 30, 34, 43, 47, 53, 54, 56, 58, 61,62, 67, 68, 70–72, 74, 79, 83, 85, 86,88, 90, 95, 96, 100, 118, 122, 124,131, 134–136, 138, 142, 143

gamlss.fp , 19, 45gamlss.lo , 46, 99gamlss.ps , 48, 108gamlss.ra , 50gamlss.random , 49, 110gamlss.rc , 51gamlss.scope , 56, 126gamlssNews (gamlss ), 52glim.control , 54, 59GU, 44, 45, 60

histDist , 61hodges , 63hodges1 (hodges ), 63

IC , 64IG , 44, 45, 65, 142is.gamlss (gamlss ), 52

JSU, 44, 45, 68, 69, 70, 122JSUo, 67

LNO, 44, 45, 71LO, 44, 45, 73lo , 33, 47, 74LOGNO(LNO), 71lp , 102lp (lpred ), 76lpred , 76, 102

make.link.gamlss , 77meanBEINF (BEINF), 15meanZAIG (ZAIG), 140model.frame.gamlss , 80model.matrix.gamlss

(model.frame.gamlss ), 80Mums, 81

NBI , 44, 45, 84, 96, 124NBII , 44, 45, 82, 83, 85, 96, 124NET, 85NO, 44, 45, 87NO.var , 88, 89

optim , 37

par.plot , 90pBB (BB), 6pBCCG(BCCG), 8pBCPE(BCPE), 10pBCT(BCT), 12pBE (BE), 17pBEINF (BEINF), 15pBI (BI ), 21pdf.plot , 56, 92PE, 44, 45, 93pGA(GA), 57pGU(GU), 60PIG, 44, 45, 83, 85, 95, 124pIG (IG ), 65pJSU (JSU), 69pJSUo (JSUo), 67pLNO(LNO), 71pLO (LO), 73pLOGNO(LNO), 71plot.gamlss , 37, 38, 97, 117, 120, 132,

140plotBEINF (BEINF), 15plotZAIG (ZAIG), 140pNBI (NBI ), 84pNBII (NBII ), 82pNET(NET), 85pNO(NO), 87pNO.var (NO.var ), 89PO, 44, 45, 99, 143

Page 149: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

INDEX 149

poly.matrix (polyS ), 98polyS , 98pp (bfp ), 19pPE (PE), 93pPIG (PIG), 95pPO(PO), 99predict.gamlss , 77, 100pRG(RG), 117print.gamlss , 38, 102, 117, 132print.gamlss.family

(gamlss.family ), 43prof.dev , 103, 106prof.term , 104, 105ps , 49, 107pSEP(SEP), 120pSI (SI ), 122pTF (TF), 130pWEI (WEI), 137pWEI2 (WEI2), 135pZAIG (ZAIG), 140pZIP (ZIP ), 142

Q.stats , 108qBB (BB), 6qBCCG(BCCG), 8qBCPE(BCPE), 10qBCT(BCT), 12qBE (BE), 17qBEINF (BEINF), 15qBI (BI ), 21qGA(GA), 57qGU(GU), 60qIG (IG ), 65qJSU (JSU), 69qJSUo (JSUo), 67qLNO(LNO), 71qLO (LO), 73qLOGNO(LNO), 71qNBI (NBI ), 84qNBII (NBII ), 82qNO(NO), 87qNO.var (NO.var ), 89qPE (PE), 93qPIG (PIG), 95qPO(PO), 99qRG(RG), 117qSEP(SEP), 120qSI (SI ), 122qTF (TF), 130qWEI (WEI), 137qWEI2 (WEI2), 135qZAIG (ZAIG), 140qZIP (ZIP ), 142

ra , 50, 51, 111, 113random , 50, 51, 76, 109, 111–113rBB (BB), 6rBCCG(BCCG), 8rBCPE (BCPE), 10rBCT (BCT), 12rBE (BE), 17rBEINF (BEINF), 15rBI (BI ), 21rc , 52, 112refit , 41, 113rent , 114residuals.gamlss , 38, 116, 117, 132RG, 44, 45, 117rGA (GA), 57rGU (GU), 60rIG (IG ), 65rJSU (JSU), 69rJSUo (JSUo), 67rLNO (LNO), 71rLO (LO), 73rLOGNO(LNO), 71rNBI (NBI ), 84rNBII (NBII ), 82rNO (NO), 87rNO.var (NO.var ), 89rPE (PE), 93rPIG (PIG), 95rPO (PO), 99rqres.plot , 116, 119rRG (RG), 117rSEP (SEP), 120rSI (SI ), 122rTF (TF), 130rWEI (WEI), 137rWEI2 (WEI2), 135rZAIG (ZAIG), 140rZIP (ZIP ), 142

SEP, 120show.link (make.link.gamlss ), 77SI , 44, 83, 85, 96, 122stepGAIC , 57, 124summary.gamlss , 38, 117, 127, 132

term.plot , 128termplot , 129terms.gamlss

(model.frame.gamlss ), 80TF, 44, 45, 130

update , 114update.gamlss , 38, 114, 117, 131

Page 150: The gamlss Package - University of Aucklandftp.auckland.ac.nz/software/CRAN/doc/packages/gamlss.pdf · BI ... JSU ... Instructions on how to use the GAMLSS package in R. Accompanying

150 INDEX

usair , 133

vc (cs ), 31VGD, 134

WEI, 44, 45, 136, 137WEI2, 44, 45, 135, 138wp, 109, 138

ZAIG, 44, 140ZIP , 44, 45, 142