# Formula for 95% confidence interval for $R^2$

I googled and searched on stats.stackexchange but I cannot find the formula to calculate a 95% confidence interval for an $R^2$ value for a linear regression. Can anyone provide it?

Even better, let's say I had ran the linear regression below in R. How would I calculate a 95% confidence interval for the $R^2$ value using R code.

lm_mtcars <- lm(mpg ~ wt, mtcars)

• Well you know the relationship between the correlation $r$ and $R^2$ is that you are squaring the correlation coefficient to get $R^2$ so why not calculate the confidence interval for $r$ and then square the lower and upper limits of the interval?
– user30490
Oct 1 '15 at 13:22
• @ZERO: that will work in a simple linear regression, that is, with a single predictor and an intercept. It won't work for multiple linear regression with more than one predictor. Oct 1 '15 at 13:25
• @StephanKolassa, very true! I guess I was basing it off of his R code where there is only one regressor but that is a very good point to clarify.
– user30490
Oct 1 '15 at 13:39
• danielsoper.com/statcalc/formulas.aspx?id=28 Jan 28 '17 at 20:09
• You can e.g. use a very small R function github.com/mayer79/R-confidence-intervals-R-squared based on properties of the non-central F-distribution. Aug 16 '17 at 19:50

> library(boot)
summary(lm(mpg~wt,data[indices,]))$r.squared,R=10000) > foo$t0
> quantile(foo$t,c(0.025,0.975)) 2.5% 97.5% 0.6303133 0.8584067  Carpenter & Bithell (2000, Statistics in Medicine) provide a readable introduction to bootstrapping confidence intervals, though not specifically focused on$R^2$. • (+1) It might be of interest that the approximate formula quoted by @Durden, with$n=32$and$k=1$gives the interval$(0.546,0.960)$. It would be almost perfectly correct if we drop the factor of$2$multiplying the SE in that formula! – whuber Aug 16 '17 at 19:57 • May also be worth noting that you can get other types of confidence interval (e.g., BCa) from the bootstrap resampling distribution using boot.ci(). Mar 3 '19 at 21:37 In R, you can make use of the CI.Rsq() function provided by the psychometric package. As for the formula it applies, see Cohen et al. (2003), Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences, p. 88:$SE_{R^{2}} = \sqrt{\frac{4R^{2}(1-R^{2})^{2}(n-k-1)^{2}}{(n^2 - 1)(n+3)}}$Then, the 95% CI is your$R^{2} \pm 2 \cdot SE_{R^{2}}$. • (1)$(1-R^2)$is squared in your reference. (2) It is important to note that "$R^2$" is intended to be the sample value rather than the population value (which clearly is what "$R^2$" refers to in the question, whence the potential for confusion). (3) It is also important that this is only an asymptotic ("large-sample") result, giving "adequate approximations" for "$n-k-1 \gt 60$". (I believe$k+1\$ counts an intercept plus the number of independent variables.) It would be useful to see a worked example supported by simulation, because this interval looks too wide.