mc.table {desk} | R Documentation |
Generate R² Matrix of all Possible Regressions Among Regressors to Check Multicollinearity
Description
For a given set of regressors this command calculates the coefficient of determination of a regression of one specific regressor on all combinations of the remaining regressors. This provides an overview of potential multicollinearity. Needs at least three variables. For just two regressors the square of cor()
can be used.
Usage
mc.table(x, intercept = TRUE, digits = 3)
Arguments
x |
data frame of variables to be regressed on each other. |
intercept |
logical value specifying whether regression should have an intercept. |
digits |
number of digits to be rounded to. |
Value
Matrix of R-squared values. The column headers indicate the respective endogenous variables that is projected on a combination of exogenous variables. Example: If we have 4 regressors x1, x2, x3, x4, then the fist column of the returned matrix has 7 rows including the R-squared values of the following regressions:
x1 ~ x2 + x3 + x4
x1 ~ x3 + x4
x1 ~ x2 + x4
x1 ~ x2 + x3
x1 ~ x4
x1 ~ x3
x1 ~ x2
The second column corresponds to the regressions:
x2 ~ x1 + x3 + x4
x2 ~ x3 + x4
x2 ~ x1 + x4
x2 ~ x1 + x3
x2 ~ x4
x2 ~ x3
x2 ~ x1
and so on.
Examples
## Replicate table 21.3 in the textbook
mc.table(data.printer[,-1])