calc_r2 | R Documentation |
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).
calc_r2(model)
model |
A fitted model object. The model must have |
A numeric value representing the R^2
value of the model. Returns NA
if the model is NULL
.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.