Skip to content

Commit

Permalink
Temporary hack to fix #261 and #261
Browse files Browse the repository at this point in the history
If keeping, need to fix licensing
  • Loading branch information
seananderson committed Oct 10, 2023
1 parent af49635 commit 3396683
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: sdmTMB
Title: Spatial and Spatiotemporal SPDE-Based GLMMs with 'TMB'
Version: 0.3.1.9000
Version: 0.3.1.9001
Authors@R: c(
person(c("Sean", "C."), "Anderson", , "sean@seananderson.ca",
role = c("aut", "cre"),
Expand Down Expand Up @@ -71,6 +71,7 @@ Imports:
glmmTMB,
graphics,
lifecycle,
lme4,
Matrix,
methods,
mgcv,
Expand All @@ -92,7 +93,6 @@ Suggests:
INLA,
inlabru,
knitr,
lme4,
rgdal,
rmarkdown,
sf,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ importFrom(lifecycle,deprecate_stop)
importFrom(lifecycle,deprecate_warn)
importFrom(lifecycle,deprecated)
importFrom(lifecycle,is_present)
importFrom(lme4,nobars)
importFrom(methods,as)
importFrom(methods,is)
importFrom(mgcv,s)
Expand Down
8 changes: 4 additions & 4 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,7 @@ sdmTMB <- function(
contains_offset <- check_offset(formula[[ii]])

# anything in a list here needs to be saved for tmb data
formula_no_sm <- remove_s_and_t2(formula[[ii]])
split_formula[[ii]] <- glmmTMB::splitForm(formula_no_sm)
split_formula[[ii]] <- splitForm(formula[ii][[1]])
RE_names <- barnames(split_formula[[ii]]$reTrmFormulas)

fct_check <- vapply(RE_names, function(x) check_valid_factor_levels(data[[x]], .name = x), TRUE)
Expand All @@ -835,8 +834,9 @@ sdmTMB <- function(
formula[[ii]] <- split_formula[[ii]]$fixedFormula
ln_tau_G_index[[ii]] <- unlist(lapply(seq_along(nobs_RE[[ii]]), function(i) rep(i, each = nobs_RE[[ii]][i]))) - 1L

X_ij[[ii]] <- model.matrix(split_formula[[ii]]$fixedFormula, data)
mf[[ii]] <- model.frame(split_formula[[ii]]$fixedFormula, data)
formula_no_sm <- remove_s_and_t2(formula[[ii]])
X_ij[[ii]] <- model.matrix(formula_no_sm, data)
mf[[ii]] <- model.frame(formula_no_sm, data)
# Check for random slopes:
if (length(split_formula[[ii]]$reTrmFormulas)) {
termsfun <- function(x) {
Expand Down
5 changes: 3 additions & 2 deletions R/mesh.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#'
#' @export
#'
#' mesh <- make_mesh(pcod, c("X", "Y"), cutoff = 30, type = "cutoff")
#' plot(mesh)
#' @examples
#'
#' \donttest{
#' mesh <- make_mesh(pcod, c("X", "Y"), cutoff = 5, type = "cutoff")
Expand All @@ -38,6 +37,7 @@
#' mesh <- make_mesh(pcod, c("X", "Y"), n_knots = 50, type = "kmeans")
#' plot(mesh)
#'
#'}
# # Defining a mesh directly with fmesher (formerly in INLA):
# bnd <- fmesher::fm_nonconvex_hull(cbind(pcod$X, pcod$Y), convex = -0.05)
# inla_mesh <- fmesher::fm_mesh_2d_inla(
Expand All @@ -49,6 +49,7 @@
# )
# mesh <- make_mesh(pcod, c("X", "Y"), mesh = inla_mesh)
# plot(mesh)

make_mesh <- function(data, xy_cols,
type = c("kmeans", "cutoff", "cutoff_search"),
cutoff, n_knots,
Expand Down
Loading

0 comments on commit 3396683

Please sign in to comment.