Package: gratia 0.9.2.9011

gratia: Graceful 'ggplot'-Based Graphics and Other Functions for GAMs Fitted Using 'mgcv'

Graceful 'ggplot'-based graphics and utility functions for working with generalized additive models (GAMs) fitted using the 'mgcv' package. Provides a reimplementation of the plot() method for GAMs that 'mgcv' provides, as well as 'tidyverse' compatible representations of estimated smooths.

Authors:Gavin L. Simpson [aut, cre, cph], Henrik Singmann [ctb]

gratia_0.9.2.9011.tar.gz
gratia_0.9.2.9011.zip(r-4.5)gratia_0.9.2.9011.zip(r-4.4)gratia_0.9.2.9011.zip(r-4.3)
gratia_0.9.2.9011.tgz(r-4.4-any)gratia_0.9.2.9011.tgz(r-4.3-any)
gratia_0.9.2.9011.tar.gz(r-4.5-noble)gratia_0.9.2.9011.tar.gz(r-4.4-noble)
gratia_0.9.2.9011.tgz(r-4.4-emscripten)gratia_0.9.2.9011.tgz(r-4.3-emscripten)
gratia.pdf |gratia.html
gratia/json (API)
NEWS

# Install 'gratia' in R:
install.packages('gratia', repos = c('https://gavinsimpson.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/gavinsimpson/gratia/issues

Datasets:
  • bird_move - Simulated bird migration data
  • gss_vocab - Data from the General Social Survey (GSS) from the National Opinion Research Center of the University of Chicago
  • ref_sims - Reference simulation data
  • smallAges - Lead-210 age-depth measurements for Small Water
  • zooplankton - Madison lakes zooplankton data

On CRAN:

gamgeneralized-additive-modelsggplot2glmlmmgcvrandom-effectssmoothing

12.47 score 206 stars 1 packages 1.3k scripts 3.6k downloads 11 mentions 116 exports 42 dependencies

Last updated 3 hours agofrom:9b75e13f58. Checks:OK: 5 NOTE: 2. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 21 2024
R-4.5-winNOTENov 21 2024
R-4.5-linuxNOTENov 21 2024
R-4.4-winOKNov 21 2024
R-4.4-macOKNov 21 2024
R-4.3-winOKNov 21 2024
R-4.3-macOKNov 21 2024

Exports:add_confintadd_constantadd_fittedadd_fitted_samplesadd_partial_residualsadd_posterior_samplesadd_predicted_samplesadd_residualsadd_sizeradd_smooth_samplesappraisebasisbasis_sizeboundaryby_levelby_variablecheck_is_mgcv_smoothcompare_smoothsconcrvitydata_combosdata_simdata_slicederivative_samplesderivativesdifference_smoothsdispersiondrawedfeval_smoothevaluate_parametric_termevaluate_smoothevenlyextract_linkfactor_combosfamily_namefamily_typefderivfitted_samplesfitted_valuesfix_offsetfixed_effectsfixefgaussian_drawsgenerate_drawsget_by_smoothget_smoothget_smooths_by_idgw_f0gw_f1gw_f2gw_f3has_thetainv_linkis_by_smoothis_continuous_by_smoothis_factor_by_smoothis_factor_termis_mgcv_smoothis_mrf_smoothis_offsetlevellinkload_mgcvlp_matrixmh_drawsmodel_concurvitymodel_constantmodel_edfmodel_varsn_etan_smoothsnb_thetanull_devianceobserved_fitted_plotoverviewparametric_effectsparametric_termspartial_derivativespartial_residualspenaltypost_drawsposterior_samplespredicted_samplesqq_plotref_levelresiduals_hist_plotresiduals_linpred_plotresponse_derivativesrootogramsmooth_coef_indicessmooth_coefssmooth_datasmooth_dimsmooth_estimatessmooth_labelsmooth_samplessmooth_termssmooth_typesmoothsspline_valuesspline_values2stop_if_not_mgcv_smoothterm_namesterm_variablesthetatidy_basisto_natoo_fartoo_far_to_natransform_funtypical_valuesuser_drawsvariance_compvars_from_labelwhich_smoothsworm_plot

Dependencies:BHclicolorspacecpp11dplyrfansifarvergenericsggokabeitoggplot2gluegtableisobandlabelinglatticelifecyclemagrittrMASSMatrixmgcvmunsellmvnfastnlmepatchworkpillarpkgconfigpurrrR6RColorBrewerRcppRcppArmadillorlangscalesstringistringrtibbletidyrtidyselectutf8vctrsviridisLitewithr

Data slices

Rendered fromdata-slices.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-08-05
Started: 2022-09-06

Getting started with gratia

Rendered fromgratia.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-06-25
Started: 2022-02-06

Readme and manuals

Help Manual

Help pageTopics
Add a confidence interval to an existing objectadd_confint add_confint.default add_confint.parametric_effects add_confint.smooth_estimates
Add a constant to estimated valuesadd_constant add_constant.evaluated_parametric_term add_constant.mgcv_smooth add_constant.parametric_effects add_constant.smooth_estimates add_constant.smooth_samples add_constant.tbl_df
Add fitted values from a model to a data frameadd_fitted
Add posterior draws from a model to a data objectadd_fitted_samples add_posterior_samples add_predicted_samples add_smooth_samples
Add fitted values from a GAM to a data frameadd_fitted.gam
Add partial residualsadd_partial_residuals add_partial_residuals.gam
Add residuals from a model to a data frameadd_residuals
Add residuals from a GAM to a data frameadd_residuals.gam
Add indicators of significant change after SiZeRadd_sizer add_sizer.derivatives add_sizer.smooth_estimates
Model diagnostic plotsappraise appraise.gam appraise.lm
Basis expansions for smoothsbasis basis.default basis.gam basis.gamm basis.list basis.scam
Extract basis dimension of a smoothbasis_size basis_size.gam basis_size.gamm basis_size.mgcv.smooth
Simulated bird migration databird_move
Extract the boundary of a soap film smoothboundary boundary.gam boundary.soap.film
Select smooths based on user's choicescheck_user_select_smooths
Extract coefficients from a fitted 'scam' model.coef.scam
Compare smooths across modelscompare_smooths
Point-wise and simultaneous confidence intervals for derivatives of smoothsconfint.fderiv
Point-wise and simultaneous confidence intervals for smoothsconfint.gam confint.gamm confint.list
All combinations of factor levels plus typical values of continuous variablesdata_combos data_combos.gam
Simulate example data for fitting GAMsdata_sim
Prepare a data slice through model covariatesdata_slice data_slice.data.frame data_slice.default data_slice.gam data_slice.gamm data_slice.list data_slice.scam
Posterior expectations of derivatives from an estimated modelderivative_samples derivative_samples.default derivative_samples.gam derivative_samples.gamm
Derivatives of estimated smooths via finite differencesderivatives derivatives.default derivatives.gam derivatives.gamm
Differences of factor smooth interactionsdifference_smooths difference_smooths.gam
Dispersion parameter for fitted modeldispersion dispersion.gam dispersion.glm
Generic plotting via 'ggplot2'draw
Plot basis functionsdraw.basis
Plot comparisons of smoothsdraw.compare_smooths
Plot derivatives of smoothsdraw.derivatives draw.partial_derivatives
Plot differences of smoothsdraw.difference_smooth
Plot estimated parametric effectsdraw.evaluated_parametric_term
Plot estimated smooths from a fitted GAMdraw.gam
Plot smooths of a GAMLSS model estimated by 'GJRM::gamlss'draw.gamlss
Plot basis functionsdraw.mgcv_smooth
Plot concurvity measuresdraw.overall_concurvity draw.pairwise_concurvity
Plot estimated effects for model parametric termsdraw.parametric_effects
Display penalty matrices of smooths using 'ggplot'draw.penalty_df
Draw a rootogramdraw.rootogram
Plot the result of a call to 'smooth_estimates()'draw.smooth_estimates
Plot posterior smoothsdraw.smooth_samples
Effective degrees of freedom for smooths and GAMsedf edf.gam model_edf
S3 methods to evaluate individual smoothseval_smooth eval_smooth.fs.interaction eval_smooth.mgcv.smooth eval_smooth.mrf.smooth eval_smooth.random.effect eval_smooth.scam_smooth eval_smooth.soap.film eval_smooth.sz.interaction eval_smooth.t2.smooth eval_smooth.tensor.smooth
Evaluate parametric model termsevaluate_parametric_term evaluate_parametric_term.gam
Evaluate a smoothevaluate_smooth
Create a sequence of evenly-spaced valuesevenly seq_min_max
All combinations of factor levelsfactor_combos factor_combos.gam
Name of family used to fit modelfamily_name
Extracts the type of family in a consistent wayfamily_type family_type.default family_type.family
Extract family objects from modelsfamily.bam family.gam family.gamm family.list
Draw fitted values from the posterior distributionfitted_samples fitted_samples.gam
Generate fitted values from a estimated GAMfitted_values fitted_values.gam fitted_values.gamm fitted_values.scam
Fix the names of a data frame containing an offset variable.fix_offset
Extract fixed effects estimatesfixef
Extract fixed effects estimates from a fitted GAMfixed_effects fixed_effects.default fixef.gam fixef.gamm fixef.glm fixef.lm
Posterior samples using a simple Metropolis Hastings samplergaussian_draws gaussian_draws.gam gaussian_draws.scam
Extract an factor-by smooth by nameget_by_smooth
Extract an mgcv smooth by nameget_smooth
Extract an mgcv smooth given its position in the model objectget_smooths_by_id get_smooths_by_id.gam get_smooths_by_id.gamm get_smooths_by_id.gamm4 get_smooths_by_id.list get_smooths_by_id.scam
Data from the General Social Survey (GSS) from the National Opinion Research Center of the University of Chicagogss_vocab
Gu and Wabha test functionsgw_f0 gw_f1 gw_f2 gw_f3 gw_functions
Are additional parameters available for a GAM?has_theta
Tests for by variable smoothsby_level by_variable is_by_smooth is_continuous_by_smooth is_factor_by_smooth
Is a model term a factor (categorical)?is_factor_term is_factor_term.bam is_factor_term.gam is_factor_term.gamm is_factor_term.list is_factor_term.terms
Check if objects are smooths or are a particular type of smoothcheck_is_mgcv_smooth is_mgcv_smooth is_mrf_smooth stop_if_not_mgcv_smooth
Is a model term an offset?is_offset
Extract link and inverse link functions from modelsextract_link extract_link.family extract_link.general.family inv_link inv_link.bam inv_link.family inv_link.gam inv_link.gamm inv_link.glm inv_link.list link link.bam link.family link.gam link.gamm link.glm link.list
Load mgcv quietlyload_mgcv
Return the linear prediction matrix of a fitted GAMlp_matrix lp_matrix.gam
Posterior samples using a Gaussian approximation to the posterior distributionmh_draws mh_draws.gam
Concurvity of an estimated GAMconcrvity model_concurvity model_concurvity.gam
Extract the model constant termmodel_constant model_constant.gam model_constant.gamlss
List the variables involved in a model fitted with a formulamodel_vars model_vars.bam model_vars.default model_vars.gam model_vars.gamm model_vars.gamm4 model_vars.list
The Number of linear predictors in modeln_eta n_eta.gam
How many smooths in a fitted modeln_smooths n_smooths.bam n_smooths.default n_smooths.gam n_smooths.gamm
Negative binomial parameter thetanb_theta nb_theta.gam
Extract the null deviance of a fitted modelnull_deviance null_deviance.default
Plot of fitted against observed response valuesobserved_fitted_plot
Provides an overview of a model and the terms in that modeloverview overview.gam
Estimated values for parametric model termsparametric_effects parametric_effects.gam
Names of any parametric terms in a GAMparametric_terms parametric_terms.default parametric_terms.gam
Partial derivatives of estimated multivariate smooths via finite differencespartial_derivatives partial_derivatives.default partial_derivatives.gam partial_derivatives.gamm
Partial residualspartial_residuals partial_residuals.gam
Extract and tidy penalty matricespenalty penalty.default penalty.gam penalty.mgcv.smooth penalty.re.smooth.spec penalty.t2.smooth penalty.tensor.smooth
Low-level Functions to generate draws from the posterior distribution of model coefficientsgenerate_draws generate_draws.gam post_draws post_draws.default
Draw samples from the posterior distribution of an estimated modelposterior_samples posterior_samples.gam
Draw new response values from the conditional distribution of the responsepredicted_samples predicted_samples.gam
Quantile-quantile plot of model residualsqq_plot qq_plot.default qq_plot.gam qq_plot.glm qq_plot.lm
Return the reference or specific level of a factorlevel ref_level
Reference simulation dataref_sims
Repeat the first level of a factor n timesrep_first_factor_value
Histogram of model residualsresiduals_hist_plot
Plot of residuals versus linear predictor valuesresiduals_linpred_plot
Derivatives on the response scale from an estimated GAMresponse_derivatives response_derivatives.default response_derivatives.gam response_derivatives.gamm
Rootograms to assess goodness of model fitrootogram rootogram.gam
Create a sequence of evenly-spaced values adjusted to accommodate a small adjustmentseq_min_max_eps
Shift numeric values in a data frame by an amount 'eps'shift_values
Simulate from the posterior distribution of a GAMsimulate.gam simulate.gamm simulate.scam
Lead-210 age-depth measurements for Small WatersmallAges
Indices of the parametric terms for a particular smoothsmooth_coef_indices
Coefficients for a particular smoothsmooth_coefs smooth_coefs.bam smooth_coefs.gam smooth_coefs.gamm smooth_coefs.gamm4 smooth_coefs.list smooth_coefs.mgcv.smooth smooth_coefs.scam
Generate regular data over the covariates of a smoothsmooth_data
Dimension of a smoothsmooth_dim smooth_dim.gam smooth_dim.gamm smooth_dim.mgcv.smooth
Evaluate smooths at covariate valuessmooth_estimates smooth_estimates.gam
Extract the label for a smooth used by 'mgcv'smooth_label smooth_label.gam smooth_label.mgcv.smooth
Posterior draws for individual smoothssmooth_samples smooth_samples.gam
List the variables involved in smoothssmooth_terms
Determine the type of smooth and return it n a human readable formsmooth_type smooth_type.Bspline.smooth smooth_type.cpspline.smooth smooth_type.cr.smooth smooth_type.cs.smooth smooth_type.cv.smooth smooth_type.cx.smooth smooth_type.cyclic.smooth smooth_type.default smooth_type.duchon.spline smooth_type.fs.interaction smooth_type.gp.smooth smooth_type.mdcv.smooth smooth_type.mdcx.smooth smooth_type.micv.smooth smooth_type.micx.smooth smooth_type.mifo.smooth smooth_type.miso.smooth smooth_type.mpd.smooth smooth_type.mpi.smooth smooth_type.mrf.smooth smooth_type.pspline.smooth smooth_type.random.effect smooth_type.sf smooth_type.soap.film smooth_type.sos.smooth smooth_type.sw smooth_type.sz.interaction smooth_type.t2.smooth smooth_type.tensor.smooth smooth_type.tprs.smooth smooth_type.ts.smooth
Names of smooths in a GAMsmooths smooths.default smooths.gamm
Evaluate a spline at provided covariate valuesspline_values
Extract names of all variables needed to fit a GAM or a smoothterm_names term_names.gam term_names.gamm term_names.mgcv.smooth
Names of variables involved in a specified model termterm_variables term_variables.bam term_variables.gam term_variables.terms
General extractor for additional parameters in mgcv modelstheta theta.gam
A tidy basis representation of a smooth objecttidy_basis
Sets the elements of vector to 'NA'to_na
Exclude values that lie too far from the support of datatoo_far
Set rows of data to 'NA' if the lie too far from a reference set of valuestoo_far_to_na
Transform estimated values and confidence intervals by applying a functiontransform_fun transform_fun.evaluated_parametric_term transform_fun.mgcv_smooth transform_fun.parametric_effects transform_fun.smooth_estimates transform_fun.smooth_samples transform_fun.tbl_df
Typical values of model covariatestypical_values typical_values.data.frame typical_values.gam
Handle user-supplied posterior drawsuser_draws user_draws.gam
Variance components of smooths from smoothness estimatesvariance_comp variance_comp.gam
Returns names of variables from a smooth labelvars_from_label
Identify a smooth term by its labelwhich_smooths which_smooths.bam which_smooths.default which_smooths.gam which_smooths.gamm
Worm plot of model residualsworm_plot worm_plot.gam worm_plot.glm worm_plot.lm
Madison lakes zooplankton datazooplankton