Partial residuals for models can be computed with
partial_residuals(). The partial residuals are the weighted residuals of the model added to the contribution of each smooth term (as returned by
predict(model, type = "terms").
Also, new function
add_partial_residuals() can be used to add the partial residuals to data frames.
Users can now control to some extent what colour or fill scales are used when plotting smooths in those
draw() methods that use them. This is most useful to change the fill scale when plotting 2D smooths, or to change the discrete colour scale used when plotting random factor smooths (
bs = "fs").
The user can pass scales via arguments
The effects of certain smooths can be excluded from data simulated from a model using
predicted_samples() by passing
terms on to
predict.gam(). This allows for excluding random effects, for example, from model predicted values that are then used to simulate new data from the conditional distribution. See the example in
draw.gam() can now include partial residuals when drawing univariate smooths. Use
residuals = TRUE to add partial residuals to each univariate smooth that is drawn. This feature is not available for smooths of more than one variable, by smooths, or factor-smooth interactions (
bs = "fs").
The coverage of credible and confidence intervals drawn by
draw.gam() can be specified via argument
ci_level. The default is arbitrarily
0.95 for no other reason than (rough) compatibility with
This change has had the effect of making the intervals slightly narrower than in previous versions of gratia; intervals were drawn at ± 2 × the standard error. The default intervals are now drawn at ± ~1.96 × the standard error.
difference_smooths() for computing differences between factor smooth interactions. Methods available for
gamm4::gamm4(). Also has a
draw() method, which can handle differences of 1D and 2D smooths currently (handling 3D and 4D smooths is planned).
data_sim() is a tidy reimplementation of
mgcv::gamSim() with the added ability to use sampling distributions other than the Gaussian for all models implemented. Currently Gaussian, Poisson, and Bernoulli sampling distributions are available.
smooth_samples() can handle continuous by variable smooths such as in varying coefficient models.
data_slice() can generate data for a 1-d slice (a single variable varying).
The colour of the points, reference lines, and simulation band in
appraise() can now be specified via arguments
Added utility functions
term_variables() for working with models.
is_factor_term() identifies is the named term is a factor using information from the
terms() object of the fitted model.
term_variables() returns a character vector of variable names that are involved in a model term. These are strictly for working with parametric terms in models.
appraise() also works for models fitted with family
gaulss(). Further location scale models and models fitted with extended family functions will be supported in upcoming releases.
datagen() method for class
"gam" couldn’t possibly have worked for anything but the simplest models and would fail even with simple factor by smooths. These issues have been fixed, but the behaviour of
datagen() has changed, and the function is now not intended for use by users.
Fixed an issue where in models terms of the form
factor1:factor2 were incorrectly identified as being numeric parametric terms. #68
Methods for classes:
"gamm" currently. #58
family() methods for objects of classes
basis() for generating tidy representations of basis expansions from an mgcv-like definition of a smooth, e.g.
t2(). The basic smooth types also have a simple
draw() method for plotting the basis.
basis() is a simple wrapper around
mgcv::smoothCon() with some post processing of the basis model matrix into a tidy format. #42
evaluate_parametric_term() and hence
draw.gam() would fail on a
ziplss() model because i) gratia didn’t handle parametric terms in models with multiple linear predictors correctly, and ii) gratia didn’t convert to the naming convention of mgcv for terms in higher linear predictors. Reported by @pboesu #45.