calcr2: Coefficient of Determination

Description Usage Arguments Value Examples

View source: R/calcr2.R

Description

Calculate the unadjusted and adjusted coefficient of determination (R^2).

Usage

1
calcr2(fitted, observed, nparam)

Arguments

fitted

A vector of fitted values.

observed

A vector of observed values.

nparam

A scalar, number of parameters in the fitted model.

Value

A vector of unadjusted and adjusted coefficients of determination.

Examples

1
2
3
4
5
fit1 <- lm(mpg ~ cyl + disp, data=mtcars)
calcr2(fit1$fitted, mtcars$mpg, 3)

fit2 <- lm(mpg ~ cyl + disp + wt, data=mtcars)
calcr2(fit2$fitted, mtcars$mpg, 4)

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.