# Compute the asymmetric piecewise linear scoring function (quantile scoring
# function).
df <- data.frame(
y = rep(x = 0, times = 6),
x = c(2, 2, -2, -2, 0, 0),
p = rep(x = c(0.05, 0.95), times = 3)
)
df$quantile_penalty <- quantile_sf(x = df$x, y = df$y, p = df$p)
print(df)
# The absolute error scoring function is twice the asymmetric piecewise linear
# scoring function (quantile scoring function) at level p = 0.5.
df <- data.frame(
y = rep(x = 0, times = 3),
x = c(-2, 0, 2),
p = rep(x = c(0.5), times = 3)
)
df$quantile_penalty <- quantile_sf(x = df$x, y = df$y, p = df$p)
df$absolute_error <- aerr_sf(x = df$x, y = df$y)
print(df)
Run the code above in your browser using DataLab