From c8407213d96aa1732114453308e1c350cdb5fc5e Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Wed, 18 Oct 2023 10:07:52 -0700 Subject: [PATCH] R CMD check fixes [skip ci] --- DESCRIPTION | 1 - R/mesh.R | 38 +++++++++++++++++++------------------- R/plot.R | 2 +- R/priors.R | 2 ++ R/stacking.R | 2 ++ man/plot_anisotropy.Rd | 2 +- man/priors.Rd | 2 ++ man/sdmTMB_stacking.Rd | 2 ++ 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 767b050ac..f426ebd22 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -91,7 +91,6 @@ Suggests: ggforce, glmmTMB, ggplot2, - inlabru, knitr, rmarkdown, sf, diff --git a/R/mesh.R b/R/mesh.R index c49647cce..4e3d056d2 100644 --- a/R/mesh.R +++ b/R/mesh.R @@ -234,27 +234,27 @@ binary_search_knots <- function(loc_xy, #' @rdname make_mesh #' @export plot.sdmTMBmesh <- function(x, ...) { - r1 <- requireNamespace("inlabru", quietly = TRUE) - r2 <- requireNamespace("ggplot2", quietly = TRUE) - if (r1 && r2) { - dat <- data.frame( - x = x$loc_xy[,1,drop=TRUE], - y = x$loc_xy[,2,drop=TRUE] - ) - ggplot2::ggplot() + - inlabru::gg(x$mesh, ext.color = "grey20", ext.linewidth = 0.5, edge.color = "grey50") + - # ggplot2::coord_sf() + - # fmesher::geom_fm(data = x$mesh) + - ggplot2::geom_point( - data = dat, - mapping = ggplot2::aes(x = .data$x, y = .data$y), alpha = 0.4, pch = 20, colour = "#3182BD") + - ggplot2::coord_fixed() + - ggplot2::labs(x = x$xy_cols[[1]], y = x$xy_cols[[2]]) - } else { + # r1 <- requireNamespace("inlabru", quietly = TRUE) + # r2 <- requireNamespace("ggplot2", quietly = TRUE) + # if (r1 && r2) { + # dat <- data.frame( + # x = x$loc_xy[,1,drop=TRUE], + # y = x$loc_xy[,2,drop=TRUE] + # ) + # ggplot2::ggplot() + + # # inlabru::gg(x$mesh, ext.color = "grey20", ext.linewidth = 0.5, edge.color = "grey50") + + # ggplot2::coord_sf() + + # fmesher::geom_fm(data = x$mesh) + + # ggplot2::geom_point( + # data = dat, + # mapping = ggplot2::aes(x = .data$x, y = .data$y), alpha = 0.4, pch = 20, colour = "#3182BD") + + # # ggplot2::coord_fixed() + + # ggplot2::labs(x = x$xy_cols[[1]], y = x$xy_cols[[2]]) + # } else { plot(x$mesh, main = NA, edge.color = "grey60", asp = 1, ...) - points(x$loc_xy, pch = ".", col = "#00000070") + points(x$loc_xy, pch = 21, cex = 0.3, col = "#00000080") points(x$loc_centers, pch = 20, col = "red") - } + # } } # from TMB examples repository: diff --git a/R/plot.R b/R/plot.R index 4f173306c..c891219ea 100644 --- a/R/plot.R +++ b/R/plot.R @@ -17,7 +17,7 @@ #' spatiotemporal range (distance at which correlation is effectively #' independent) in any direction from zero. Uses \pkg{ggplot2}. If anisotropy #' was turned off when fitting the model, `NULL` is returned instead of a -#' {ggplot2} object. +#' \pkg{ggplot2} object. #' #' `plot_anisotropy2()`: A plot of eigenvectors illustrating the estimated #' anisotropy. A list of the plotted data is invisibly returned. Uses base diff --git a/R/priors.R b/R/priors.R index d45308bb7..de3437191 100644 --- a/R/priors.R +++ b/R/priors.R @@ -151,6 +151,7 @@ mvnormal <- function(location = 0, scale = diag(length(location))) { #' pc_matern(range_gt = 5, sigma_lt = 1) #' plot_pc_matern(range_gt = 5, sigma_lt = 1) #' +#' \donttest{ #' d <- subset(pcod, year > 2011) #' pcod_spde <- make_mesh(d, c("X", "Y"), cutoff = 30) #' @@ -194,6 +195,7 @@ mvnormal <- function(location = 0, scale = diag(length(location))) { #' matern_s = pc_matern(range_gt = 5, sigma_lt = 1), #' matern_st = pc_matern(range_gt = 5, sigma_lt = 1)) #' ) +#' } pc_matern <- function(range_gt, sigma_lt, range_prob = 0.05, sigma_prob = 0.05) { assert_that(range_prob > 0 && range_prob < 1) assert_that(sigma_prob > 0 && sigma_prob < 1) diff --git a/R/stacking.R b/R/stacking.R index 407891ec3..afabebeda 100644 --- a/R/stacking.R +++ b/R/stacking.R @@ -31,6 +31,7 @@ #' #' #' @examples +#' \donttest{ #' # Set parallel processing if desired. See 'Details' in ?sdmTMB_cv #' #' # Depth as quadratic: @@ -59,6 +60,7 @@ #' models <- list(m_cv_1, m_cv_2, m_cv_3) #' weights <- sdmTMB_stacking(models) #' weights +#' } sdmTMB_stacking <- function(model_list, include_folds = NULL) { n_models <- length(model_list) if (is.null(include_folds)) { diff --git a/man/plot_anisotropy.Rd b/man/plot_anisotropy.Rd index dcbe6391f..aedfc3db9 100644 --- a/man/plot_anisotropy.Rd +++ b/man/plot_anisotropy.Rd @@ -24,7 +24,7 @@ the X-Y coordinates being modeled. The ellipses show the spatial and/or spatiotemporal range (distance at which correlation is effectively independent) in any direction from zero. Uses \pkg{ggplot2}. If anisotropy was turned off when fitting the model, \code{NULL} is returned instead of a -{ggplot2} object. +\pkg{ggplot2} object. \code{plot_anisotropy2()}: A plot of eigenvectors illustrating the estimated anisotropy. A list of the plotted data is invisibly returned. Uses base diff --git a/man/priors.Rd b/man/priors.Rd index b1766f5b2..c8e87e4e9 100644 --- a/man/priors.Rd +++ b/man/priors.Rd @@ -113,6 +113,7 @@ mvnormal(c(0, 0)) pc_matern(range_gt = 5, sigma_lt = 1) plot_pc_matern(range_gt = 5, sigma_lt = 1) +\donttest{ d <- subset(pcod, year > 2011) pcod_spde <- make_mesh(d, c("X", "Y"), cutoff = 30) @@ -157,6 +158,7 @@ m <- sdmTMB(density ~ 0 + depth_scaled + depth_scaled2 + as.factor(year), matern_st = pc_matern(range_gt = 5, sigma_lt = 1)) ) } +} \references{ Fuglstad, G.-A., Simpson, D., Lindgren, F., and Rue, H. (2016) Constructing Priors that Penalize the Complexity of Gaussian Random Fields. diff --git a/man/sdmTMB_stacking.Rd b/man/sdmTMB_stacking.Rd index 117ed02e3..2afc20e58 100644 --- a/man/sdmTMB_stacking.Rd +++ b/man/sdmTMB_stacking.Rd @@ -31,6 +31,7 @@ where log scores are used to generate the stacking of predictive distributions } \examples{ +\donttest{ # Set parallel processing if desired. See 'Details' in ?sdmTMB_cv # Depth as quadratic: @@ -60,6 +61,7 @@ models <- list(m_cv_1, m_cv_2, m_cv_3) weights <- sdmTMB_stacking(models) weights } +} \references{ Yao, Y., Vehtari, A., Simpson, D., and Gelman, A. 2018. Using Stacking to Average Bayesian Predictive Distributions (with Discussion). Bayesian Analysis