# Relation between R2 and the covariate correlation matrix (multidimensional case)

Following the post :

Relation between $R^2$ and the covariate correlation matrix

Does it exist a formula for N>3 when N is the number of covariates ?

Many thanks

Take the correlation matrix of all your variables (y is just a column with the other x variables) and find the inverse matrix. Then take 1 minus the reciprocal of the diagonal elements of that matrix ($$1 - \frac{1}{x_{ii}}$$), those values are the $$R^2$$ values for each of the variables as y, with all the others as predictors, so the one corresponding to your y variable is the $$R^2$$ you are looking for.

Here is a quick example in R:

> tmp <- as.matrix(iris[,1:4])
> tmp2 <- solve(cor(tmp))
> 1-1/diag(tmp2)
Sepal.Length  Sepal.Width Petal.Length  Petal.Width
0.8586117    0.5240071    0.9680118    0.9378503
> summary(lm(Sepal.Length ~ Sepal.Width+Petal.Length+Petal.Width, data=iris))

Call:
lm(formula = Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width,
data = iris)

Residuals:
Min       1Q   Median       3Q      Max
-0.82816 -0.21989  0.01875  0.19709  0.84570

Coefficients:
Estimate Std. Error t value         Pr(>|t|)
(Intercept)   1.85600    0.25078   7.401 0.00000000000985 ***
Sepal.Width   0.65084    0.06665   9.765          < 2e-16 ***
Petal.Length  0.70913    0.05672  12.502          < 2e-16 ***
Petal.Width  -0.55648    0.12755  -4.363 0.00002412875686 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3145 on 146 degrees of freedom
Multiple R-squared:  0.8586,    Adjusted R-squared:  0.8557
F-statistic: 295.5 on 3 and 146 DF,  p-value: < 2.2e-16


Notice that 0.8586 in the regression output matches the first value in the vector.

You can use this in matrix notation, or you could use the rules for matrix algebra to find the formula for any $$N$$.

In fact, I found this is called the Multiple correlation.

http://en.wikipedia.org/wiki/Multiple_correlation

Hope it helps

• The multiple correlation is $R$, if you square it you get $R^2$. – Jeremy Miles Feb 26 '15 at 22:19