
Squared-error decomposition into bias, variance and noise (p. 158)
Source:R/ml_geron.R
morie_bvdecomp.Rdp. 158 states IN WORDS that the generalization error is the sum of bias, variance and irreducible error; NO formula is printed there. The decomposition computed here is stated explicitly rather than attributed to the book: MSE = mean_i (mean_b f_b(x_i) - y_i)^2 + mean_i var_b(f_b(x_i)) + noisevar.
Examples
preds <- rbind(c(1, 2, 3), c(1.5, 2.5, 2.5)) # two bootstrap models, three test points
morie_bvdecomp(preds, truth = c(1, 2, 3), noisevar = 0.1)
#> $bias2
#> [1] 0.0625
#>
#> $variance
#> [1] 0.0625
#>
#> $noise
#> [1] 0.1
#>
#> $total
#> [1] 0.225
#>
#> $mse
#> [1] 0.125
#>
#> $residual
#> [1] 0
#>
#> $b
#> [1] 2
#>
#> $n
#> [1] 3
#>