plot_parametric: Visualization of group estimates.

View source: R/inspect.R

plot_parametricR Documentation

Visualization of group estimates.

Description

Plots a smooth from a gam or bam model based on predictions. In contrast with the default plot.gam, this function plots the summed effects and optionally removes the random effects.

Usage

plot_parametric(
  x,
  pred,
  cond = list(),
  parametricOnly = FALSE,
  rm.ranef = TRUE,
  col = "black",
  se = 1.96,
  print.summary = getOption("itsadug_print"),
  main = NULL,
  xlab = NULL,
  ...
)

Arguments

x

A gam object, produced by gam or bam.

pred

A named list of the values to use for the predictor terms to plot.

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.

parametricOnly

Logical: whether or not to cancel out all smooth terms and only use the predictors in the parametric summary.

rm.ranef

Logical: whether or not to remove random effects. Default is TRUE.

col

The colors for the lines and the error bars of the plot.

se

If less than or equal to zero then only the predicted surface is plotted, but if greater than zero, then the predicted values plus confidence intervals are plotted. The value of se will be multiplied with the standard error (i.e., 1.96 results in 95%CI and 2.58).

print.summary

Logical: whether or not to print summary. Default set to the print info messages option (see infoMessages).

main

Changing the main title for the plot, see also title.

xlab

Changing the label for the x axis, defaults to a description of x.

...

other options to pass on to dotplot_error, see par

Warning

Use parametricOnly with care! When set to TRUE, all smooth predictors are set to 0. Note that this might result in strange predictions, because a value of 0 does not always represents a realistic situation (e.g., body temperature of 0 is highly unlikely). Note that linear slopes are not set to zero, because they are considered as parametric terms. If cond does not specify a value for these continuous predictors, the closes value to the mean is automatically selected.

Author(s)

Jacolien van Rij, based on a function of Fabian Tomaschek

See Also

plot.gam

Other Functions for model inspection: dispersion(), fvisgam(), gamtabs(), inspect_random(), plot_data(), plot_smooth(), plot_topo(), pvisgam()

Examples

data(simdat)
## Not run: 
m1 <- bam(Y ~ Group + te(Time, Trial, by=Group)
    + s(Time, Subject, bs='fs', m=1), data=simdat)
plot_parametric(m1, pred=list(Group=c('Adults', 'Children')))
# Note the summary that is printed.

# use rm.ranef to cancel random effects:
plot_parametric(m1, pred=list(Group=c('Adults', 'Children')),
    rm.ranef = TRUE)

# It is possible to get estimates that do not make sense:
out <- plot_parametric(m1, 
    pred=list(Group=c('Adults', 'Children'), Subject=c('a01', 'a02', 'c01')))
print(out)

## End(Not run)

# see the vignette for examples:
vignette('overview', package='itsadug')

itsadug documentation built on June 17, 2022, 5:05 p.m.