difference_smooths | R Documentation |
Estimates pairwise differences (comparisons) between factor smooth
interactions (smooths with a factor by
argument) for pairs of groups
defined by the factor. The group means can be optionally included in the
difference.
difference_smooths(model, ...) ## S3 method for class 'gam' difference_smooths( model, smooth, n = 100, ci_level = 0.95, data = NULL, group_means = FALSE, partial_match = TRUE, unconditional = FALSE, frequentist = FALSE, ... )
model |
A fitted model. |
... |
arguments passed to other methods. Not currently used. |
smooth |
character; which smooth to compute differences for. |
n |
numeric; the number of points at which to evaluate the difference between pairs of smooths. |
ci_level |
numeric between 0 and 1; the coverage of credible interval. |
data |
data frame of locations at which to evaluate the difference between smooths. |
group_means |
logical; should the group means be included in the difference? |
partial_match |
logical; should |
unconditional |
logical; account for smoothness selection in the model? |
frequentist |
logical; use the frequentist covariance matrix? |
load_mgcv() df <- data_sim("eg4", seed = 42) m <- gam(y ~ fac + s(x2, by = fac) + s(x0), data = df, method = "REML") sm_dif <- difference_smooths(m, smooth = "s(x2)") sm_dif draw(sm_dif) # include the groups means for `fac` in the difference sm_dif2 <- difference_smooths(m, smooth = "s(x2)", group_means = TRUE) draw(sm_dif2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.