# Compute the n-th moment scoring function.
df <- data.frame(
y = rep(x = 2, times = 6),
x = c(1, 2, 3, 1, 2, 3),
n = c(2, 2, 2, 3, 3, 3)
)
df$nmoment_penalty <- nmoment_sf(x = df$x, y = df$y, n = df$n)
print(df)
Run the code above in your browser using DataLab