pit | R Documentation |
Probability integral transform (PIT). LOO-PIT is given by a weighted sample.
pit(x, y, ...)
## Default S3 method:
pit(x, y, weights = NULL, log = FALSE, ...)
## S3 method for class 'draws_matrix'
pit(x, y, weights = NULL, log = FALSE, ...)
## S3 method for class 'rvar'
pit(x, y, weights = NULL, log = FALSE, ...)
x |
(draws) A |
y |
(observations) A 1D vector, or an array of dim(x), if x is |
... |
Arguments passed to individual methods (if applicable). |
weights |
A matrix of weights for each draw and variable. |
log |
(logical) Are the weights passed already on the log scale? The
default is |
The pit()
function computes the probability integral transform of
y
using the empirical cumulative distribution computed from the samples
in x
. For continuous valued y
and x
, the PIT for the elements of y
is computed as the empirical cumulative distribution value:
PIT(y_i) = Pr(x_i < y_i),
where x_i, is the corresponding set of draws in x
. For draws
objects,
this corresponds to the draws of the ith variable, and for rvar
the elements of y
and x
are matched.
The draws in x
can further be provided (log-)weights in
If y
and x
are discrete, randomisation is used to obtain continuous PIT
values. (see, e.g., Czado, C., Gneiting, T., Held, L.: Predictive model
assessment for count data. Biometrics 65(4), 1254–1261 (2009).)
A numeric vector of length length(y)
containing the PIT values, or
an array of shape dim(y)
, if x
is an rvar
.
# PIT for a draws object
x <- example_draws()
# Create a vector of observations
y <- rnorm(nvariables(x), 5, 5)
pit(x, y)
# Compute weighted PIT (for example LOO-PIT)
weights <- matrix(runif(length(x)), ncol = nvariables(x))
pit(x, y, weights)
# PIT for an rvar
x <- rvar(example_draws())
# Create an array of observations with the same dimensions as x.
y_arr <- array(rnorm(length(x), 5, 5), dim = dim(x))
pit(x, y_arr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.