rSquared {NCStats}R Documentation

Extract the coefficient of determination from a linear model object.

Description

Extracts the coefficient of determination (i.e., “r-squared” from a linear model (i.e., lm) object.

Usage

rSquared(x, digits = getOption("digits"), percent = FALSE)

Arguments

x

An object saved from lm.

digits

A number indicating the number of digits to round the returned result to.

percent

A logical indicating if the result should be returned as a percentage (=TRUE) or as a proportion (=FALSE; default).

Details

This is a convenience function for extracting the r.squared part from summary(lm).

Value

Returns a number representing the coefficient of determination as either a proportion or percentage.

Examples

if (require(FSA)) {
data(Mirex)
# Simple linear regression test HA:slope!=0.1
lm1 <- lm(mirex~weight, data=Mirex)
rSquared(lm1)
rSquared(lm1,digits=3)
rSquared(lm1,digits=1,percent=TRUE)
}


[Package NCStats version 0.4.7 Index]