Skip to contents

Backward-compatible alias for picp(). New code should prefer picp(), the conventional abbreviation for prediction interval coverage probability. Its equation, interpretation, and reference are given in picp().

Usage

coverage(
  obs,
  lower = NULL,
  upper = NULL,
  na.rm = TRUE,
  level = 0.95,
  pred = NULL,
  predictive_sd = NULL,
  distribution = NULL
)

Arguments

obs

Numeric observation vector.

lower, upper

Optional numeric lower and upper prediction-interval bounds. Supply both, without another input representation.

na.rm

Logical; remove incomplete cases? See Input representations.

level

Nominal central interval coverage, strictly between zero and one. Used to generate bounds from predictive means and standard deviations or predictive samples; it does not alter explicit bounds.

pred, predictive_sd

Optional numeric vectors of predictive means and predictive standard deviations, supplied together and of the same length as obs. Assumes normal predictive distributions. Non-missing predictive standard deviations must be finite and strictly positive.

distribution

Optional numeric matrix or data frame of equally weighted predictive samples: one row per observation and one column per predictive draw. Supply this instead of bounds or predictive means and standard deviations. At least one draw is required; infinite values are not allowed.

Value

One numeric value on the probability scale from zero to one.

Input representations

Supply exactly one of explicit lower and upper bounds, predictive mean and standard deviation (pred and predictive_sd), or predictive samples (distribution). Normal inputs generate central intervals using normal quantiles. Samples generate equal-tailed intervals using stats::quantile() with type = 7, at probabilities (1 - level) / 2 and (1 + level) / 2. With na.rm = TRUE, a case is removed if its observation or any supplied predictive value is missing; individual missing draws are not discarded within a case. With na.rm = FALSE, incomplete inputs give NA. No complete cases also gives NA. Standalone interval_width() ignores missing obs.

Examples

coverage(1:3, c(0, 1, 2), c(2, 3, 4))
#> [1] 1