Skip to content

Commit

Permalink
Set EDF printing on by default #383 #387
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Dec 14, 2024
1 parent 18b6d77 commit 9d4634b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: sdmTMB
Title: Spatial and Spatiotemporal SPDE-Based GLMMs with 'TMB'
Version: 0.6.0.9018
Version: 0.6.0.9019
Authors@R: c(
person(c("Sean", "C."), "Anderson", , "[email protected]",
role = c("aut", "cre"),
Expand Down
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# sdmTMB (development version)

* Add EDF (effective degrees of freedom) printing to smoothers with
`print.sdmTMB()` and `summary.sdmTMB()` if argument `edf = TRUE`
is included. E.g. `print.sdmTMB(fit, edf = TRUE)`. #383 #387
`print.sdmTMB()` and `summary.sdmTMB()`. #383 #387

* Add `cAIC()` for calculating *conditional* AIC. Theory based on
<https://arxiv.org/abs/2411.14185>; also see
Expand Down
6 changes: 5 additions & 1 deletion R/caic.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ cAIC.sdmTMB <- function(object, what = c("cAIC", "EDF"), ...) {

what <- tolower(what)
what <- match.arg(what, choices = c("caic", "edf"))
what <- tolower(what)

if ("edf" %in% names(object) && what == "edf") {
return(object$edf)
}

tmb_data <- object$tmb_data

## Ensure profile = NULL
Expand Down
5 changes: 4 additions & 1 deletion R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,10 @@ sdmTMB <- function(
gradients = conv$final_grads,
bad_eig = conv$bad_eig,
pos_def_hessian = sd_report$pdHess))
`class<-`(out, "sdmTMB")
out <- `class<-`(out, "sdmTMB")
edf <- cAIC(out, what = "EDF")
out$edf <- edf
out
}

check_bounds <- function(.par, lower, upper) {
Expand Down
2 changes: 1 addition & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ print_header <- function(x) {
cat(info$overall_family)
}

print_one_model <- function(x, m = 1, edf = FALSE, silent = FALSE) {
print_one_model <- function(x, m = 1, edf = TRUE, silent = FALSE) {
if (edf) {
.edf <- suppressMessages(cAIC(x, what = "EDF"))
} else {
Expand Down

0 comments on commit 9d4634b

Please sign in to comment.