calc_r2 {beezdiscounting} | R Documentation |
Calculate R-Squared for a Model
Description
This function calculates the coefficient of determination (R^2
) for a given model by comparing the sum of squared errors (SSE)
to the total sum of squares (SST).
Usage
calc_r2(model)
Arguments
model |
A fitted model object. The model must have |
Value
A numeric value representing the R^2
value of the model. Returns NA
if the model is NULL
.
Examples
# Example using a simple linear model
data <- data.frame(x = 1:10, y = c(1, 2, 3, 4, 5, 6, 7, 9, 10, 11))
lm_model <- lm(y ~ x, data = data)
calc_r2(lm_model)
[Package beezdiscounting version 0.3.2 Index]