* using log directory ‘/data/localhost/ripley/R/packages/tests-donttest/sdmTMB.Rcheck’ * using R Under development (unstable) (2026-08-25 r90447) * using platform: x86_64-pc-linux-gnu * R was compiled by gcc (GCC) 16.1.1 20260515 (Red Hat 16.1.1-2) GNU Fortran (GCC) 16.1.1 20260515 (Red Hat 16.1.1-2) * running under: Fedora Linux 44 (Server Edition) * using session charset: UTF-8 * current time: 2026-08-26 00:47:38 UTC * checking for file ‘sdmTMB/DESCRIPTION’ ... OK * checking extension type ... Package * this is package ‘sdmTMB’ version ‘1.1.0’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘sdmTMB’ can be installed ... [5m/10m] OK * used C++ compiler: ‘g++ (GCC) 16.2.1 20260819 (Red Hat 16.2.1-2)’ * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking code files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking whether startup messages can be suppressed ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [29s/61s] NOTE Found calls to structure() using deprecated special names: sdmTMB/tests/testthat/test-1-fit-basic.R (.Dim: 1) '.Dim' should be changed to 'dim'. * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK * checking data for non-ASCII characters ... OK * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK * checking line endings in C/C++/Fortran sources/headers ... OK * checking line endings in Makefiles ... OK * checking compilation flags in Makevars ... OK * checking for GNU extensions in Makefiles ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking use of PKG_*FLAGS in Makefiles ... OK * checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK * checking pragmas in C/C++ headers and code ... OK * checking compilation flags used ... OK * checking compiled code ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... [45s/101s] OK * checking examples with --run-donttest ... [117s/223s] ERROR Running examples in ‘sdmTMB-Ex.R’ failed The error most likely occurred in: > ### Name: predict.sdmTMB > ### Title: Predict from an sdmTMB model > ### Aliases: predict.sdmTMB > > ### ** Examples > > ## Don't show: > if (ggplot2_installed()) withAutoprint({ # examplesIf + ## End(Don't show) + + d <- pcod_2011 + mesh <- make_mesh(d, c("X", "Y"), cutoff = 30) # a coarse mesh for example speed + m <- sdmTMB( + data = d, formula = density ~ 0 + as.factor(year) + depth_scaled + depth_scaled2, + time = "year", mesh = mesh, family = tweedie(link = "log") + ) + + # Predictions at original data locations ------------------------------- + + predictions <- predict(m) + head(predictions) + + predictions$resids <- residuals(m) # randomized quantile residuals + + library(ggplot2) + ggplot(predictions, aes(X, Y, col = resids)) + scale_colour_gradient2() + + geom_point() + facet_wrap(~year) + hist(predictions$resids) + qqnorm(predictions$resids); abline(a = 0, b = 1) + + # Predictions on new data ---------------------------------------------- + + qcs_grid_2011 <- replicate_df(qcs_grid, "year", unique(pcod_2011$year)) + predictions <- predict(m, newdata = qcs_grid_2011) + + ## No test: + # A short function for plotting predictions: + plot_map <- function(dat, column = est) { + ggplot(dat, aes(X, Y, fill = {{ column }})) + + geom_raster() + + facet_wrap(~year) + + coord_fixed() + } + + plot_map(predictions, exp(est)) + + scale_fill_viridis_c(trans = "sqrt") + + ggtitle("Prediction (fixed effects + all random effects)") + + plot_map(predictions, exp(est_non_rf)) + + ggtitle("Prediction (fixed effects and any time-varying effects)") + + scale_fill_viridis_c(trans = "sqrt") + + plot_map(predictions, est_rf) + + ggtitle("All random field estimates") + + scale_fill_gradient2() + + plot_map(predictions, omega_s) + + ggtitle("Spatial random effects only") + + scale_fill_gradient2() + + plot_map(predictions, epsilon_st) + + ggtitle("Spatiotemporal random effects only") + + scale_fill_gradient2() + + # Visualizing a marginal effect ---------------------------------------- + + # See the visreg package or the ggeffects::ggeffect() or + # ggeffects::ggpredict() functions + # To do this manually: + + nd <- data.frame(depth_scaled = + seq(min(d$depth_scaled), max(d$depth_scaled), length.out = 100)) + nd$depth_scaled2 <- nd$depth_scaled^2 + + # Because this is a spatiotemporal model, you'll need at least one time + # value. For these population-level predictions, if time isn't also a fixed + # effect, it doesn't matter what you pick: + nd$year <- 2011L # L: integer to match original data + p <- predict(m, newdata = nd, se_fit = TRUE, re_form = NA) + ggplot(p, aes(depth_scaled, exp(est), + ymin = exp(est - 1.96 * est_se), ymax = exp(est + 1.96 * est_se))) + + geom_line() + geom_ribbon(alpha = 0.4) + + # Plotting marginal effect of a spline --------------------------------- + + m_gam <- sdmTMB( + data = d, formula = density ~ 0 + as.factor(year) + s(depth_scaled, k = 5), + time = "year", mesh = mesh, family = tweedie(link = "log") + ) + if (require("visreg", quietly = TRUE)) { + visreg::visreg(m_gam, "depth_scaled") + } + + # or manually: + nd <- data.frame(depth_scaled = + seq(min(d$depth_scaled), max(d$depth_scaled), length.out = 100)) + nd$year <- 2011L + p <- predict(m_gam, newdata = nd, se_fit = TRUE, re_form = NA) + ggplot(p, aes(depth_scaled, exp(est), + ymin = exp(est - 1.96 * est_se), ymax = exp(est + 1.96 * est_se))) + + geom_line() + geom_ribbon(alpha = 0.4) + + # Forecasting ---------------------------------------------------------- + mesh <- make_mesh(d, c("X", "Y"), cutoff = 15) + + unique(d$year) + m <- sdmTMB( + data = d, formula = density ~ 1, + spatiotemporal = "AR1", # using AR(1) to have something to forecast with + extra_time = 2019L, # `L` for integer to match our data + spatial = "off", + time = "year", mesh = mesh, family = tweedie(link = "log") + ) + + # Add a year to our grid: + grid2019 <- qcs_grid_2011[qcs_grid_2011$year == max(qcs_grid_2011$year), ] + grid2019$year <- 2019L # `L` because `year` is an integer in the data + qcsgrid_forecast <- rbind(qcs_grid_2011, grid2019) + + predictions <- predict(m, newdata = qcsgrid_forecast) + plot_map(predictions, exp(est)) + + scale_fill_viridis_c(trans = "log10") + plot_map(predictions, epsilon_st) + + scale_fill_gradient2() + + # Estimating local trends ---------------------------------------------- + + d <- pcod + d$year_scaled <- as.numeric(scale(d$year)) + mesh <- make_mesh(pcod, c("X", "Y"), cutoff = 25) + m <- sdmTMB(data = d, formula = density ~ depth_scaled + depth_scaled2, + mesh = mesh, family = tweedie(link = "log"), + spatial_varying = ~ 0 + year_scaled, time = "year", spatiotemporal = "off") + nd <- replicate_df(qcs_grid, "year", unique(pcod$year)) + nd$year_scaled <- (nd$year - mean(d$year)) / sd(d$year) + p <- predict(m, newdata = nd) + + plot_map(subset(p, year == 2003), zeta_s_year_scaled) + # pick any year + ggtitle("Spatial slopes") + + scale_fill_gradient2() + + plot_map(p, est_rf) + + ggtitle("Random field estimates") + + scale_fill_gradient2() + + plot_map(p, exp(est_non_rf)) + + ggtitle("Prediction (fixed effects only)") + + scale_fill_viridis_c(trans = "sqrt") + + plot_map(p, exp(est)) + + ggtitle("Prediction (fixed effects + all random effects)") + + scale_fill_viridis_c(trans = "sqrt") + ## End(No test) + ## Don't show: + }) # examplesIf > d <- pcod_2011 > mesh <- make_mesh(d, c("X", "Y"), cutoff = 30) > m <- sdmTMB(data = d, formula = density ~ 0 + as.factor(year) + depth_scaled + + depth_scaled2, time = "year", mesh = mesh, family = tweedie(link = "log")) > predictions <- predict(m) > head(predictions) # A tibble: 6 × 17 year X Y depth density present lat lon depth_mean depth_sd 1 2011 435. 5718. 241 245. 1 51.6 -130. 5.16 0.445 2 2011 487. 5719. 52 0 0 51.6 -129. 5.16 0.445 3 2011 490. 5717. 47 0 0 51.6 -129. 5.16 0.445 4 2011 545. 5717. 157 0 0 51.6 -128. 5.16 0.445 5 2011 404. 5720. 398 0 0 51.6 -130. 5.16 0.445 6 2011 420. 5721. 486 0 0 51.6 -130. 5.16 0.445 # ℹ 7 more variables: depth_scaled , depth_scaled2 , est , # est_non_rf , est_rf , omega_s , epsilon_st > predictions$resids <- residuals(m) > library(ggplot2) > ggplot(predictions, aes(X, Y, col = resids)) + scale_colour_gradient2() + + geom_point() + facet_wrap(~year) > hist(predictions$resids) > qqnorm(predictions$resids) > abline(a = 0, b = 1) > qcs_grid_2011 <- replicate_df(qcs_grid, "year", unique(pcod_2011$year)) > predictions <- predict(m, newdata = qcs_grid_2011) > plot_map <- function(dat, column = est) { + ggplot(dat, aes(X, Y, fill = { + { + column + } + })) + geom_raster() + facet_wrap(~year) + coord_fixed() + } > plot_map(predictions, exp(est)) + scale_fill_viridis_c(trans = "sqrt") + + ggtitle("Prediction (fixed effects + all random effects)") > plot_map(predictions, exp(est_non_rf)) + ggtitle("Prediction (fixed effects and any time-varying effects)") + + scale_fill_viridis_c(trans = "sqrt") > plot_map(predictions, est_rf) + ggtitle("All random field estimates") + + scale_fill_gradient2() > plot_map(predictions, omega_s) + ggtitle("Spatial random effects only") + + scale_fill_gradient2() > plot_map(predictions, epsilon_st) + ggtitle("Spatiotemporal random effects only") + + scale_fill_gradient2() > nd <- data.frame(depth_scaled = seq(min(d$depth_scaled), max(d$depth_scaled), + length.out = 100)) > nd$depth_scaled2 <- nd$depth_scaled^2 > nd$year <- 2011L > p <- predict(m, newdata = nd, se_fit = TRUE, re_form = NA) > ggplot(p, aes(depth_scaled, exp(est), ymin = exp(est - 1.96 * est_se), + ymax = exp(est + 1.96 * est_se))) + geom_line() + geom_ribbon(alpha = 0.4) > m_gam <- sdmTMB(data = d, formula = density ~ 0 + as.factor(year) + s(depth_scaled, + k = 5), time = "year", mesh = mesh, family = tweedie(link = "log")) > if (require("visreg", quietly = TRUE)) { + visreg::visreg(m_gam, "depth_scaled") + } visreg 3.0 includes breaking changes. For migration details, see: https://pbreheny.github.io/visreg/articles/migrating-to-3-0.html Error in `predict()`: ! `xy_cols` (the column names for the x and y coordinates) are not in `newdata`. Did you miss specifying the argument `xy_cols` to match your data? The newer `make_mesh()` (vs. `make_spde()`) takes care of this for you. Backtrace: ▆ 1. ├─base::withAutoprint(...) 2. │ └─base::source(...) 3. │ ├─base::withVisible(eval(ei, envir)) 4. │ └─base::eval(ei, envir) 5. │ └─base::eval(ei, envir) 6. └─visreg::visreg(m_gam, "depth_scaled") 7. └─visreg:::build_visreg(...) 8. └─visreg:::get_xy(...) 9. └─visreg:::compute_response(fit, x, trans, alpha, predict) 10. └─visreg:::visreg_pred(fit, x$frame_res, predict = predict) 11. └─visreg (local) call_fn(fit, args, se_fit) 12. ├─base::suppressWarnings(do.call("predict", args)) 13. │ └─base::withCallingHandlers(...) 14. ├─base::do.call("predict", args) 15. ├─stats::predict(object = ``, newdata = ``) 16. └─sdmTMB:::predict.sdmTMB(object = ``, newdata = ``) 17. └─cli::cli_abort(...) 18. └─rlang::abort(...) Execution halted * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... Running ‘testthat.R’ [125s/108s] [125s/109s] OK * checking for unstated dependencies in vignettes ... OK * checking package vignettes ... OK * checking re-building of vignette outputs ... [8s/12s] OK * checking PDF version of manual ... [6s/13s] OK * checking HTML version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * checking for new files in some other directories ... OK * DONE Status: 1 ERROR, 1 NOTE See ‘/data/localhost/ripley/R/packages/tests-donttest/sdmTMB.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 22:07.61, 671.53 + 48.29