rsq: Calculate the R^2 of a model for predicted probabilities...

View source: R/rsq.R

rsqR Documentation

Calculate the R^2 of a model for predicted probabilities against a binary outcome.

Description

Calculate the R^2 of a model for predicted probabilities against a binary outcome.

Usage

rsq(preds, obs)

Arguments

preds

A vector of predicted probabilities.

obs

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

Value

The R^2 value

Examples

# Generate some predictions
predictions <- runif(1000)
# Generate some binary outcomes
observations <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the R^2
rsq(predictions, observations)

gweissman/gmish documentation built on Sept. 3, 2024, 11:39 p.m.