Skip to content

Commit 70d8a30

Browse files
committed
tidy coefficents for linear smoothers
Small fix added to tidy()
1 parent 39fa30b commit 70d8a30

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

R/tidy.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ tidy.sdmTMB <- function(x, effects = c("fixed", "ran_pars", "ran_vals"), model =
155155
)
156156
}
157157

158+
if (x$tmb_data$has_smooths) {
159+
p <- print_smooth_effects(x)
160+
mm <- p$smooth_effects
161+
out <- rbind(out,
162+
data.frame(term = rownames(mm),
163+
estimate = mm[,"bs"],
164+
std.error = mm[,"bs_se"],
165+
stringsAsFactors = FALSE))
166+
}
167+
168+
158169
if (conf.int) {
159170
out$conf.low <- as.numeric(trans(out$estimate - crit * out$std.error))
160171
out$conf.high <- as.numeric(trans(out$estimate + crit * out$std.error))

sdmTMB.Rproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Version: 1.0
2-
ProjectId: 1e54a969-ff39-402d-83f4-c260f1f06bda
32

43
RestoreWorkspace: No
54
SaveWorkspace: No

tests/testthat/test-tidy.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@ test_that("tidy works", {
4545
x <- tidy(fit, "ran_pars", conf.int = TRUE)
4646
x
4747
expect_true(sum(is.na(x$std.error)) == 0L)
48+
49+
# test smooth handling
50+
fit <- sdmTMB(
51+
density ~ s(depth),
52+
data = pcod_2011, mesh = mesh,
53+
family = tweedie(link = "log")
54+
)
55+
x <- tidy(fit)
56+
expect_equal(x$term, c("(Intercept)", "sdepth"))
57+
4858
})

0 commit comments

Comments
 (0)