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

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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 compate to the rest. In the‘free’ option the limits are computed for each plot seperatly.

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 differnt 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 parsial residuals

pch.res

characters for points in the parsial 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 polygone nformation filr for MRF models

polys.scheme

Color scheme for polygones 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

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

Example output

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

GAMLSS-RS iteration 1: Global Deviance = 373.1785 
GAMLSS-RS iteration 2: Global Deviance = 366.4869 
GAMLSS-RS iteration 3: Global Deviance = 366.9278 
GAMLSS-RS iteration 4: Global Deviance = 366.9262 
GAMLSS-RS iteration 5: Global Deviance = 366.9258 

gamlss documentation built on March 31, 2021, 5:10 p.m.