Learn R Programming

AICcmodavg (version 2.3-2)

covDiag: Compute Covariance Diagnostic for Lambda in N-mixture Models

Description

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.

Usage

covDiag(object, ...)

# S3 method for unmarkedFitPCount covDiag(object, ...)

# S3 method for unmarkedFramePCount covDiag(object, ...)

Value

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., "Warning: lambda is infinite, data too sparse") or not (i.e., NULL).

Arguments

object

an object of class unmarkedFitPCount or unmarkedFramePCount.

...

additional arguments passed to the function.

Author

Marc J. Mazerolle

Details

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.

References

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.

See Also

modavg, modavgPred, Nmix.chisq, Nmix.gof.test, predictSE, pcount

Examples

Run this code
##modified example from ?pcount
if (FALSE) {
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)
}
}

Run the code above in your browser using DataLab