Skip to content

Commit

Permalink
Move add_barrier_mesh() to sdmTMBextra
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Oct 18, 2023
1 parent 3f641ac commit 9d682b7
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 280 deletions.
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ jobs:
remotes::install_cran("sf")
remotes::install_cran("rcmdcheck")
remotes::install_cran("textshaping")
remotes::install_cran("rgdal")
shell: Rscript {0}

- name: Install dependencies Ubuntu
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::., any::rgdal, any::textshaping, any::remotes
extra-packages: any::pkgdown, local::., any::textshaping, any::remotes
needs: website

- name: Install extra packages for web-only vignettes
Expand Down
5 changes: 0 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,8 @@ Suggests:
glmmTMB,
ggplot2,
inlabru,
INLAspacetime,
INLA,
knitr,
rgdal,
rmarkdown,
rnaturalearth,
rnaturalearthdata,
sf,
splancs,
testthat,
Expand Down
162 changes: 0 additions & 162 deletions R/barrier.R

This file was deleted.

35 changes: 33 additions & 2 deletions R/deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Moved to the \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra}
#' package
#'
#' @param object **Deprecated** See the \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra} package.
#' @param object **Deprecated** See the \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra} package. Make sure to load \pkg{sdmTMBextra} *after* \pkg{sdmTMB}.
#'
#' @return
#' Deprecated. See the
Expand All @@ -22,7 +22,7 @@ extract_mcmc <- function(object = deprecated()) {
#' DHARMa residuals
#'
#' Moved to the \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra}
#' package
#' package. Make sure to load \pkg{sdmTMBextra} *after* \pkg{sdmTMB}.
#'
#' @param simulated_response **Deprecated** See the \pkg{sdmTMBextra} package.
#' @param object **Deprecated** See the \pkg{sdmTMBextra} package.
Expand All @@ -42,3 +42,34 @@ extract_mcmc <- function(object = deprecated()) {
dharma_residuals <- function(simulated_response = deprecated(), object, plot = TRUE, ...) {
deprecate_stop("0.2.2", "dharma_residuals()", details = "Load the sdmTMBextra package to use this function: https://github.com/pbs-assess/sdmTMBextra")
}

#' Transform a mesh object into a mesh with correlation barriers
#'
#' Moved to the \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra}
#' package. Make sure to load \pkg{sdmTMBextra} *after* \pkg{sdmTMB}.
#'
#' @param spde_obj Output from [make_mesh()].
#' @param barrier_sf An sf object with polygons defining the barriers. For
#' example, a coastline dataset for ocean data. **Note that this object must
#' have the same projection as the data used to generate the x and y columns
#' in `spde_obj`.**
#' @param range_fraction The fraction of the spatial range that barrier
#' triangles have.
#' @param proj_scaling If `spde_obj` was created with scaling of the coordinates
#' after the projection (e.g., dividing UTMs by 1000 so the spatial range is
#' on a reasonable scale) the x and y values in `spde_obj` are multiplied by
#' this scaling factor before applying the projection from `barrier_sf`.
#' @param plot Logical.
#' @export
#' @keywords internal
#' @return
#' Deprecated. See the
#' \href{https://github.com/pbs-assess/sdmTMBextra}{sdmTMBextra} package.
#' @examples
#' \dontrun{
#' add_barrier_mesh()
#' }
add_barrier_mesh <- function(spde_obj = deprecated(), barrier_sf = deprecated(), range_fraction = 0.2,
proj_scaling = 1, plot = FALSE) {
deprecate_stop("0.3.0", "add_barrier_mesh()", details = "Load the sdmTMBextra package to use this function: https://github.com/pbs-assess/sdmTMBextra \n We may move this back to the main package once the functionality joins fmesher. For now, this function requires INLA.")
}
12 changes: 6 additions & 6 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,19 @@ NULL
#' # Perform several 'sanity' checks:
#' sanity(fit)
#'
#' # Visualize depth effect: (see ?visreg_delta)
#' visreg::visreg(fit, xvar = "depth") # link space; randomized quantile residuals
#' visreg::visreg(fit, xvar = "depth", scale = "response")
#' visreg::visreg(fit, xvar = "depth", scale = "response", gg = TRUE, rug = FALSE)
#'
#' # Predict on the fitted data; see ?predict.sdmTMB
#' p <- predict(fit)
#'
#' # Predict on new data:
#' p <- predict(fit, newdata = qcs_grid)
#' head(p)
#'
#' \donttest{
#' # Visualize depth effect: (see ?visreg_delta)
#' visreg::visreg(fit, xvar = "depth") # link space; randomized quantile residuals
#' visreg::visreg(fit, xvar = "depth", scale = "response")
#' visreg::visreg(fit, xvar = "depth", scale = "response", gg = TRUE, rug = FALSE)
#'
#' # Add spatiotemporal random fields:
#' fit <- sdmTMB(
#' density ~ 0 + as.factor(year),
Expand All @@ -410,7 +411,6 @@ NULL
#' )
#' fit
#'
#' \donttest{
#' # Make the fields AR1:
#' fit <- sdmTMB(
#' density ~ s(depth),
Expand Down
4 changes: 3 additions & 1 deletion R/get-index-sims.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@
#'
#' @export
#' @examples
#' m <- sdmTMB(density ~ 0 + as.factor(year) + depth_scaled + depth_scaled2,
#' m <- sdmTMB(density ~ 0 + as.factor(year),
#' data = pcod_2011, mesh = pcod_mesh_2011, family = tweedie(link = "log"),
#' time = "year"
#' )
#' qcs_grid_2011 <- replicate_df(qcs_grid, "year", unique(pcod_2011$year))
#' p <- predict(m, newdata = qcs_grid_2011, nsim = 100)
#' x <- get_index_sims(p)
#' \donttest{
#' x_sims <- get_index_sims(p, return_sims = TRUE)
#'
#' if (require("ggplot2", quietly = TRUE)) {
Expand All @@ -77,6 +78,7 @@
#' agg_function = function(x) sum(x),
#' area_function = function(x, area) x * area
#' )
#' }
get_index_sims <- function(obj,
level = 0.95,
return_sims = FALSE,
Expand Down
Loading

0 comments on commit 9d682b7

Please sign in to comment.