r2: R2

Description Usage Arguments Details Value Examples

View source: R/r2.R

Description

Computes the R2 value

Usage

1
r2(pred, truth)

Arguments

pred

a numeric vector of predicted/fitted values

truth

a numeric vector of true/observed values

Details

Uses 2 numeric vectors pred and truth to compute an R2 value

Value

r2-value

Examples

1
2
3
4
5
#using the ISLR::Credit database for this example
truth <- ISLR::Credit$Limit
reg_model <- lm(ISLR::Credit$Limit~ISLR::Credit$Income)
pred <- reg_model$fitted.values
r2(pred, truth)

frankchien/bmi585flc documentation built on Dec. 20, 2021, 8:51 a.m.