library("gamlss2")
data("film90", package = "gamlss.data")
## model formula
f <- ~ s(lboopen) + s(lnosc)
f <- rep(list(f), 4)
f[[1]] <- update(f[[1]], lborev1 ~ .)
## estimate model
m1 <- gamlss2(f, data = film90, family = BCCG)
## plot effects (default)
plot(m1)
## plot specific effect
plot(m1, parameter = "sigma")
plot(m1, model = "sigma")
plot(m1, model = "nu", terms = 1)
plot(m1, model = "nu", terms = 2)
plot(m1, model = "nu", terms = "lnosc")
plot(m1, terms = "lnosc")
## plot all residual diagnostics
plot(m1, which = "resid")
## single diagnostic plots
plot(m1, which = "hist-resid")
plot(m1, which = "qq-resid")
plot(m1, which = "wp-resid")
plot(m1, which = "scatter-resid")
## if available, plot stored stepwise-selection path
## plot(m1, which = "selection")
## estimate another model
m2 <- gamlss2(f, data = film90, family = BCPE)
## compare estimated effects
plot(c(m1, m2))
plot(c(m1, m2), terms = "lboopen",
col = c(1, 4), lwd = 3, lty = 1,
pos = c("topleft", "topright", "bottomleft", "bottomright"))
plot(c(m1, m2), model = "sigma")
plot(c(m1, m2), model = "sigma", terms = 2)
plot(c(m1, m2), model = c("mu", "nu"))Plotting GAMLSS
Description
Plotting methods for objects of class “gamlss2” and “gamlss2.list”. These methods support effect plots for model terms and residual diagnostics. Effect plots for model terms with more than two covariates are not supported; in such cases, use predict and plot the results manually.
Usage
## S3 method for class 'gamlss2'
plot(x, parameter = NULL,
which = "effects", terms = NULL,
scale = TRUE, spar = TRUE, ...)
## S3 method for class 'gamlss2.list'
plot(x, parameter = NULL, which = "effects",
terms = NULL, spar = TRUE, legend = TRUE, ...)
Arguments
x
|
An object of class “gamlss2” or “gamlss2.list”. Objects of class “gamlss2.list” can be created by combining “gamlss2” objects with c(). See the examples.
|
parameter
|
Character or integer specifying for which distribution parameter the plots should be created. The arguments model and what, if supplied through …, are treated as aliases for parameter to support alternative calling styles.
|
which
|
Character or integer selecting the type of plot. “effects” produces effect plots of model terms, “resid” shows the available residual diagnostics, “hist-resid” produces a histogram of residuals, “qq-resid” a quantile-quantile plot of residuals, “wp-resid” a worm plot of residuals, and “scatter-resid” a scatter plot of residuals against fitted values for the distribution mean (or median, if available in the family object). In addition, “selection” plots the GAIC path stored for a fitted stepwise or selection object, and “samples” visualizes posterior or simulation draws for objects that contain samples.
|
terms
|
Character or integer. Which model term(s) should be plotted? |
scale
|
Logical. If TRUE, effect plots all have the same scale on the y-axis. If FALSE, each effect plot has its own y-axis scale.
|
spar
|
Logical. Should graphical parameters be set automatically? |
legend
|
Logical. Should a legend be added for plots with multiple models? |
…
|
Additional graphical arguments such as lwd, lty, col, legend = TRUE (for multiple model plots), among others, depending on the type of plot. Arguments model and what are treated as aliases for parameter.
|
Details
For objects of class “gamlss2”, which = “effects” is the default and plots the partial effects stored in results(object). If no effect information is available, residual diagnostics are shown instead.
For objects of class “gamlss2.list”, plots compare effect estimates across several fitted models. Residual diagnostics are only available for single-model objects.
See Also
gamlss2.