Description Usage Arguments Examples
View source: R/reg.r.squared.R
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.
1 | reg.r.squared(SSR,SSTO)
|
SSR |
:regression sum of squares or explained of squares |
SSTO |
:total sum of squares |
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)
|
[1] 0.9821057
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.