Learn R Programming

itsadug (version 2.0)

rug_model: Add rug to plot, based on model.

Description

Add rug based on model data.

Usage

rug_model(model, view, cond = NULL, data.rows = NULL, rm.ranef = NULL,
  print.summary = getOption("itsadug_print"), ...)

Arguments

model
gam or bam object.
view
Text string containing the name of the smooth to be displayed. Note that variables coerced to factors in the model formula won't work as view variables.
cond
A named list of the values to use for the other predictor terms (not in view). Used for choosing between smooths that share the same view predictors.
data.rows
Vector of numbers (indices of rows in data) or vector of logical vales (same length as rows in data) for selecting specific data points.
rm.ranef
Logical: whether or not to remove random effects. Default is TRUE.
print.summary
Logical: whether or not to print information messages. Default set to the print info messages option (see infoMessages).
...
Optional graphical parameters (see rug).

See Also

Other Functions for plotting: addInterval, add_bars, alphaPalette, alpha, check_normaldist, color_contour, dotplot_error, drawArrows, emptyPlot, errorBars, fadeRug, fill_area, getCoords, getFigCoords, getProps, gradientLegend, marginDensityPlot, plot_error, plot_image, plotsurface

Examples

Run this code
plot(cars$speed, cars$dist, pch=16, col=alpha(1))
lm1 <- lm(dist ~ speed, dat=cars)
abline(lm1, col='red', lwd=2)
rug_model(lm1, view="speed")
rug_model(lm1, view="dist", side=2)

library(itsadug)
data(simdat)
m1 <- bam(Y ~ Group + te(Time, Trial, by=Group), data=simdat)
# plot:
fvisgam(m1, view=c("Time", "Trial"), cond=list(Group="Adults"))
rug_model(m1, view="Time", cond=list(Group="Adults"))
rug_model(m1, view="Trial", cond=list(Group="Adults"), side=2)

Run the code above in your browser using DataLab