Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pit

Non-Randomized Version of the PIT Histogram (for Count Data)


Description

See Czado et al. (2009).

Usage

pit(x, ...)
## Default S3 method:
pit(x, pdistr, J = 10, relative = TRUE, ..., plot = list())

Arguments

x

numeric vector representing the observed counts.

pdistr

either a list of predictive cumulative distribution functions for the observations x, or (the name of) a single predictive CDF used for all x (with potentially varying arguments ...). It is checked that the predictive CDF returns 0 at x=-1. The name of its first argument can be different from x, e.g., pdistr="pnbinom" is possible.
If pdistr is a single function and no additional ... arguments are supplied, pdistr is assumed to be vectorized, i.e., it is simply called as pdistr(x) and pdistr(x-1). Otherwise, the predictive CDF is called sequentially and does not need to be vectorized.

J

the number of bins of the histogram.

relative

logical indicating if relative frequency or the density should be plotted. Due to a historical bug, relative=TRUE (the default) actually plots a density histogram while relative=FALSE plots relative frequencies.

...

ignored if pdistr is a list. Otherwise, such additional arguments are used in sequential calls of pdistr via mapply(pdistr, x, ...).

plot

a list of arguments for plot.histogram. Otherwise, no plot will be produced.

Value

an object of class "pit", which inherits from class "histogram" (see hist). It is returned invisibly if a plot is produced.

Author(s)

Michaela Paul and Sebastian Meyer

References

Czado, C., Gneiting, T. and Held, L. (2009): Predictive model assessment for count data. Biometrics, 65 (4), 1254-1261. doi: 10.1111/j.1541-0420.2009.01191.x

Examples

## Simulation example of Czado et al. (2009, Section 2.4)
set.seed(100)
x <- rnbinom(200, mu = 5, size = 2)
pdistrs <- list("NB(5,0)"   = function (x) ppois(x, lambda=5),
                "NB(5,1/2)" = function (x) pnbinom(x, mu=5, size=2),
                "NB(5,1)"   = function (x) pnbinom(x, mu=5, size=1))
## Reproduce Figure 1
op <- par(mfrow = c(1,3))
for (i in seq_along(pdistrs)) {
    pit(x, pdistr = pdistrs[[i]], J = 10,
        plot = list(ylim = c(0,2.75), main = names(pdistrs)[i]))
    box()
}
par(op)

## Alternative call using ... arguments for pdistr (less efficient)
stopifnot(identical(pit(x, "pnbinom", mu = 5, size = 2, plot = FALSE),
                    pit(x, pdistrs[[2]], plot = FALSE)))

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.