Learn R Programming

gamlss.util (version 4.2-7)

plotSimpleGamlss: Plotting a simple GAMLSS model for demonstration purpose

Description

This is a facility 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

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

Value

A plot is shown

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.

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

Run this code
## 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))
##------------------------------------------------------------------------------
## 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))
#------------------------------------------------------------------------------

Run the code above in your browser using DataLab