reg.r.squared: R-squared for lm.fit

Description Usage Arguments Examples

View source: R/reg.r.squared.R

Description

Calculate R-squared for the outcome of lm.fit(). This function is built for reg.linreg for higher efficiency only. It can't be used for calculating R-squared in general operation.

Usage

1
reg.r.squared(SSR,SSTO)

Arguments

SSR

:regression sum of squares or explained of squares

SSTO

:total sum of squares

Examples

1
2
3
4
5
6
7
X <- as.matrix(cbind(1,EuStockMarkets[,1:2])) # create the design matrix
Y <- as.data.frame(EuStockMarkets)$FTSE
fit <- lm.fit(x = X, y = Y)
me <- mean(Y)
SSR <- sum((fit$fitted.values - me)^2)
SSTO <- sum((Y - me)^2)
reg.r.squared(SSR,SSTO)

Example output

[1] 0.9821057

YRmisc documentation built on March 25, 2020, 5:13 p.m.

Related to reg.r.squared in YRmisc...