term.plot: Plot regression terms for a specified parameter of a fitted...

term.plotR Documentation

Plot regression terms for a specified parameter of a fitted GAMLSS object

Description

Plots regression terms against their predictors, optionally with standard errors and partial residuals added. It is based on the R function termplot but is suitably changed to apply to GAMLSS objects.

Usage

term.plot(object, what = c("mu", "sigma", "nu", "tau"), 
         parameter= NULL, data = NULL, 
         envir = environment(formula(object)), partial.resid = FALSE, 
         rug = FALSE, terms = NULL, se = TRUE, ylim = c("common", "free"), 
         scheme = c("shaded", "lines"), xlabs = NULL, ylabs = NULL, 
         main = NULL, pages = 0, col.term = "darkred", 
         col.se = "orange", col.shaded = "gray", col.res = "lightblue", 
         col.rug = "gray", lwd.term = 1.5, lty.se = 2, lwd.se = 1, 
         cex.res = 1, pch.res = par("pch"), 
         ask = interactive() && nb.fig < n.tms && .Device != "postscript", 
         use.factor.levels = TRUE, surface.gam = FALSE,     
         polys = NULL, polys.scheme = "topo",...)

Arguments

object

a fitted GAMLSS object

what

the required parameter of the GAMLSS distribution i.e. "mu"

parameter

equivalent to what

data

data frame in which variables in object can be found

envir

environment in which variables in object can be found

partial.resid

logical; should partial residuals be plotted or not

rug

add rug plots (jitter 1-d histograms) to the axes?

terms

which terms to be plotted (default 'NULL' means all terms)

se

plot point-wise standard errors?

ylim

there are two options here a) "common" and b) "free". The "common" option plots all figures with the same ylim range and therefore allows the viewer to check the relative contribution of each terms compare to the rest. In the‘free’ option the limits are computed for each plot separately.

scheme

whether the se's should appear shaded or as lines

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 main title, 'NULL' or 'FALSE' mean no titles.

pages

in how many pages the plot should appear. The default is 0 which allows different page for each plot

col.term

the colour of the term line

col.se

the colour of the se's lines

col.shaded

the colour of the shaded area

col.res

the colour of the partial residuals

col.rug

the colour of the rug

lwd.term

line width of the fitted terms

lty.se

line ype for standard errors

lwd.se

line width for the stadard errors

cex.res

plotting character expansion for the partial residuals

pch.res

characters for points in the partial residuals

ask

logical; if 'TRUE', the user is asked before each plot, see 'par(ask=.)'.

use.factor.levels

Should x-axis ticks use factor levels or numbers for factor terms?

surface.gam

whether to use surface plot if a ga() term is fitted

polys

The polygon information file for MRF models

polys.scheme

Color scheme for polygons for RMF models

...

other graphical parameters

Details

The function uses the lpred 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.

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 and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

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

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

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

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

See Also

termplot

Examples

data(aids)
a<-gamlss(y~pb(x)+qrt,data=aids,family=NBI)
term.plot(a, pages=1)
rm(a)

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