Title: | Goodness of Fit Checks for Binomial N-Mixture Models |
---|---|
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>. |
Authors: | Jonas Knape [aut, cre] |
Maintainer: | Jonas Knape <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2025-02-13 10:22:35 UTC |
Source: | https://github.com/jknape/nmixgof |
Computes various types of overdispersion metrics, based on Pearson residuals, for binomial N-mixture models.
chat(umFit, type = "marginal")
chat(umFit, type = "marginal")
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'. |
An estimate of overdispersion relative to the fitted model.
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")
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")
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).
Maintainer: Jonas Knape [email protected] (ORCID)
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
Useful links:
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.
residcov(umFit, ...)
residcov(umFit, ...)
umFit |
An object of class unmarkedFit from a model fitted using pcount. |
... |
Plot arguments. |
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)
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)
Plots randomized-quantile residuals for binomial N-mixture models against fitted values.
residfit(umFit, type = "marginal", ...)
residfit(umFit, type = "marginal", ...)
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. |
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")
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
residqq( umFit, type = "site-sum", main = "Residual qq plot", plotLine = TRUE, ... )
residqq( umFit, type = "site-sum", main = "Residual qq plot", plotLine = TRUE, ... )
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. |
A list with x and y coordinates of the qq plot, see qqnorm.
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")
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")
Computes three types of randomized quantile residuals for binomial N-mixture models.
rqresiduals(umFit, type = "marginal")
rqresiduals(umFit, type = "marginal")
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'. |
A matrix (if type
is 'marginal' or 'site-sum') or vector (for ) con.
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))
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))
Repeated count data of Northern shoveler with covariates, formatted for use with the unmarked package.
shoveler
shoveler
A list with three elements
A matrix with Northern shoveler counts
A data frame with site specific covariates
A list containing observation specific covariates
Knape et al. (2018) Methods in Ecology and Evolution, 9:2102-2114. doi:10.1111/2041-210X.13062
library(unmarked) umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)
library(unmarked) umf = unmarkedFramePCount(y = shoveler$y, obsCovs = shoveler$obs, siteCovs = shoveler$site)