Skip to content

Commit

Permalink
add glance.TMB
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Dec 27, 2024
1 parent a355ff3 commit 44a0a94
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: broom.mixed
Type: Package
Title: Tidying Methods for Mixed Models
Version: 0.2.9.6
Version: 0.2.9.7
Authors@R: c(
person("Ben", "Bolker", email = "[email protected]",
role = c("aut", "cre"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ S3method(augment,merMod)
S3method(augment,ranef.mer)
S3method(confint,rlmerMod)
S3method(fixef,MCMCglmm)
S3method(glance,TMB)
S3method(glance,allFit)
S3method(glance,brmsfit)
S3method(glance,gamlss)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# CHANGES IN broom.mixed VERSION 0.2.9.7

- added `glance` method for `TMB` objects

# CHANGES IN broom.mixed VERSION 0.2.9.6

- CRAN maintenance release
Expand Down
14 changes: 14 additions & 0 deletions R/TMB_tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,17 @@ tidy.TMB <- function(x, effects = c("fixed", "random"),
##
return(ret)
}

#' @export
glance.TMB <- function(x, nobs = NA, ...) {
assert_dependency("TMB")
pars <- x$env$last.par.best
random <- x$env$random
if (!is.null(random)) pars <- pars[-random]
npar <- length(pars)
dev <- x$fn(pars)
loglik <- -dev/2
AIC <- dev + 2*npar
BIC <- dev + npar*log(nobs)
tibble(df = npar, loglik, AIC, BIC)
}

0 comments on commit 44a0a94

Please sign in to comment.