Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

edf

Effective degrees of freedom for smooth terms


Description

Extracts the effective degrees of freedom (EDF) for model smooth terms

Usage

edf(object, ...)

## S3 method for class 'gam'
edf(object, smooth = NULL, alternative = FALSE, ...)

Arguments

object

a fitted model from which to extract smooth-specific EDFs.

...

arguments passed to methods.

smooth

character; a vector of smooth terms whose EDFs will be extracted. If NULL, the default, EDFs for all smooths will be returned.

alternative

logical; return the alternative form for model EDFs of Wood (2017; pp. 252).

Details

Wood (2017; pp. 252) describes an alternative EDF describes an alternative EDF form for the entire model

EDF = 2 * tr(F) - tr(F),

where \mathrm{tr} is the matrix trace and F is a matrix mapping un-penalized coefficient estimates to the penalized coefficient estimates. The trace of F is effectively the average shrinkage of the coefficients multipled by the number of coefficients (Wood, 2017). Smooth-specific EDFs then are obtained by summing up the relevent elements of \mathrm{diag}(2\mathbf{F} - \mathbf{FF}).

Examples

load_mgcv()
df <- data_sim("eg1", n = 400, seed = 42)
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
edf(m)
edf(m, smooth = c("s(x0)", "s(x2)"))

gratia

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

v0.6.0
MIT + file LICENSE
Authors
Gavin L. Simpson [aut, cre] (<https://orcid.org/0000-0002-9084-8413>), Henrik Singmann [ctb] (<https://orcid.org/0000-0002-4842-3657>)
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.