pinball: Pinball function

View source: R/error-measures.R

pinballR Documentation

Pinball function

Description

The function returns the value from the pinball function for the specified level and the type of loss

Usage

pinball(holdout, forecast, level, loss = 1, na.rm = TRUE)

Arguments

holdout

The vector or matrix of the holdout values.

forecast

The forecast of a distribution (e.g. quantile or expectile). It should be the same length as the holdout.

level

The level associated with the forecast (e.g. level of quantile).

loss

The type of loss to use. The number which corresponds to L1, L2 etc. L1 implies the loss for quantiles, while L2 is for the expectile.

na.rm

Logical, defining whether to remove the NAs from the provided data or not.

Value

The function returns the scalar value.

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

Examples

# An example with mtcars data
ourModel <- alm(mpg~., mtcars[1:30,], distribution="dnorm")

# Produce predictions with the interval
ourForecast <- predict(ourModel, mtcars[-c(1:30),], interval="p")

# Pinball with the L1 (quantile value)
pinball(mtcars$mpg[-c(1:30)],ourForecast$upper,level=0.975,loss=1)
pinball(mtcars$mpg[-c(1:30)],ourForecast$lower,level=0.025,loss=1)

# Pinball with the L2 (expectile value)
pinball(mtcars$mpg[-c(1:30)],ourForecast$upper,level=0.975,loss=2)
pinball(mtcars$mpg[-c(1:30)],ourForecast$lower,level=0.025,loss=2)


config-i1/greybox documentation built on Dec. 12, 2024, 1:42 p.m.