# Compute the generalized piecewise linear scoring function (type 2).
df <- data.frame(
y = rep(x = 2, times = 6),
x = c(1, 2, 3, 1, 2, 3),
p = c(rep(x = 0.05, times = 3), rep(x = 0.95, times = 3))
)
df$gpl2_penalty <- gpl2_sf(x = df$x, y = df$y, p = df$p)
print(df)
# The generalized piecewise linear scoring function (type 2) is half the MAE-LOG
# scoring function.
df <- data.frame(
y = rep(x = 5.5, times = 10),
x = 1:10,
p = rep(x = 0.5, times = 10)
)
df$gpl2_penalty <- gpl2_sf(x = df$x, y = df$y, p = df$p)
df$mae_log_penalty <- maelog_sf(x = df$x, y = df$y)
df$ratio <- df$gpl2_penalty/df$mae_log_penalty
print(df)
Run the code above in your browser using DataLab