adjR2.lm: Adjusted R-squared in Normal Linear Models

View source: R/glms.R

adjR2.lmR Documentation

Adjusted R-squared in Normal Linear Models

Description

Extracts the adjusted R-squared in normal linear models.

Usage

## S3 method for class 'lm'
adjR2(..., digits = 4, verbose = TRUE)

Arguments

...

one or several objects of the class lm, which are obtained from the fit of normal linear models.

digits

an (optional) integer value indicating the number of decimal places to be used. By default, digits is set to be 4.

verbose

an (optional) logical indicating if should the report of results be printed. By default, verbose is set to be TRUE.

Details

The R-squared is computed as R^2=1 - RSS/Null.RSS. Then, the adjusted R-squared is computed as 1 - \frac{n-1}{n-p}(1-R^2), where p is the number of parameters in the linear predictor and n is the sample size.

Value

a matrix with the following columns

RSS value of the residual sum of squares,
R-squared value of the R-squared,
df number of parameters in the linear predictor,
adj.R-squared value of the adjusted R-squared,

Examples

###### Example 1: Fuel efficiency of cars
fit1 <- lm(mpg ~ log(hp) + log(wt) + qsec, data=mtcars)
fit2 <- lm(mpg ~ log(hp) + log(wt) + qsec + log(hp)*log(wt), data=mtcars)
fit3 <- lm(mpg ~ log(hp)*log(wt)*qsec, data=mtcars)

AIC(fit1,fit2,fit3)
BIC(fit1,fit2,fit3)
adjR2(fit1,fit2,fit3)


glmtoolbox documentation built on Oct. 10, 2023, 9:06 a.m.