The first derivative of the smooth functions of a GAM model calculated using finite differences.
fderiv(model, ...) # S3 method for gam fderiv(model, newdata, term, n = 200, eps = 1e-07, unconditional = FALSE, offset = NULL, ...) # S3 method for gamm fderiv(model, ...)
Arguments that are passed to other methods.
a data frame containing the values of the model covariates at which to evaluate the first derivatives of the smooths.
character; vector of one or more terms for which derivatives are required. If missing, derivatives for all smooth terms will be returned.
numeric; the value of the finite difference used to approximate the first derivative.
numeric; value of offset to use in generating predictions.
An object of class
"fderiv" is returned.
dat <- gamSim(1, n = 400, dist = "normal", scale = 2)#> Gu & Wahba 4 term additive modelmod <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML") ## first derivatives of all smooths... fd <- fderiv(mod) ## ...and a selected smooth fd2 <- fderiv(mod, term = "x1") ## Models with factors set.seed(2) dat <- gamSim(4, n = 400, dist = "normal", scale = 2)#> Factor `by' variable example