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

Description Usage Arguments Examples

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

Description

Calculate Adjusted 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 Adjusted R-squared in general operation.

Usage

1

Arguments

r

:R-squared for regression

n

:number of observations aka. sample size

p

:number of explanatory variables in the model

Examples

1
2
3
4
5
6
7
8
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)
SSR <- sum((fit$fitted.values - mean(Y))^2)
SSTO <- sum((Y - mean(Y))^2)
r <- reg.r.squared(SSR,SSTO)
n <- dim(X)[1]; p <- dim(X)[2]
reg.adj.r.squared(r,n,p)

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