Learn R Programming

SignalY (version 1.1.1)

compute_partial_r2: Compute Partial R-squared

Description

Calculates the partial R-squared for a specific predictor or block of predictors, measuring their unique contribution to explaining variance in the outcome after controlling for other predictors.

Usage

compute_partial_r2(y, X_interest, X_control = NULL, weights = NULL)

Value

Numeric scalar representing partial R-squared (0 to 1).

Arguments

y

Numeric vector of the outcome variable.

X_interest

Matrix of predictors of interest.

X_control

Matrix of control predictors. Can be NULL for simple R-squared.

weights

Optional observation weights.

Details

Partial R-squared is computed as: $$R^2_{partial} = (SSE_{reduced} - SSE_{full}) / SSE_{reduced}$$

where SSE is the sum of squared errors. This measures the proportional reduction in unexplained variance achieved by adding the predictors of interest to a model that already contains the control predictors.

References

Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences (3rd ed.). Lawrence Erlbaum Associates. Chapter 3.