coef_det: Coefficient of determination.

View source: R/misc_functions.R

coef_detR Documentation

Coefficient of determination.

Description

coef_det estimates the coefficient of determination (r-squared) from fitted (predicted) and observed values. Outcome from the model is assumed to be numerical.

Usage

coef_det(obs, fit)

Arguments

obs

Vector with observed values (numerical outcome).

fit

Vector with fitted (predicted) values.

Value

A scalar, the coefficient of determination (r-squared).

Examples

## 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)

pubh documentation built on Oct. 8, 2024, 9:08 a.m.