r2: Model R2.

View source: R/BAT.R

r2R Documentation

Model R2.

Description

Calculates R2 from the summed squared differences between observed and estimated values.

Usage

r2(obs, est = NULL, param = 0)

Arguments

obs

Either a model or a vector with observed values.

est

A vector with estimated values. Only used if obs is not a model.

param

Number of parameters in the model to calculate the adjusted R2 if > 0. If obs is a model param will be ignored and the number of parameters will be calculated from the model.

Details

Useful for models or functions that do not provide r2 values.

Value

The r2 value.

Examples

obs = c(1,4,5,6)
est = c(0,1,4,7)

#example using values
r2(obs, est)
r2(obs, est, param = 1)

#example using model
mod = lm(obs ~ est)
r2(mod)
summary(mod)$r.squared
r2(mod, param = 1)
summary(mod)$adj.r.squared


BAT documentation built on May 29, 2024, 7:35 a.m.

Related to r2 in BAT...