plotSimpleGamlss: Plotting a simple GAMLSS model for demonstration purpose

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This is to plot a simple GAMLSS model where only one explanatory variable exist in order to demonstrated how the distribution of the response changes according to values of the explanatory variable.

Usage

1
2
3
plotSimpleGamlss(y, x, model = NULL, formula = NULL, data = NULL, 
         family = NULL, val = NULL, N = 1000, x.val = quantile(x), 
         ylim = c(min(y), max(y)), xlim = c(min(x), max(x)), ...)

Arguments

y

The response variable

x

The explanatory variable (only one is allowed here)

model

A fitted gamlss model

formula

A formula for the mean model if model=NULL

data

The data where the response and the one explanatory can be found

family

The gamlss family distribution

val

this parameter determines how the plotted distribution is shown, increase/decrease it if the distribution is not shown properly

N

This parameters determine how many values of y are generated for each x.var

x.val

the values of the explanatory variable where we want to see the distribution

ylim

the y limits in the plot

xlim

the x limits in the plot

...

extra argument to be passed to gamlss() function if model=NULL

Details

This function is for pedagogical purpose rather than fitting models to demonstrate that the distribution of the response variable can vary according to explanatory variables. In its current from it can be used with continuous and discrete responses only.

Value

A plot is shown

Author(s)

Mikis Stasinopoulos d.stasinopoulos@londonmet.ac.uk

References

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

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

See Also

scattersmooth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## the abdominal data
m1 <- gamlss(y~pb(x), sigma.fo=~pb(x), data=abdom, family=LO)
plotSimpleGamlss(y,x, model=m1,   data=abdom, x.val=seq(15, 40, 5), 
                    ylim=c(0, 450), xlim=c(5, 45))
data(species)
species$ll <- log(species$lake)
m2 <- gamlss(fish~ll, data=species, trace=FALSE, family=PO )
plotSimpleGamlss(fish,ll, model=m2,   data=species, x.val=c(3,5,7, 9),
                  val=20, N=100, ylim=c(0,80))
 m3 <- gamlss(fish~ll, data=species, trace=FALSE, family=NBI, sigma.fo=~ll )
plotSimpleGamlss(fish,ll, model=m3,   data=species, x.val=c(3,5,7, 9),
                    val=20, N=100, ylim=c(0,100))
## Not run: 
##------------------------------------------------------------------------------
## the rent data 
## fitting the model first 
r1 <- gamlss(R~pb(Fl), sigma.fo=~pb(Fl),data=rent, family=GA, ylim=c(0, 3000))
## plot 1
plotSimpleGamlss(R,Fl, model=r1,   data=rent, x.val=seq(40,120, 5))
## plot 2 finer grid 
plotSimpleGamlss(R,Fl, model=r1,   data=rent, x.val=seq(40,120, 1), 
                  xlim=c(10,120))
##  the same but fitting the model within the function
## note that sigma formula has to be specified 
plotSimpleGamlss(R,Fl, formula= R~pb(Fl),   family=GA, data=rent, 
                    x.val=seq(40,120, 5), sigma.fo=~pb(Fl))
#------------------------------------------------------------------------------

## End(Not run)

Example output

Loading required package: gamlss.dist
Loading required package: MASS
Loading required package: gamlss
Loading required package: splines
Loading required package: gamlss.data
Loading required package: nlme
Loading required package: parallel
 **********   GAMLSS Version 5.1-2  ********** 
For more on GAMLSS look at http://www.gamlss.org/
Type gamlssNews() to see new features/changes/bug fixes.

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

GAMLSS-RS iteration 1: Global Deviance = 4782.6 
GAMLSS-RS iteration 2: Global Deviance = 4779.267 
GAMLSS-RS iteration 3: Global Deviance = 4779.279 
GAMLSS-RS iteration 4: Global Deviance = 4779.279 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
GAMLSS-RS iteration 1: Global Deviance = 28042.49 
GAMLSS-RS iteration 2: Global Deviance = 28043.38 
GAMLSS-RS iteration 3: Global Deviance = 28043.38 
GAMLSS-RS iteration 4: Global Deviance = 28043.38 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 
new prediction 
New way of prediction in pb()  (starting from GAMLSS version 5.0-3) 

gamlss.util documentation built on May 2, 2019, 7:10 a.m.