Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
doserjef committed Aug 28, 2024
1 parent c843d84 commit f3f651b
Show file tree
Hide file tree
Showing 71 changed files with 775 additions and 511 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ vignettes/svcModels_cache
vignettes/svcModels_files
vignettes/identifiability_cache
vignettes/identifiability_files
vignettes/parallelization_cache
vignettes/parallelization_files
*.swp
vignettes/modelConsiderations_cache
vignettes/modelConsiderations_files
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
+ New functionality for fitting multi-season, single-species integrated occupancy models. The function `tIntPGOcc()` fits a non-spatial multi-season integrated occupancy model, `stIntPGOcc()` fits a spatial multi-season integrated occupancy model, and `svcTIntPGOcc()` fits a spatially-varying coefficient multi-season occupancy model. Random intercepts are supported in both the occurrence and detection formulas for both model types.
+ Added in functionality for both occupancy and detection random intercepts in single-species single-season integrated models (`intPGOcc()` and `spIntPGOcc()`) using `lme4` syntax (e.g., `(1 | observer)` for a random effect of observer).
+ `simTIntPGOcc()` is a new function that allows simulation of single-species multi-season detection-nondetection data from multiple data sources.
+ Update `simMsIntPGOcc()` to now include simulation of data sets with spatially-varying coefficients and unstructured random effects on both occurrence and detection.
+ Updated `simMsIntPGOcc()` to now include simulation of data sets with spatially-varying coefficients and unstructured random effects on both occurrence and detection.
+ Fixed a bug in the k-fold cross-validation for spatial integrated occupancy models (NNGP models only) that could lead to incorrect model deviance results under certain situations depending on how the spatial coordinates were ordered on the user-side relative to how they are re-ordered when fitting the model. If using `spIntPGOcc()` with `NNGP = TRUE` and using cross-validation, I suggest re-running the analysis. Apologies for the inconvenience.
+ Added in a `residuals()` function to extract occupancy and detection residuals following the approach of [Wilson et al. (2019)](https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecy.2703) for single-season, single-species occupancy models (functions `PGOcc()`, `spPGOcc()`, and `svcPGOcc()`).
+ Added in a `residuals()` function to extract occupancy and detection residuals following the approach of [Wilson et al. (2019)](https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecy.2703) for single-season, single-species occupancy models (functions `PGOcc()`, `spPGOcc()`, and `svcPGOcc()`). I'm hoping to implement this for all model functions and improve GoF functionality. If anyone has any interest in helping out with this, then please let me know!
+ `waicOcc()` for integrated single-species models is now substantially faster.
+ `updateMCMC()` now works with lfJSDM.
+ Fixed a bug in `updateMCMC()` that prevented it from working with `spAbundance::msAbund()` when there were random effects in the model. Also added the `save.fitted` argument to `updateMCMC()` to allow it to work with `msAbund()` and not save the replicate/fitted data values in cases where the amount of RAM is an important consideration.
Expand Down Expand Up @@ -37,6 +37,7 @@
+ Wrote a new "vignette" (really more of a blog post) on some recommendations to help improve interpretability of inferences in SVC models.
+ Fixed a few typos in the MCMC sampler vignettes for factor models and SVC models.
+ Fixed a bug that prevented cross-validation from working properly in multi-species models when setting `k.fold.only = TRUE`. Thanks to Zack Steel for pointing this out.
+ Fixed a typo in the generation of initial values for latent unstructured random effects in all model functions. The typo had no major ramifications, if anything it would have just led to slower convergence, as it resulted in very large (or very small) initial values for the latent random effects that are not really viable on the logit scale.

# spOccupancy 0.7.2

Expand Down
16 changes: 8 additions & 8 deletions R/PGOcc.R
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
}
}
beta.star.indx <- rep(0:(p.occ.re - 1), n.occ.re.long)
beta.star.inits <- rnorm(n.occ.re, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.occ.re, 0, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
} else {
sigma.sq.psi.inits <- 0
beta.star.indx <- 0
Expand Down Expand Up @@ -581,7 +581,7 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
}
}
alpha.star.indx <- rep(0:(p.det.re - 1), n.det.re.long)
alpha.star.inits <- rnorm(n.det.re, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
alpha.star.inits <- rnorm(n.det.re, 0, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
} else {
sigma.sq.p.inits <- 0
alpha.star.indx <- 0
Expand Down Expand Up @@ -677,14 +677,14 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
alpha.inits.list[[i]] <- rnorm(p.det, mu.alpha, sqrt(sigma.alpha))
if (p.occ.re > 0) {
sigma.sq.psi.inits.list[[i]] <- runif(p.occ.re, 0.5, 10)
beta.star.inits.list[[i]] <- rnorm(n.occ.re, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
beta.star.inits.list[[i]] <- rnorm(n.occ.re, 0, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
} else {
sigma.sq.psi.inits.list[[i]] <- 1
beta.star.inits.list[[i]] <- 1
}
if (p.det.re > 0) {
sigma.sq.p.inits.list[[i]] <- runif(p.det.re, 0.5, 10)
alpha.star.inits.list[[i]] <- rnorm(n.det.re, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
alpha.star.inits.list[[i]] <- rnorm(n.det.re, 0, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
} else {
sigma.sq.p.inits.list[[i]] <- 1
alpha.star.inits.list[[i]] <- 1
Expand Down Expand Up @@ -721,11 +721,11 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
alpha.inits <- rnorm(p.det, mu.alpha, sqrt(sigma.alpha))
if (p.occ.re > 0) {
sigma.sq.psi.inits <- runif(p.occ.re, 0.5, 10)
beta.star.inits <- rnorm(n.occ.re, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.occ.re, 0, sqrt(sigma.sq.psi.inits[beta.star.indx + 1]))
}
if (p.det.re > 0) {
sigma.sq.p.inits <- runif(p.det.re, 0.5, 10)
alpha.star.inits <- rnorm(n.det.re, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
alpha.star.inits <- rnorm(n.det.re, 0, sqrt(sigma.sq.p.inits[alpha.star.indx + 1]))
}
}
storage.mode(chain.info) <- "integer"
Expand Down Expand Up @@ -880,7 +880,7 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
if (p.det.re > 0) {
alpha.star.indx.fit <- rep(0:(p.det.re - 1), n.det.re.long.fit)
alpha.level.indx.fit <- sort(unique(c(X.p.re.fit)))
alpha.star.inits.fit <- rnorm(n.det.re.fit,
alpha.star.inits.fit <- rnorm(n.det.re.fit, 0,
sqrt(sigma.sq.p.inits[alpha.star.indx.fit + 1]))
p.re.level.names.fit <- list()
for (t in 1:p.det.re) {
Expand All @@ -900,7 +900,7 @@ PGOcc <- function(occ.formula, det.formula, data, inits, priors,
if (p.occ.re > 0) {
beta.star.indx.fit <- rep(0:(p.occ.re - 1), n.occ.re.long.fit)
beta.level.indx.fit <- sort(unique(c(X.re.fit)))
beta.star.inits.fit <- rnorm(n.occ.re.fit,
beta.star.inits.fit <- rnorm(n.occ.re.fit, 0,
sqrt(sigma.sq.psi.inits[beta.star.indx.fit + 1]))
re.level.names.fit <- list()
for (t in 1:p.occ.re) {
Expand Down
Loading

0 comments on commit f3f651b

Please sign in to comment.