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.
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",...)
a plot of fitted terms.
a fitted GAMLSS object
the required parameter of the GAMLSS distribution i.e. "mu"
equivalent to what
data frame in which variables in object
can be found
environment in which variables in object
can be found
logical; should partial residuals be plotted or not
add rug plots (jitter 1-d histograms) to the axes?
which terms to be plotted (default 'NULL' means all terms)
plot point-wise standard errors?
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.
whether the se's should appear shaded or as lines
vector of labels for the x axes
vector of labels for the y axes
logical, or vector of main titles; if 'TRUE', the model's call is taken as main title, 'NULL' or 'FALSE' mean no titles.
in how many pages the plot should appear. The default is 0 which allows different page for each plot
the colour of the term line
the colour of the se's lines
the colour of the shaded area
the colour of the partial residuals
the colour of the rug
line width of the fitted terms
line ype for standard errors
line width for the stadard errors
plotting character expansion for the partial residuals
characters for points in the partial residuals
logical; if 'TRUE', the user is asked before each plot, see 'par(ask=.)'.
Should x-axis ticks use factor levels or numbers for factor terms?
whether to use surface plot if a ga()
term is fitted
The polygon information file for MRF models
Color scheme for polygons for RMF models
other graphical parameters
Mikis Stasinopoulos based on the existing termplot() function
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.
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/).
data(aids)
a<-gamlss(y~pb(x)+qrt,data=aids,family=NBI)
term.plot(a, pages=1)
rm(a)
Run the code above in your browser using DataLab