covDiag | R Documentation |
This function extracts the covariance diagnostic of Dennis et al. (2015)
for lambda in N-mixture models (Royle 2004) of the
unmarkedFitPCount
class as well as in data frames of the
unmarkedFramePcount
class.
covDiag(object, ...)
## S3 method for class 'unmarkedFitPCount'
covDiag(object, ...)
## S3 method for class 'unmarkedFramePCount'
covDiag(object, ...)
object |
an object of class |
... |
additional arguments passed to the function. |
This function extracts the covariance diagnostic developed by Dennis
et al. (2015) for lambda in N-mixture models. Values <= 0
suggest sparse data and potential problems during model fitting.
covDiag
can take data frames of the unmarkedFramePcount
class as input. For convenience, the function also takes the repeated
count model object as input, extracts the raw data, and computes the
covariance diagnostic. Thus, different models on the same data set
will have identical values for this covariance diagnostic.
covDiag
returns a list with the following components:
cov.diag |
the value of the covariance diagnostic. |
message |
a string indicating whether a warning was issued (i.e.,
|
Marc J. Mazerolle
Dennis, E. B., Morgan, B. J. T., Ridout, M. S. (2015) Computational aspects of N-mixture models. Biometrics 71, 237–246.
Royle, J. A. (2004) N-mixture models for estimating population size from spatially replicated counts. Biometrics 60, 108–115.
modavg
, modavgPred
,
Nmix.chisq
, Nmix.gof.test
,
predictSE
, pcount
##modified example from ?pcount
## Not run:
if(require(unmarked)){
##Simulate data
set.seed(3)
nSites <- 100
nVisits <- 3
##covariate
x <- rnorm(nSites)
beta0 <- 0
beta1 <- 1
##expected counts
lambda <- exp(beta0 + beta1*x)
N <- rpois(nSites, lambda)
y <- matrix(NA, nSites, nVisits)
p <- c(0.3, 0.6, 0.8)
for(j in 1:nVisits) {
y[,j] <- rbinom(nSites, N, p[j])
}
## Organize data
visitMat <- matrix(as.character(1:nVisits),
nSites, nVisits, byrow=TRUE)
umf <- unmarkedFramePCount(y=y, siteCovs=data.frame(x=x),
obsCovs=list(visit=visitMat))
## Fit model
fm1 <- pcount(~ visit ~ 1, umf, K=50)
covDiag(fm1)
##sparser data
p <- c(0.01, 0.001, 0.01)
for(j in 1:nVisits) {
y[,j] <- rbinom(nSites, N, p[j])
}
## Organize data
visitMat <- matrix(as.character(1:nVisits),
nSites, nVisits, byrow=TRUE)
umf <- unmarkedFramePCount(y=y, siteCovs=data.frame(x=x),
obsCovs=list(visit=visitMat))
## Fit model
fm.sparse <- pcount(~ visit ~ 1, umf, K=50)
covDiag(fm.sparse)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.