Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compare_smooths

Compare smooths across models


Description

Compare smooths across models

Usage

compare_smooths(
  model,
  ...,
  smooths = NULL,
  n = 100,
  data = NULL,
  unconditional = FALSE,
  overall_uncertainty = TRUE
)

Arguments

model

Primary model for comparison.

...

Additional models to compare smooths against those of model.

smooths

character; vector of smooths to compare. If not specified comparisons will be performed for smooths common to all models supplied.

n

numeric; the number of points over the range of the covariate at which to evaluate the smooth.

data

a vector or data frame of points at which to evaluate the smooth.

unconditional

logical; should confidence intervals include the uncertainty due to smoothness selection? If TRUE, the corrected Bayesian covariance matrix will be used.

overall_uncertainty

logical; should the uncertainty in the model constant term be included in the standard error of the evaluate values of the smooth?

Examples

load_mgcv()
dat <- data_sim("eg1", seed = 2)

## models to compare smooths across - artificially create differences
m1 <- gam(y ~ s(x0, k = 5) + s(x1, k = 5) + s(x2, k = 5) + s(x3, k = 5),
          data = dat, method = "REML")
m2 <- gam(y ~ s(x0, bs = 'ts') + s(x1, bs = 'ts') + s(x2, bs = 'ts') +
          s(x3, bs = 'ts'), data = dat, method = "REML")

## build comparisons
comp <- compare_smooths(m1, m2)
comp
## notice that the result is a nested tibble

draw(comp)

gratia

Graceful 'ggplot'-Based Graphics and Other Functions for GAMs Fitted Using 'mgcv'

v0.6.0
MIT + file LICENSE
Authors
Gavin L. Simpson [aut, cre] (<https://orcid.org/0000-0002-9084-8413>), Henrik Singmann [ctb] (<https://orcid.org/0000-0002-4842-3657>)
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.