ci_r2: Confidence interval for R^2 (exported helper)

View source: R/ci_r2.R

ci_r2R Documentation

Confidence interval for R^2 (exported helper)

Description

Compute a confidence interval for the coefficient of determination (R^2). This implementation follows MBESS (Ken Kelley) and is exported here to avoid importing many dependencies. It supports cases with random or fixed predictors and can be parameterized via either degrees of freedom or sample size (n) and number of predictors (p/k).

Usage

ci_r2(
  r2 = NULL,
  df1 = NULL,
  df2 = NULL,
  conf_level = 0.95,
  random_predictors = TRUE,
  random_regressors = random_predictors,
  f_value = NULL,
  n = NULL,
  p = NULL,
  k = NULL,
  alpha_lower = NULL,
  alpha_upper = NULL,
  tol = 1e-09
)

Arguments

r2

Numeric. The observed R^2 (may be 'NULL' if 'f_value' is supplied).

df1

Integer. Numerator degrees of freedom from F.

df2

Integer. Denominator degrees of freedom from F.

conf_level

Numeric in (0, 1). Two-sided confidence level for a symmetric confidence interval. Default is '0.95'. Cannot be used with 'alpha_lower' or 'alpha_upper'.

random_predictors

Logical. If 'TRUE' (default), compute limits for random predictors; if 'FALSE', compute limits for fixed predictors.

random_regressors

Logical. Backwards-compatible alias for 'random_predictors'. If supplied, it overrides 'random_predictors'.

f_value

Numeric. The observed F statistic from the study.

n

Integer. Sample size.

p

Integer. Number of predictors.

k

Integer. Alias for 'p' (number of predictors). If supplied along with 'p', they must be equal.

alpha_lower

Numeric. Lower-tail noncoverage probability (cannot be used with 'conf_level').

alpha_upper

Numeric. Upper-tail noncoverage probability (cannot be used with 'conf_level').

tol

Numeric. Tolerance for the iterative method determining critical values. Default is '1e-9'.

Details

If 'n' and 'p' (or 'k') are provided, 'df1' and 'df2' are derived as 'df1 = p' and 'df2 = n - p - 1'. Conversely, if 'df1' and 'df2' are provided, 'n = df1 + df2 + 1' and 'p = df1'.

Value

A named list with the following elements:

lower_conf_limit_r2

The lower confidence limit for R^2.

prob_less_lower

Probability associated with values less than the lower limit.

upper_conf_limit_r2

The upper confidence limit for R^2.

prob_greater_upper

Probability associated with values greater than the upper limit.

References

Kelley, K. (2007). Methods for the behavioral, educational, and social sciences: An R package (MBESS).


MOTE documentation built on Dec. 15, 2025, 9:06 a.m.

Related to ci_r2 in MOTE...