| derivatives | R Documentation |
Derivatives of estimated smooths via finite differences
derivatives(object, ...)
## Default S3 method:
derivatives(object, ...)
## S3 method for class 'gamm'
derivatives(object, ...)
## S3 method for class 'gam'
derivatives(
object,
select = NULL,
term = deprecated(),
data = newdata,
order = 1L,
type = c("forward", "backward", "central"),
n = 100,
eps = 1e-07,
interval = c("confidence", "simultaneous"),
n_sim = 10000,
level = 0.95,
unconditional = FALSE,
frequentist = FALSE,
offset = NULL,
ncores = 1,
partial_match = FALSE,
...,
newdata = NULL
)
object |
an R object to compute derivatives for. |
... |
arguments passed to other methods. |
select |
character; select which smooth's posterior to draw from.
The default ( |
term |
|
data |
a data frame containing the values of the model covariates at which to evaluate the first derivatives of the smooths. |
order |
numeric; the order of derivative. |
type |
character; the type of finite difference used. One of
|
n |
numeric; the number of points to evaluate the derivative at. |
eps |
numeric; the finite difference. |
interval |
character; the type of interval to compute. One of
|
n_sim |
integer; the number of simulations used in computing the simultaneous intervals. |
level |
numeric; |
unconditional |
logical; use smoothness selection-corrected Bayesian covariance matrix? |
frequentist |
logical; use the frequentist covariance matrix? |
offset |
numeric; a value to use for any offset term |
ncores |
number of cores for generating random variables from a
multivariate normal distribution. Passed to |
partial_match |
logical; should smooths be selected by partial matches
with |
newdata |
Deprecated: use |
A tibble, currently with the following variables:
.smooth: the smooth each row refers to,
.by: the name of any factor by variable involved in the smooth,
.fs: the name of any random factor variable involved in the smooth,
.derivative: the estimated derivative,
.se: the standard error of the estimated derivative,
.crit: the critical value such that derivative ± (crit * se) gives
the upper and lower bounds of the requested confidence or simultaneous
interval (given level),
.lower_ci: the lower bound of the confidence or simultaneous interval,
.upper_ci: the upper bound of the confidence or simultaneous interval.
plus one or more columns of data containing the values of covariates at which the derivative was evaluated.
derivatives() will ignore any random effect smooths it encounters in
object.
Gavin L. Simpson
load_mgcv()
dat <- data_sim("eg1", n = 400, dist = "normal", scale = 2, seed = 42)
mod <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML")
## first derivatives of all smooths using central finite differences
derivatives(mod, type = "central")
## derivatives for a selected smooth
derivatives(mod, type = "central", select = "s(x1)")
## or via a partial match
derivatives(mod, type = "central", select = "x1", partial_match = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.