# Compute the generalized piecewise linear scoring function (type 1).
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)),
b = rep(x = 2, times = 6)
)
df$gpl1_penalty <- gpl1_sf(x = df$x, y = df$y, p = df$p, b = df$b)
print(df)
# Equivalence of generalized piecewise linear scoring function (type 1) and
# asymmetric piecewise linear scoring function (quantile scoring function), when
# b = 1.
set.seed(12345)
n <- 100
x <- runif(n, 0, 20)
y <- runif(n, 0, 20)
p <- runif(n, 0, 1)
b <- rep(x = 1, times = n)
u <- gpl1_sf(x = x, y = y, p = p, b = b)
v <- quantile_sf(x = x, y = y, p = p)
max(abs(u - v))
# Equivalence of generalized piecewise linear scoring function (type 1) and
# MAE-SD scoring function, when p = 1/2 and b = 1/2.
set.seed(12345)
n <- 100
x <- runif(n, 0, 20)
y <- runif(n, 0, 20)
p <- rep(x = 0.5, times = n)
b <- rep(x = 1/2, times = n)
u <- gpl1_sf(x = x, y = y, p = p, b = b)
v <- maesd_sf(x = x, y = y)
max(abs(u - v))
Run the code above in your browser using DataLab