Loss functions

Quadratic loss

Absolute loss

Difference loss

Huber loss

Hinge loss

loss_quadratic(
  observed,
  predicted,
  SESOI_lower = 0,
  SESOI_upper = 0,
  negative_weight = 1,
  positive_weight = 1,
  na.rm = FALSE
)

loss_absolute(
  observed,
  predicted,
  SESOI_lower = 0,
  SESOI_upper = 0,
  negative_weight = 1,
  positive_weight = 1,
  na.rm = FALSE
)

loss_difference(
  observed,
  predicted,
  SESOI_lower = 0,
  SESOI_upper = 0,
  negative_weight = 1,
  positive_weight = 1,
  na.rm = FALSE
)

loss_huber(
  observed,
  predicted,
  SESOI_lower = 0,
  SESOI_upper = 0,
  negative_weight = 1,
  positive_weight = 1,
  na.rm = FALSE
)

loss_hinge(
  observed,
  predicted,
  SESOI_lower = 0,
  SESOI_upper = 0,
  negative_weight = 1,
  positive_weight = 1,
  exponent = 1,
  na.rm = FALSE
)

Arguments

observed

Numeric vector

predicted

Numeric vector

SESOI_lower

Lower smallest effect size of interest threshold

SESOI_upper

Upper smallest effect size of interest threshold

negative_weight

How should negative residuals be weighted? Default is 1

positive_weight

How should positive residuals be weighted? Default is 1

na.rm

Should NAs be removed? Default is FALSE

exponent

Numeric scalar. Default is 1.

Examples

data("yoyo_mas_data") model <- lm(MAS ~ YoYoIR1, yoyo_mas_data) observed <- yoyo_mas_data$MAS predicted <- predict(model) SESOI_lower <- -0.5 SESOI_upper <- 0.5 # Square loss loss_quadratic( observed = observed, predicted = predicted, SESOI_lower = SESOI_lower, SESOI_upper = SESOI_upper )
#> 1 2 3 4 5 6 #> 1.643043e-03 1.061036e-01 3.205411e-02 2.479935e-02 3.608629e-05 7.271095e-02 #> 7 8 9 10 11 12 #> 3.855537e-03 3.205411e-02 3.285686e-03 4.470933e-03 7.530729e-02 1.028040e-02 #> 13 14 15 16 17 18 #> 1.917626e-01 9.335474e-03 4.560953e-02 8.480220e-02 3.855537e-03 3.855537e-03 #> 19 20 21 22 23 24 #> 7.016015e-02 2.052682e-03 1.173212e-01 1.173212e-01 2.479935e-02 5.306127e-02 #> 25 26 27 28 29 30 #> 2.331913e-02 5.306127e-02 1.643043e-03 2.052682e-03 1.396622e-02 1.551065e-01
# Absolute loss loss_absolute( observed = observed, predicted = predicted, SESOI_lower = SESOI_lower, SESOI_upper = SESOI_upper )
#> 1 2 3 4 5 6 #> 0.040534471 0.325735459 0.179036605 0.157478105 0.006007186 0.269649674 #> 7 8 9 10 11 12 #> 0.062092971 0.179036605 0.057320907 0.066865035 0.274421738 0.101392320 #> 13 14 15 16 17 18 #> 0.437907029 0.096620256 0.213563890 0.291208174 0.062092971 0.062092971 #> 19 20 21 22 23 24 #> 0.264877611 0.045306535 0.342521895 0.342521895 0.157478105 0.230350326 #> 25 26 27 28 29 30 #> 0.152706041 0.230350326 0.040534471 0.045306535 0.118178756 0.393835616
# Difference loss_difference( observed = observed, predicted = predicted, SESOI_lower = SESOI_lower, SESOI_upper = SESOI_upper )
#> 1 2 3 4 5 6 #> -0.040534471 -0.325735459 0.179036605 -0.157478105 0.006007186 -0.269649674 #> 7 8 9 10 11 12 #> 0.062092971 0.179036605 0.057320907 0.066865035 -0.274421738 -0.101392320 #> 13 14 15 16 17 18 #> -0.437907029 -0.096620256 -0.213563890 0.291208174 0.062092971 0.062092971 #> 19 20 21 22 23 24 #> -0.264877611 -0.045306535 0.342521895 0.342521895 -0.157478105 0.230350326 #> 25 26 27 28 29 30 #> -0.152706041 0.230350326 -0.040534471 -0.045306535 0.118178756 0.393835616
# Huber loss loss_huber( observed = observed, predicted = predicted, SESOI_lower = SESOI_lower, SESOI_upper = SESOI_upper )
#> 1 2 3 4 5 6 #> 8.215217e-04 5.305179e-02 1.602705e-02 1.239968e-02 1.804314e-05 3.635547e-02 #> 7 8 9 10 11 12 #> 1.927769e-03 1.602705e-02 1.642843e-03 2.235466e-03 3.765365e-02 5.140201e-03 #> 13 14 15 16 17 18 #> 9.588128e-02 4.667737e-03 2.280477e-02 4.240110e-02 1.927769e-03 1.927769e-03 #> 19 20 21 22 23 24 #> 3.508007e-02 1.026341e-03 5.866062e-02 5.866062e-02 1.239968e-02 2.653064e-02 #> 25 26 27 28 29 30 #> 1.165957e-02 2.653064e-02 8.215217e-04 1.026341e-03 6.983109e-03 7.755325e-02
# Hinge loss loss_hinge( observed = observed, predicted = predicted, SESOI_lower = SESOI_lower, SESOI_upper = SESOI_upper )
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 27 28 29 30 #> 0 0 0 0