loss_functions: Loss functions

Description Usage Arguments Examples

Description

Loss functions

Quadratic loss

Absolute loss

Difference loss

Huber loss

Hinge loss

Usage

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
)

# Absolute loss
loss_absolute(
  observed = observed,
  predicted = predicted,
  SESOI_lower = SESOI_lower,
  SESOI_upper = SESOI_upper
)

# Difference
loss_difference(
  observed = observed,
  predicted = predicted,
  SESOI_lower = SESOI_lower,
  SESOI_upper = SESOI_upper
)

# Huber loss
loss_huber(
  observed = observed,
  predicted = predicted,
  SESOI_lower = SESOI_lower,
  SESOI_upper = SESOI_upper
)

# Hinge loss
loss_hinge(
  observed = observed,
  predicted = predicted,
  SESOI_lower = SESOI_lower,
  SESOI_upper = SESOI_upper
)

mladenjovanovic/bmbstats documentation built on Aug. 5, 2020, 4:20 p.m.