# Median Fair loss (just the Fair loss...)
library(Deriv) # loads the required library
fc <- function(x, c=2, t=0.5)
{(c^2) * ((abs(x) / c) - log(1 + (abs(x) / c))) * ifelse(x > 0, 2 * t, 2-2*t)}
fc_ref <- function(x) {x^2} # Quadratic loss, aka Mean Squared Error
SymbolicLoss(fc = fc,
fc_ref = fc_ref,
verbose = TRUE,
plotting = TRUE)
Run the code above in your browser using DataLab