From 08e085adbd38e73c7bbcacb84df3c9e5e86228fc Mon Sep 17 00:00:00 2001 From: doserjef Date: Thu, 19 Oct 2023 06:45:16 -0400 Subject: [PATCH] fixing stuff for CRAN --- DESCRIPTION | 4 +- man/dataNMixSim.rda.Rd | 128 ++++++++++++++++++++--------------------- 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 562eec1..eeb67da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,12 +2,12 @@ Package: spAbundance Type: Package Title: Univariate and Multivariate Spatial Modeling of Species Abundance Version: 0.1.0 -Author: Jeffrey Doser [aut, cre], Andrew O. Finley [aut] -Maintainer: Jeffrey Doser +Authors@R: c(person("Jeffrey", "Doser", role=c("aut", "cre"), email="doserjef@msu.edu"), person("Andrew", "Finley", role = c("aut"))) Description: Fits single-species (univariate) and multi-species (multivariate) non-spatial and spatial abundance models in a Bayesian framework using Markov Chain Monte Carlo (MCMC). Spatial models are fit using Nearest Neighbor Gaussian Processes (NNGPs). Details on NNGP models are given in Datta, Banerjee, Finley, and Gelfand (2016) and Finley, Datta, and Banerjee (2020) . Fits single-species and multi-species spatial and non-spatial versions of generalized linear mixed models (Gaussian, Poisson, Negative Binomial), N-mixture models (Royle 2004 ) and hierarchical distance sampling models (Royle, Dawson, Bates (2004) ). Multi-species spatial models are fit using a spatial factor modeling approach with NNGPs for computational efficiency. License: GPL (>= 3) Encoding: UTF-8 LazyData: true +URL: https://www.jeffdoser.com/files/spabundance-web BugReports: https://github.com/doserjef/spAbundance/issues Depends: R (>= 3.5.0) Imports: diff --git a/man/dataNMixSim.rda.Rd b/man/dataNMixSim.rda.Rd index 7ec8de6..0703c58 100644 --- a/man/dataNMixSim.rda.Rd +++ b/man/dataNMixSim.rda.Rd @@ -38,70 +38,68 @@ data(dataNMixSim) \keyword{datasets} \examples{ -\dontrun{ - set.seed(6) - J.x <- 15 - J.y <- 15 - J <- J.x * J.y - n.rep <- sample(3, size = J, replace = TRUE) - # n.rep <- rep(5, J) - n.sp <- 6 - # Community-level covariate effects - # Occurrence - beta.mean <- c(-1, 0.5) - p.abund <- length(beta.mean) - tau.sq.beta <- c(0.4, 1.2) - # Detection - alpha.mean <- c(0, 0.5, 0.8) - tau.sq.alpha <- c(0.2, 1, 1.5) - p.det <- length(alpha.mean) - # Random effects - mu.RE <- list() - mu.RE <- list(levels = c(10), - sigma.sq.mu = c(0.5), - beta.indx = list(1)) - p.RE <- list() - # Draw species-level effects from community means. - beta <- matrix(NA, nrow = n.sp, ncol = p.abund) - alpha <- matrix(NA, nrow = n.sp, ncol = p.det) - for (i in 1:p.abund) { - beta[, i] <- rnorm(n.sp, beta.mean[i], sqrt(tau.sq.beta[i])) - } - for (i in 1:p.det) { - alpha[, i] <- rnorm(n.sp, alpha.mean[i], sqrt(tau.sq.alpha[i])) - } - alpha.true <- alpha - sp <- TRUE - n.factors <- 3 - factor.model <- TRUE - phi <- runif(n.factors, 3/1, 3 / .2) - kappa <- runif(n.sp, 0.1, 1) - family <- 'Poisson' - - dat <- simMsNMix(J.x = J.x, J.y = J.y, n.rep = n.rep, n.sp = n.sp, beta = beta, alpha = alpha, - mu.RE = mu.RE, p.RE = p.RE, sp = sp, kappa = kappa, family = family, - factor.model = factor.model, phi = phi, - cov.model = 'exponential', n.factors = n.factors) - table(dat$N) - apply(dat$N, 1, sum) - - y <- dat$y - X <- dat$X - X.p <- dat$X.p - X.re <- dat$X.re - X.p.re <- dat$X.p.re - coords <- dat$coords - dimnames(coords)[[2]] <- c('X', 'Y') - - # Package all data into a list - abund.covs <- cbind(X, X.re) - colnames(abund.covs) <- c('int', 'abund.cov.1', 'abund.factor.1') - abund.covs <- abund.covs[, -1] - det.covs <- list(det.cov.1 = X.p[, , 2], - det.cov.2 = X.p[, , 3]) - dataNMixSim <- list(y = y, - abund.covs = abund.covs, - det.covs = det.covs, - coords = coords) +set.seed(6) +J.x <- 15 +J.y <- 15 +J <- J.x * J.y +n.rep <- sample(3, size = J, replace = TRUE) +# n.rep <- rep(5, J) +n.sp <- 6 +# Community-level covariate effects +# Occurrence +beta.mean <- c(-1, 0.5) +p.abund <- length(beta.mean) +tau.sq.beta <- c(0.4, 1.2) +# Detection +alpha.mean <- c(0, 0.5, 0.8) +tau.sq.alpha <- c(0.2, 1, 1.5) +p.det <- length(alpha.mean) +# Random effects +mu.RE <- list() +mu.RE <- list(levels = c(10), + sigma.sq.mu = c(0.5), + beta.indx = list(1)) +p.RE <- list() +# Draw species-level effects from community means. +beta <- matrix(NA, nrow = n.sp, ncol = p.abund) +alpha <- matrix(NA, nrow = n.sp, ncol = p.det) +for (i in 1:p.abund) { + beta[, i] <- rnorm(n.sp, beta.mean[i], sqrt(tau.sq.beta[i])) } +for (i in 1:p.det) { + alpha[, i] <- rnorm(n.sp, alpha.mean[i], sqrt(tau.sq.alpha[i])) +} +alpha.true <- alpha +sp <- TRUE +n.factors <- 3 +factor.model <- TRUE +phi <- runif(n.factors, 3/1, 3 / .2) +kappa <- runif(n.sp, 0.1, 1) +family <- 'Poisson' + +dat <- simMsNMix(J.x = J.x, J.y = J.y, n.rep = n.rep, n.sp = n.sp, beta = beta, alpha = alpha, + mu.RE = mu.RE, p.RE = p.RE, sp = sp, kappa = kappa, family = family, + factor.model = factor.model, phi = phi, + cov.model = 'exponential', n.factors = n.factors) +table(dat$N) +apply(dat$N, 1, sum) + +y <- dat$y +X <- dat$X +X.p <- dat$X.p +X.re <- dat$X.re +X.p.re <- dat$X.p.re +coords <- dat$coords +dimnames(coords)[[2]] <- c('X', 'Y') + +# Package all data into a list +abund.covs <- cbind(X, X.re) +colnames(abund.covs) <- c('int', 'abund.cov.1', 'abund.factor.1') +abund.covs <- abund.covs[, -1] +det.covs <- list(det.cov.1 = X.p[, , 2], + det.cov.2 = X.p[, , 3]) +dataNMixSim <- list(y = y, + abund.covs = abund.covs, + det.covs = det.covs, + coords = coords) }