ppcOcc | R Documentation |
Function for performing posterior predictive checks on spOccupancy
model objects.
ppcOcc(object, fit.stat, group, ...)
object |
an object of class |
fit.stat |
a quoted keyword that specifies the fit statistic
to use in the posterior predictive check. Supported fit statistics are
|
group |
a positive integer indicating the way to group the detection-nondetection data for the posterior predictive check. Value 1 will group values by row (site) and value 2 will group values by column (replicate). |
... |
currently no additional arguments |
Standard GoF assessments are not valid for binary data, and posterior predictive checks must be performed on some sort of binned data.
An object of class ppcOcc
that is a list comprised of:
fit.y |
a numeric vector of posterior samples for the
fit statistic calculated on the observed data when |
fit.y.rep |
a numeric vector of posterior samples for the
fit statistic calculated on a replicate data set generated from the
model when |
fit.y.group.quants |
a matrix consisting of posterior quantiles
for the fit statistic using the observed data for each unique element
the fit statistic is calculated for (i.e., sites when group = 1,
replicates when group = 2) when |
fit.y.rep.group.quants |
a matrix consisting of posterior quantiles
for the fit statistic using the model replicated data for each unique element
the fit statistic is calculated for (i.e., sites when group = 1,
replicates when group = 2) when |
The return object will include additional objects used for standard extractor functions.
Jeffrey W. Doser doserjef@msu.edu,
set.seed(400)
# Simulate Data -----------------------------------------------------------
J.x <- 8
J.y <- 8
J <- J.x * J.y
n.rep <- sample(2:4, J, replace = TRUE)
beta <- c(0.5, -0.15)
p.occ <- length(beta)
alpha <- c(0.7, 0.4)
p.det <- length(alpha)
dat <- simOcc(J.x = J.x, J.y = J.y, n.rep = n.rep, beta = beta, alpha = alpha,
sp = FALSE)
occ.covs <- dat$X[, 2, drop = FALSE]
colnames(occ.covs) <- c('occ.cov')
det.covs <- list(det.cov = dat$X.p[, , 2])
# Data bundle
data.list <- list(y = dat$y,
occ.covs = occ.covs,
det.covs = det.covs)
# Priors
prior.list <- list(beta.normal = list(mean = 0, var = 2.72),
alpha.normal = list(mean = 0, var = 2.72))
# Initial values
inits.list <- list(alpha = 0, beta = 0,
z = apply(data.list$y, 1, max, na.rm = TRUE))
n.samples <- 5000
n.report <- 1000
out <- PGOcc(occ.formula = ~ occ.cov,
det.formula = ~ det.cov,
data = data.list,
inits = inits.list,
n.samples = n.samples,
priors = prior.list,
n.omp.threads = 1,
verbose = TRUE,
n.report = n.report,
n.burn = 4000,
n.thin = 1)
# Posterior predictive check
ppc.out <- ppcOcc(out, fit.stat = 'chi-squared', group = 1)
summary(ppc.out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.