Learn R Programming

itsadug (version 0.8)

fvisgam: Visualization of nonlinear interactions.

Description

Produces perspective or contour plot views of gam model predictions of the additive effects interactions. The code is based on the script for vis.gam, but allows to cancel random effects.

Usage

fvisgam(x, view = NULL, cond = list(), n.grid = 30, too.far = 0,
  col = NA, color = "topo", contour.col = NULL, add.color.legend = TRUE,
  se = -1, plot.type = "contour", zlim = NULL, nCol = 50,
  rm.ranef = NULL, print.summary = TRUE, ...)

Arguments

x
A gam object, produced by gam or bam.
view
A two-value vector containing the names of the two main effect terms to be displayed on the x and y dimensions of the plot. 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.
n.grid
The number of grid nodes in each direction used for calculating the plotted surface.
too.far
Plot grid nodes that are too far from the points defined by the variables given in view can be excluded from the plot. too.far determines what is too far. The grid is scaled into the unit square along with the view variables and then grid nodes more than
col
The colors for the facets of the plot.
color
The color scheme to use for plots. One of "topo", "heat", "cm", "terrain", "gray" or "bw".
contour.col
sets the color of contours when using plot.
add.color.legend
Logical: whether or not to add a color legend. Default is TRUE. If FALSE (omitted), one could use the function gradientLegend to add a legend manually at any position.
se
If less than or equal to zero then only the predicted surface is plotted, but if greater than zero, then 3 surfaces are plotted, one at the predicted values minus se standard errors, one at the predicted values and one at the predicted values plus se stan
plot.type
one of "contour" or "persp" (default is "contour").
zlim
A two item array giving the lower and upper limits for the z- axis scale. NULL to choose automatically.
nCol
The number of colors to use in color schemes.
rm.ranef
Logical: whether or not to remove random effects. Default is TRUE.
print.summary
Logical: whether or not to print a summary.
...
other options to pass on to persp, image or contour. In particular ticktype="detailed" will add proper axes labeling to the plots.

See Also

vis.gam, plot.gam

Other functions for interpreting nonlinear effects: plotDiff2D, plot_diff2; plotDiff, plot_diff; plot_parametric; plot_smooth; pvis.gam, pvisgam

Examples

Run this code
data(simdat)

# Model with random effect and interactions:
m1 <- bam(Y ~ te(Time, Trial)+s(Time, Subject, bs='fs', m=1),
    data=simdat)

# Plot summed effects:
vis.gam(m1, view=c("Time", "Trial"), plot.type='contour', color='topo')
# Same plot:
fvisgam(m1, view=c("Time", "Trial"), rm.ranef=FALSE)
# Without random effects included:
fvisgam(m1, view=c("Time", "Trial"), rm.ranef=TRUE)
# see the vignette for examples:
vignette("plotfunctions", package="itsadug")

Run the code above in your browser using DataLab