
Instructions on how to use the gamlss package in R Second Edition Mikis Stasinopoulos, Bob Rigby and Calliope Akantziliotou January 11, 2008 2 Preface This document contains a brief introduction to Generalized Additive Models for Location, Scale and Shape (GAMLSS)1 and information on how to install and use the gamlss package in R. The gamlss package is free software and comes with ABSOLUTELY NO WARRANTY. In this edition major changes have been made in Chapter 2, 3, 4 and in the Appendix. For any inquiry or problem please contact Mikis Stasinopoulos at [email protected] . h i The authors would appreciate any comments for the improvement of the package or this manual. Warning: The models described here are very flexible and therefore should be used with care. As simple advice start with a simple model and built it up do not attempt to fit overcomplex models that are not supported by your data compare results from several models 1 © The material contained here is the property of the authors and in no circumstances should be reproduced without the authors’ permission Contents 1 Introduction 13 1.1 WhatisGAMLSS ................................... 13 1.2 GAMLSS:thestatisticalmodel . ...... 13 2 The gamlss package 17 2.1 How to input the GAMLSS framework packages . ...... 17 2.2 The different functions of the gamlss package .................... 18 2.3 An introduction to the gamlss packages ....................... 21 3 The gamlss() function 29 3.1 Theargumentsofthefunction . ..... 29 3.1.1 Thealgorithms ................................. 31 3.1.2 The algorithmic control functions . ....... 32 3.1.3 Weighting out observations, the weight and data=subset() arguments . 35 3.2 Thegamlssobject ................................. 41 3.3 Therefitandupdatefunctions . ..... 45 3.3.1 refit() ...................................... 45 3.3.2 update()..................................... 46 3.4 Thepredictandlpredfunctions. ....... 48 3.5 The prof.dev and prof.term functions . ......... 55 3.6 Other gamlss functions................................. 63 4 Distributions 67 4.1 Different distributions in gamlss() .......................... 67 4.2 Amending and constructing a new distribution . .......... 73 4.3 Fitting distributions (with constant parameters) to a datasample. 77 4.3.1 Datawithsamplekurtosislessthan3 . ..... 78 4.3.2 Datawithsamplekurtosismorethan3 . .... 83 4.4 Plotting pdf’s using pdf.plot() ........................... 91 5 Additive terms 95 5.1 Cubic splines, the cs() function ........................... 96 5.2 Varying coefficient, the vc() function ........................ 97 5.3 Penalized splines, the ps() function ......................... 102 5.4 The loess function lo() ............................... 106 5.5 Fractional polynomials, the fp() function ...................... 109 5.6 Therandomeffectsfunctions . ..... 112 3 4 CONTENTS 5.6.1 The random function.............................. 112 5.6.2 The ra function ................................ 115 5.6.3 The random coefficient, rc,function ..................... 120 6 Diagnostics 121 6.1 The plot function ................................... 121 6.2 The wp() function ................................... 127 6.3 the Q.stats function.................................. 131 6.4 the rqres.plot function ............................... 132 7 Model selection 135 7.1 Model selection in gamlss ............................... 135 7.2 Selecting explanatory variables using addterm, dropterm, and stepGAIC ..... 136 7.3 Selecting hyperparameters using find.hyper .................... 148 8 Centiles 157 8.1 Plotting fitted values against one x variable using fitted.plot() .................................... 157 8.2 Plotting centiles curves using centiles() ...................... 158 8.2.1 The function centiles() ........................... 158 8.2.2 The function centiles.split() ....................... 162 8.2.3 The function centiles.com() ........................ 167 8.2.4 The function centiles.pred() ........................ 169 9 Examples 177 9.1 Theabdominalcircumferencedata . ....... 177 A Distributions in the gamlss packages 181 A.1 Continuous two parameter distributions on .................... 181 ℜ A.1.1 Normal (or Gausian) distribution (NO, NO2, NOF) . ....... 181 A.1.2 Logisticdistribution(LO) . ..... 182 A.1.3 Gumbel distribution (GU) . 182 A.1.4 Reverse Gumbel distribution (RG) . ..... 183 A.2 Continuous three parameter distributions on ................... 183 ℜ A.2.1 Exponential Gaussian distribution (exGAUS) . ......... 183 A.2.2 Power Exponential distribution (PE, PE2) . ........ 183 A.2.3 t familydistribution(TF) . 184 A.3 Continuous four parameter distributions on ................... 184 ℜ A.3.1 Exponential Generalized Beta type 2 distribution (EGB2)......... 184 A.3.2 Generalized t distribution(GT). 184 A.3.3 Johnson SU distribution (JSUo, JSU) . ..... 184 A.3.4 Normal-Exponential-t distribution(NET) . 185 A.3.5 Sinh-Arcsinh(SHASH) . 186 A.3.6 Skew Exponential Power type 1 distribution (SEP1) . ......... 186 A.3.7 Skew Exponential Power type 2 distribution (SEP2) . ......... 187 A.3.8 Skew Exponential Power type 3 distribution (SEP3) . ......... 187 A.3.9 Skew Exponential Power type 4 distribution (SEP4) . ......... 188 A.3.10 Skew t type1distribution(ST1) . 188 A.3.11 Skew t type2distribution(ST2) . 188 CONTENTS 5 A.3.12 Skew t type3distribution(ST3) . 188 A.3.13 Skew t type4distribution(ST4) . 189 A.3.14 Skew t type5distribution(ST5) . 189 A.4 Continuous one parameter distribution in + .................... 189 A.4.1 Exponential distribution (EXP) . .ℜ . ...... 189 A.5 Continuous two parameter distribution in + .................... 190 A.5.1 Gamma distribution (GA) . .ℜ . 190 A.5.2 Log Normal distribution (LOGNO, LNO) . .... 190 A.5.3 Inverse Gaussian distribution (IG) . ....... 190 A.5.4 Weibull distribution (WEI, WEI2, WEI3) . ...... 191 A.6 Continuous three parameter distribution in + ................... 191 A.6.1 Box-Cox Cole and Green distributionℜ (BCCG) . ...... 191 A.6.2 Generalized gamma distribution (GG, GG2) . ....... 192 A.6.3 Generalized inverse Gaussian distribution (GIG) . ........... 193 A.6.4 Zero adjusted Inverse Gaussian distribution (ZAIG) . ........... 193 A.7 Continuous four parameter distribution in + ................... 193 A.7.1 Box-Cox t distribution(BCT). .ℜ . 193 A.7.2 Box-Cox power exponential distribution (BCPE) . ......... 193 A.7.3 Generalized Beta type 2 distribution (GB2) . ........ 194 A.8 Continuous two parameter distribution in [0, 1] .................. 194 A.8.1 Betadistribution(BE,BEo) . .ℜ . 194 A.8.2 Beta inflated distribution (BEINF) . ...... 195 A.8.3 Generalized Beta type 1 distribution (GB1) . ........ 195 A.9 Binomialtypedata................................ 195 A.9.1 The Binomial distribution (BI) . ..... 195 A.9.2 Beta Binomial distribution (BB) . ..... 195 A.10Countdata ...................................... 196 A.10.1Poissondistribution(PO) . ..... 196 A.10.2 Negative Binomial distribution (NBI, NBII) . .......... 196 A.10.3 Poisson-inverse Gaussian distribution (PIG) . ............ 197 A.10.4 Delaportedistribution(DEL) . ...... 197 A.10.5 Sichel distribution (SI, SICHEL) . ....... 197 A.10.6 Zeroinflatedpoisson(ZIP,ZIP2) . ...... 198 Index 203 6 CONTENTS List of Figures 2.1 Aplotoftheabdominalcircumferencedata . ......... 21 2.2 Residual plot from the normal fitted model abd2 with µ = cs(x, 3) and log(σ)= cs(x, 3) 25 2.3 Worm plot from the normal fitted model abd2 with µ = cs(x, 3) and log(σ)= cs(x, 3) 26 3.1 Rent (R) against floor space (Fl) from the rent data . .......... 48 3.2 Profile global deviance for the degrees of freedom parameter of the t distribution fitted to the abdom data with µ = cs(x, 3) and σ = cs(x, 3) ........... 58 3.3 Profile global deviance for the linear trend parameter in the model gamlss(y x+qrt, data=aids, family=NBI) ............................... 60 3.4 Profile global deviance for the break point in the model gamlss(y x+(x>break)*(x- break)+qrt,data=aids,family=NBI) ........................ 62 3.5 Profile GAIC with penalty 2.5 for the degrees of freedom in the model gamlss(y cs(x,df=this) + qrt, data = aids, family = NBI) .............. 63 4.1 Rent (R) against floor space (Fl) from the rent data . .......... 69 4.2 Plots created by (a) dGA (b) pGA (c) qGA, and (d) rGA functions respectively, i.e. (a) the pdf (b) the cdf (c) the inverse cdf (or quantiles) and (d) a histogram of a random sample, from the gamma distribution. ....... 71 4.3 Plot created by (a) dNBI (b) pNBI (c) qNBI and (d) rNBI functions respectively, (a) the pdf (b) the cdf (c) the inverse cdf and (d) a histogram of a random sample, from the negative binomial distribution type I. ......... 72 4.4 An histogram of the y variable in the abdom data . ........ 78 4.5 Residual plot from fitting a Normal distribution with µ = 1 and σ = 1 to the abdomdata....................................... 79 4.6 The fitted BCPE distribution to the y variable of the abdom data ........ 82 4.7 The histogram and the fitted PE distribution to the y variable of the abdom data 83 4.8 Histogram of the subset of the head circumference Dutch boysdata. 84 4.9 Residual plot from the Normal (NO) fitted model on the subset of the Dutch boysdata ........................................ 85 4.10 Residual plot of the BCT model fitted in to the Dutch boys data ......... 87 4.11 The fitted BCT distribution to the Dutch boys data . .......... 88 4.12 The histigram and the fitted BCT distribution to the Dutchboysdata . 88 4.13 Residual plot of the BCPE model fitted to the subset of the Dutch
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages206 Page
-
File Size-