evaluate_smooth | R Documentation |
Evaluate a smooth at a grid of evenly spaced value over the range of the covariate associated with the smooth. Alternatively, a set of points at which the smooth should be evaluated can be supplied.
evaluate_smooth(object, ...) ## S3 method for class 'gam' evaluate_smooth( object, smooth, n = 100, newdata = NULL, unconditional = FALSE, overall_uncertainty = TRUE, dist = 0.1, ... ) ## S3 method for class 'gamm' evaluate_smooth(object, ...) ## S3 method for class 'list' evaluate_smooth(object, ...)
object |
an object of class |
... |
arguments passed to other methods. |
smooth |
character; a single smooth to evaluate. |
n |
numeric; the number of points over the range of the covariate at which to evaluate the smooth. |
newdata |
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 |
overall_uncertainty |
logical; should the uncertainty in the model constant term be included in the standard error of the evaluate values of the smooth? |
dist |
numeric; if greater than 0, this is used to determine when
a location is too far from data to be plotted when plotting 2-D smooths.
The data are scaled into the unit square before deciding what to exclude,
and |
evaluate_smooth()
is deprecated in
favour of smooth_estimates()
, which provides a cleaner way to evaluate a
smooth over a range of covariate values. smooth_estimates()
can handle a
much wider range of models than evaluate_smooth()
is capable of and
smooth_estimates()
is much easier to extend to handle new smooth types.
Most code that uses evaluate_smooth()
should work simply by changing the
function call to smooth_estimates()
. However, there are some differences:
the newdata
argument becomes data
Consider evaluate_smooth()
to be soft-deprecated; its use is discouraged
and it may be removed at a later date if it becomes difficult to maintain
the current functionality, but there are no intentions of removing it from
gratia unless that situation arises.
A data frame, which is of class "evaluated_1d_smooth"
or
evaluated_2d_smooth
, which inherit from classes "evaluated_smooth"
and "data.frame"
.
load_mgcv() dat <- data_sim("eg1", n = 500, dist = "normal", scale = 1, seed = 2) m1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML") evaluate_smooth(m1, "s(x1)") ## 2d example dat <- data_sim("eg2", n = 1000, dist = "normal", scale = 1, seed = 2) m2 <- gam(y ~ s(x, z, k = 30), data = dat, method = "REML") evaluate_smooth(m2, "s(x,z)", n = 50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.