Arithmetic mean of upper - lower, i.e. PIW(tau) = sum(upper - lower) / n
for a tau-level prediction interval. Smaller widths are sharper, but should
always be interpreted jointly with empirical coverage. PIW is independent of
observed values: obs is retained only to check input length compatibility.
Central intervals have lower and upper predictive quantiles at
(1 - tau) / 2 and (1 + tau) / 2, respectively.
Usage
interval_width(
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.
Details
$$\mathrm{PIW}(\tau) = \frac{1}{n}\sum_{i=1}^{n}(upper_i-lower_i)$$
PIW has response units. Smaller values indicate sharper predictions, but are
desirable only when calibration is adequate; assess it alongside picp().
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.
References
Schmidinger, J. and Heuvelink, G. B. M. (2023). Validation of uncertainty predictions in digital soil mapping. Geoderma, 437, 116585. doi:10.1016/j.geoderma.2023.116585
