quantile_to_interval | R Documentation |
Quantile format In a quantile format, a prediction is characterised by one or multiple predicted values and the corresponding quantile levels. For example, a prediction in a quantile format could be represented by the 0.05, 0.25, 0.5, 0.75 and 0.95 quantiles of the predictive distribution.
Interval format In the interval format, two quantiles are assumed to form a prediction interval. Prediction intervals need to be symmetric around the median and are characterised by a lower and an upper bound. The lower bound is defined by the lower quantile and the upper bound is defined by the upper quantile. A 90% prediction interval, for example, covers 90% of the probability mass and is defined by the 5% and 95% quantiles. A forecast could therefore be characterised by one or multiple prediction intervals, e.g. the lower and upper bounds of the 50% and 90% prediction intervals (corresponding to the 0.25 and 0.75 as well as the 0.05 and 0.095 quantiles).
quantile_to_interval(...)
## S3 method for class 'data.frame'
quantile_to_interval(forecast, format = "long", keep_quantile_col = FALSE, ...)
## S3 method for class 'numeric'
quantile_to_interval(observed, predicted, quantile_level, ...)
... |
Arguments |
forecast |
A data.table with forecasts in a quantile-based format (see
|
format |
The format of the output. Either "long" or "wide". If "long"
(the default), there will be a column |
keep_quantile_col |
keep the |
observed |
Numeric vector of size n with the observed values. |
predicted |
Numeric nxN matrix of predictive
quantiles, n (number of rows) being the number of forecasts (corresponding
to the number of observed values) and N
(number of columns) the number of quantiles per forecast.
If |
quantile_level |
Vector of of size N with the quantile levels for which predictions were made. |
A data.table with forecasts in an interval format.
quantile_to_interval.data.frame:
a data.table in an interval format (either "long" or "wide"), with or
without a quantile_level
column. Rows will not be reordered.
quantile_to_interval.numeric:
a data.table in a wide interval format with columns forecast_id
,
observed
, lower
, upper
, and interval_range
. The forecast_id
column
is a unique identifier for each forecast. Rows will be reordered according to
forecast_id
and interval_range
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.