Skip to content

Commit 583548f

Browse files
committed
Fix project/simulate(newdata) with random intercepts
Also trash extra TMB data to save memory
1 parent 664f526 commit 583548f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: sdmTMB
33
Title: Spatial and Spatiotemporal SPDE-Based GLMMs with 'TMB'
4-
Version: 0.7.0.9001
4+
Version: 0.7.0.9002
55
Authors@R: c(
66
person(c("Sean", "C."), "Anderson", , "sean@seananderson.ca",
77
role = c("aut", "cre"),

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
is for simulating from random effects but not adding observation
66
error. #431
77

8+
* Fix `project()` and `simulate.sdmTMB(..., newdata = ...)` when
9+
random intercepts/slopes are present. #431
10+
11+
* Remove extra TMB data slots for `project()` and
12+
`simulate.sdmTMB(..., newdata = ...)` to save memory. #431
13+
814
# sdmTMB 0.7.0
915

1016
## New features

R/project.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ move_proj_to_tmbdat <- function(x, object, newdata) {
358358
x$z_i <- x$proj_z_i
359359
x$Zs <- x$proj_Zs
360360
x$Xs <- x$proj_Xs
361-
x$RE_indexes <- x$proj_RE_indexes
361+
x$Zt_list <- x$Zt_list_proj
362362
x$offset_i <- x$proj_offset_i
363363
n_m <- length(x$X_ij) ## n linear predictor [m]odels
364364
x$y_i <- matrix(NA, ncol = n_m, nrow = nrow(x$proj_X_ij[[1]])) # fake
@@ -369,5 +369,16 @@ move_proj_to_tmbdat <- function(x, object, newdata) {
369369
cli_abort("This function hasn't been set up to work with binomial size specified yet.")
370370
}
371371
x$size <- rep(1, nrow(x$y_i)) # FIXME: bring in?
372+
x$do_predict <- 0L
373+
374+
# nullify large data objects that are no longer needed:
375+
x$proj_X_ij <- list(matrix(0, ncol = 1, nrow = 1))
376+
x$proj_X_rw_ik <- matrix(0, ncol = 1, nrow = 1) # dummy
377+
x$proj_mesh <- Matrix::Matrix(c(0, 0, 2:0), 3, 5) # dummy
378+
x$proj_Zs <- list()
379+
x$proj_Xs <- matrix(nrow = 0L, ncol = 0L)
380+
x$proj_lon <- 0
381+
x$proj_lat <- 0
382+
372383
x
373384
}

0 commit comments

Comments
 (0)