Title: | Goodness of Fit Checks for Binomial N-Mixture Models |
Version: | 0.1.1 |
Description: | Provides residuals and overdispersion metrics to assess the fit of N-mixture models obtained using the package 'unmarked'. Details on the methods are given in Knape et al. (2017) <doi:10.1101/194340>. |
Depends: | R (≥ 3.3.0) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
LinkingTo: | Rcpp |
Imports: | Rcpp, unmarked |
RoxygenNote: | 7.3.2 |
URL: | https://github.com/jknape/nmixgof |
BugReports: | https://github.com/jknape/nmixgof/issues |
NeedsCompilation: | yes |
Packaged: | 2025-02-12 16:22:03 UTC; jonas |
Author: | Jonas Knape |
Maintainer: | Jonas Knape <jonas.knape@slu.se> |
Repository: | CRAN |
Date/Publication: | 2025-02-12 17:50:05 UTC |
Goodness of fit checks for binomial N-mixture models
Description
The package contains methods to compute overdispersion metrics, randomized quantile residuals, and graphical diagnostics of model fit for binomial N-mixture models fitted using the unmarked package. Details about the checks are given in Knape et al. (2018).
Author(s)
Maintainer: Jonas Knape jonas.knape@slu.se (ORCID)
References
Knape et al. 2018. Sensitivity of binomial N-mixture models to overdispersion: the importance of assessing model fit. Methods in Ecology and Evolution, 9:2102-2114. doi:10.1111/2041-210X.13062
See Also
Useful links:
Overdispersion metrics for binomial N-mixture models.
Description
Computes various types of overdispersion metrics, based on Pearson residuals, for binomial N-mixture models.
Usage
chat(umFit, type = "marginal")
Arguments
umFit |
An object of class unmarkedFit from a model fitted using pcount. |
type |
The type of metric to compute, one of 'marginal', 'site-sum' or 'observation'. |
Value
An estimate of overdispersion relative to the fitted model.
Examples
library(unmarked)
data(mallard)
fm.mallard <- pcount(~ 1 ~ 1, unmarkedFramePCount(y = mallard.y), K=100)
chat(fm.mallard, "m")
chat(fm.mallard, "s")
chat(fm.mallard, "o")
Plot residuals against covariates
Description
A convenience function to plot rq residuals against all untransformed numeric covariates. Site-sum randomized quantile residuals are used for site covariates while marginal residuals are used for observation covariates. The same random residual draws are reused for different covariates.
Usage
residcov(umFit, ...)
Arguments
umFit |
An object of class unmarkedFit from a model fitted using pcount. |
... |
Plot arguments. |
Examples
library(unmarked)
umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)
fmP = pcount(~scale(date) + scale(reedcover) ~ scale(log(water)) + scale(latitude),
data = umf, K = 80)
residcov(fmP)
Plot residuals against fitted values
Description
Plots randomized-quantile residuals for binomial N-mixture models against fitted values.
Usage
residfit(umFit, type = "marginal", ...)
Arguments
umFit |
An object from a model fitted using pcount. |
type |
The type of randomized quantile residual to plot. One of 'marginal', 'site-sum' or 'observation'. |
... |
Plot arguments. |
Examples
library(unmarked)
umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)
fmP = pcount(~scale(date) + scale(reedcover) ~ scale(log(water)) + scale(latitude),
data = umf, K = 80)
residfit(fmP, "marginal")
residfit(fmP, "site-sum")
residfit(fmP, "observation")
Qq plot of randomized quantile residuals against standard normal quantiles
Description
Qq plot of randomized quantile residuals against standard normal quantiles
Usage
residqq(
umFit,
type = "site-sum",
main = "Residual qq plot",
plotLine = TRUE,
...
)
Arguments
umFit |
An object of class unmarkedFit from a model fitted using pcount. |
type |
The type of randomized quantile residual to plot. One of 'site-sum' or 'observation'. |
main |
Plot label. |
plotLine |
If true, the identity line is added to the plot. |
... |
Further arguments passed to qqnorm. |
Value
A list with x and y coordinates of the qq plot, see qqnorm.
Examples
library(unmarked)
umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)
fmP = pcount(~scale(date) + scale(reedcover) ~ scale(log(water)) + scale(latitude),
data = umf, K = 80)
residqq(fmP, "site-sum")
residqq(fmP, "observation")
Randomized quantile resiudals for binomial N-mixture models.
Description
Computes three types of randomized quantile residuals for binomial N-mixture models.
Usage
rqresiduals(umFit, type = "marginal")
Arguments
umFit |
An object of class unmarkedFit from a model fitted using pcount. |
type |
The type of rq residuals to compute, one of 'marginal', 'site-sum' or 'observation'. |
Value
A matrix (if type
is 'marginal' or 'site-sum') or vector (for ) con.
Examples
library(unmarked)
umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)
fmP = pcount(~scale(date) + scale(reedcover) ~ scale(log(water)) + scale(latitude),
data = umf, K = 80)
qqnorm(rqresiduals(fmP, "s"))
qqnorm(rqresiduals(fmP, "o"))
par(mfcol = c(3,4))
invisible(apply(rqresiduals(fmP, "m"), 2, qqnorm))
Northern shoveler data
Description
Repeated count data of Northern shoveler with covariates, formatted for use with the unmarked package.
Usage
shoveler
Format
A list with three elements
- y
A matrix with Northern shoveler counts
- site
A data frame with site specific covariates
- obs
A list containing observation specific covariates
References
Knape et al. (2018) Methods in Ecology and Evolution, 9:2102-2114. doi:10.1111/2041-210X.13062
Examples
library(unmarked)
umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)