bvd: Decompose the prediction error (mean-squared error) into bias...

View source: R/bvd.R

bvdR Documentation

Decompose the prediction error (mean-squared error) into bias and variance components

Description

Decompose the prediction error (mean-squared error) into bias and variance components

Usage

bvd(preds, obs)

Arguments

preds

A vector of predicted probabilities.

obs

A vector containing the observed binary outcomes (0 or 1).

Value

'bias' given by

\frac{1}{N} \sum (\frac{1}{N} \sum(\hat y)) - y)^2

'variance' given by

\frac{1}{N} \sum (\frac{1}{N} \sum(\hat y)) - \hat y)^2

Examples

# Generate some predictions
predictions <- runif(1000)
# Generate some binary outcomes
observations <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the bias and variance
bvd(predictions, observations)

gweissman/gmish documentation built on Feb. 21, 2025, 1:20 a.m.