View source: R/misc_functions.R
coef_det | R Documentation |
coef_det
estimates the coefficient of determination (r-squared) from fitted (predicted) and
observed values. Outcome from the model is assumed to be numerical.
coef_det(obs, fit)
obs |
Vector with observed values (numerical outcome). |
fit |
Vector with fitted (predicted) values. |
A scalar, the coefficient of determination (r-squared).
## Linear regression:
Riboflavin <- seq(0, 80, 10)
OD <- 0.0125 * Riboflavin + rnorm(9, 0.6, 0.03)
titration <- data.frame(Riboflavin, OD)
model1 <- lm(OD ~ Riboflavin, data = titration)
summary(model1)
coef_det(titration$OD, fitted(model1))
## Non-linear regression:
library(nlme, quietly = TRUE)
data(Puromycin)
mm.tx <- gnls(rate ~ SSmicmen(conc, Vm, K),
data = Puromycin,
subset = state == "treated"
)
summary(mm.tx)
coef_det(Puromycin$rate[1:12], mm.tx$fitted)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.