This function calculates parametric CIs for the population \(R^2\). It is based on CIs for the non-centrality parameter \(\Delta\) of the F distribution found by test inversion. Values of \(\Delta\) are mapped to \(R^2\) by \(R^2 = \Delta / (\Delta + \textrm{df}_1 + \textrm{df}_2 + 1)\), where the \(\textrm{df}_j\) are the degrees of freedom of the F test statistic. A positive lower \((1 - \alpha) \cdot 100\%\)-confidence limit for the \(R^2\) goes hand-in-hand with a significant F test at level \(\alpha\).
ci_rsquared(x, df1 = NULL, df2 = NULL, probs = c(0.025, 0.975))
The result of stats::lm()
or the F test statistic.
The numerator df. Only used if x
is a test statistic.
The denominator df. Only used if x
is a test statistic.
Lower and upper probabilities, by default c(0.025, 0.975)
.
An object of class "cint", see ci_mean()
for details.
According to stats::pf()
, the results might be unreliable for very large F values.
Note that we do not provide bootstrap CIs here to keep the input interface simple.
Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.
fit <- lm(Sepal.Length ~ ., data = iris)
summary(fit)$r.squared
#> [1] 0.8673123
ci_rsquared(fit)
#>
#> Two-sided 95% F confidence interval for the population R-squared
#>
#> Sample estimate: 0.8673123
#> Confidence interval:
#> 2.5% 97.5%
#> 0.8244916 0.8889573
#>
ci_rsquared(fit, probs = c(0.05, 1))
#>
#> One-sided 95% F confidence interval for the population R-squared
#>
#> Sample estimate: 0.8673123
#> Confidence interval:
#> 5% 100%
#> 0.8312405 1.0000000
#>