Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More careful calculation of penalized EDF #31

Open
mfasiolo opened this issue Jun 16, 2019 · 0 comments
Open

More careful calculation of penalized EDF #31

mfasiolo opened this issue Jun 16, 2019 · 0 comments

Comments

@mfasiolo
Copy link
Owner

The calculation of the optimal loss smoothness requires calculating the number of effective degrees of freedom. In .getErrParam we currently do

# Fixing dimension d to EDF of Gaussian fit. 
# First use anova to find degrees of freedom of parametric terms in equation for location
# Then find EDF of smooth terms in equation for location. 
# unique() needed for "adaptive" smooths
  anv <- anova( gFit )
  d <- sum( anv$pTerms.df[ !grepl("\\.1", rownames(anv$pTerms.table)) ] )
  d <- d + sum( unique(pen.edf(gFit)[!grepl("s\\.1|te\\.1|ti\\.1|t2\\.1", names(pen.edf(gFit)))]) )

Using unique() avoids counting the edf of the same effect multiple times when using adaptive smooths and tensor product smooth, but might be problematic when using by-factor smooths, for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant