Skip to content

Commit

Permalink
initial prep for v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
doserjef committed Sep 11, 2024
1 parent bfbabde commit 961b97d
Show file tree
Hide file tree
Showing 43 changed files with 5,152 additions and 4,147 deletions.
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# spAbundance 0.1.4
# spAbundance 0.2.0

+ Updated `svcAbund()` to now work with Poisson and negative binomial families. Note that the function now defaults to use `family = 'Poisson'`, which differs from the previous implementation when only `family = 'Gaussian'` was supported. This switch was done to maintain consistency with other spAbundance model-fitting functions.
+ Added functionality for independent priors on the species-specific effects to allow species-effects to be treated as fixed effects as opposed to random effects from a common community-level distribution for the following model types: `msNMix()`.
+ Added in a check at the top of all model fitting functions to return an error when the number of posterior samples saved based on the MCMC criteria (`n.batch`, `batch.length`, `n.samples`, `n.burn`, `n.thin`, `n.chains`) are specified in a way that leads to a non-integer value. In such situations, models would previously run and return without an error, but sometimes the last posterior sample in any given chain could have widely inaccurate values, or values that prevented subsequent functions from working. Thanks to Wendy Leuenberger for bringing this to my attention.
+ Fixed some typos in the documentation.
+ Updated C++ code to adhere to the new lack of re-mapping of functions in Rinternals.h and R_ext/Error.h when building packages on CRAN.
+ 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 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 log scale.


# spAbundance 0.1.3
Expand Down
4 changes: 2 additions & 2 deletions R/DS.R
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ DS <- function(abund.formula, det.formula, data, inits, priors, tuning,
}
}
beta.star.indx <- rep(0:(p.abund.re - 1), n.abund.re.long)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
} else {
sigma.sq.mu.inits <- 0
beta.star.indx <- 0
Expand Down Expand Up @@ -777,7 +777,7 @@ DS <- function(abund.formula, det.formula, data, inits, priors, tuning,
alpha.inits <- runif(p.det, -10, 10)
if (p.abund.re > 0) {
sigma.sq.mu.inits <- runif(p.abund.re, 0.05, 1)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
}
if (p.det.re > 0) {
sigma.sq.p.inits <- runif(p.det.re, 0.05, 0.5)
Expand Down
8 changes: 4 additions & 4 deletions R/NMix.R
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ NMix <- function(abund.formula, det.formula, data, inits, priors, tuning,
}
}
beta.star.indx <- rep(0:(p.abund.re - 1), n.abund.re.long)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
} else {
sigma.sq.mu.inits <- 0
beta.star.indx <- 0
Expand Down Expand Up @@ -606,7 +606,7 @@ NMix <- function(abund.formula, det.formula, data, inits, priors, tuning,
}
}
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 @@ -811,11 +811,11 @@ NMix <- function(abund.formula, det.formula, data, inits, priors, tuning,
alpha.inits <- rnorm(p.det, 0, 1)
if (p.abund.re > 0) {
sigma.sq.mu.inits <- runif(p.abund.re, 0.05, 2)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
}
if (p.det.re > 0) {
sigma.sq.p.inits <- runif(p.det.re, 0.05, 2)
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]))
}
if (family == 'NB') {
kappa.inits <- runif(1, kappa.a, kappa.b)
Expand Down
4 changes: 2 additions & 2 deletions R/abund.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ abund <- function(formula, data, inits, priors, tuning,
}
}
beta.star.indx <- rep(0:(p.abund.re - 1), n.abund.re.long)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
} else {
sigma.sq.mu.inits <- 0
beta.star.indx <- 0
Expand Down Expand Up @@ -545,7 +545,7 @@ abund <- function(formula, data, inits, priors, tuning,
}
if (p.abund.re > 0) {
sigma.sq.mu.inits <- runif(p.abund.re, 0.05, 1)
beta.star.inits <- rnorm(n.abund.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.abund.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
}
}
storage.mode(chain.info) <- "integer"
Expand Down
4 changes: 2 additions & 2 deletions R/abundGaussian.R
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ abundGaussian <- function(formula, data, inits, priors, tuning, n.batch,
}
}
beta.star.indx <- rep(0:(p.re - 1), n.re.long)
beta.star.inits <- rnorm(n.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
} else {
sigma.sq.mu.inits <- 0
beta.star.indx <- 0
Expand Down Expand Up @@ -449,7 +449,7 @@ abundGaussian <- function(formula, data, inits, priors, tuning, n.batch,
beta.inits <- rnorm(p, mu.beta, sqrt(sigma.beta))
if (p.re > 0) {
sigma.sq.mu.inits <- runif(p.re, 0.5, 10)
beta.star.inits <- rnorm(n.re, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
beta.star.inits <- rnorm(n.re, 0, sqrt(sigma.sq.mu.inits[beta.star.indx + 1]))
}
tau.sq.inits <- runif(1, 0.1, 10)
}
Expand Down
Loading

0 comments on commit 961b97d

Please sign in to comment.