r2: Compute (delta) squared multiple correlation coefficients...

View source: R/r2.R

r2R Documentation

Compute (delta) squared multiple correlation coefficients with variances

Description

These functions compute squared multiple correlation coefficients (i.e., proportions of explained variance) R^2 for (a set of) covariates based on (un)conditional variances and differences \Delta between the R^2 values of two nested covariate models A and B (where the covariates in model B represent a subset of the covariates in model A), as well as corresponding large-sample variances implementing the formulas given in Hedges & Hedberg (2013) and Alf & Graf (1999), respectively.

  • r2() computes R^2 and its variance (Hedges & Hedberg, 2013, p. 451).

  • r2.delta() computes \Delta R^2 and its variance (Alf & Graf, 1999, Equations (19) and (21)).

Usage

r2(var, var_adj, N = NULL, trunc = c("zero", "na", "none"))

r2.delta(
  r2_full,
  r2_reduced,
  N = NULL,
  trunc = c("zero", "na", "none"),
  var_delta0 = FALSE
)

Arguments

var

A numeric vector of the unconditional (i.e., unadjusted) variance.

var_adj

A numeric vector of the conditional (i.e., covariate-adjusted) variance.

N

Optional. A numeric vector of the sample size. Necessary for computing the variance.

trunc

A string determining the treatment of negative (\Delta)R^2 values. The default is "zero".

  • "zero": Negative values are truncated to zero.

  • "na": Negative values are set to NA.

  • "none": Negative values are kept. Note that no variances are computed for negative (\Delta)R^2 values.

r2_full

A numeric vector of R^2 for a model A with a set of covariates.

r2_reduced

A numeric vector of R^2 for a model B with a subset of the covariates from model A.

var_delta0

A logical indicating whether variances of zero \Delta R^2 should be computed. The default is FALSE.

Details

Squared multiple correlation coefficients

Covariates that are correlated with (or, put differently: explain variance in) an outcome reduce error variance. R^2 quantifies the proportion of the total variance in an outcome that can be explained by one or more covariates. Formally, R^2 is the ratio of the difference between the unconditional variance and the on covariates C conditional variance to the unconditional variance ((\sigma^2-\sigma^2_{|C})/\sigma^2).

Multilevel designs

In multilevel models, covariates may act at either hierarchical level. Generally, group-mean centering of within-cluster covariates is recommended to ensure that covariates explain variance exclusively at that hierarchical level at which they are specified (e.g., Konstantopoulos, 2012). Consider, for example, a three-level design, where students at L1 are nested within classrooms at L2, which are in turn nested within schools at L3. Given (a set of) classroom-mean centered L1 covariates C_{L1}, R^2_{L1} is the ratio of the difference between the unconditional and the conditional between-student-within-classroom variances to the unconditional between-student-within-classroom variance located at L1 ((\sigma^2_{L1}-\sigma^2_{L1|C_{L1}})/\sigma^2_{L1}); given (a set of) school-mean centered L2 covariates C_{L2}, R^2_{L2} is the ratio of the difference between the unconditional and the conditional between-classroom-within-school variances to the unconditional between-classroom-within-school variance located at L2 ((\sigma^2_{L2}-\sigma^2_{L2|C_{L2}})/\sigma^2_{L2}); and finally, given (a set of) L3 covariates C_{L3}, R^2_{L3} is the ratio of the difference between the unconditional and the conditional between-school variances to the unconditional between-school variance located at L3 ((\sigma^2_{L3}-\sigma^2_{L3|C_{L3}})/\sigma^2_{L3}).

Delta squared multiple correlation coefficients

\Delta R^2 quantifies the increment in the proportion of explained variance when adding covariates to a model. Formally, \Delta R^2 is the difference between the R^2 of a full model A with a certain set of covariates and the R^2 of a reduced model B with a subset of those covariates that are included in model A (R^2_A-R^2_B).

Value

A matrix that contains:

  • r2()

    • Estimate R^2.

    • Variance Variance of R^2, if N is supplied.

  • r2.delta()

    • Estimate \DeltaR^2.

    • Variance Variance of \DeltaR^2, if N is supplied.

References

Alf, E. F., & Graf, R. G. (1999). Asymptotic confidence limits for the difference between two squared multiple correlations: A simplified approach. Psychological Methods, 4(1), 70–75. https://doi.org/10.1037/1082-989X.4.1.70

Hedges, L. V., & Hedberg, E. C. (2013). Intraclass correlations and covariate outcome correlations for planning two- and three-level cluster-randomized experiments in education. Evaluation Review, 37(6), 445–489. https://doi.org/10.1177/0193841X14529126

Konstantopoulos, S. (2012). The impact of covariates on statistical power in cluster randomized designs: Which level matters more? Multivariate Behavioral Research, 47(3), 392–420. https://doi.org/10.1080/00273171.2012.673898

Examples

# compute R-squared and its sampling variance
r2(var = 3.25, var_adj = 1.75, N = 100, trunc = "zero")

# compute Delta R-squared and its sampling variance
r2.delta(r2_full = .75, r2_reduced = .50, N = 100, trunc = "zero", var_delta0 = FALSE)



sophiestallasch/multides documentation built on Oct. 20, 2024, 5:14 a.m.