mc.table: Generate R² Matrix of all Possible Regressions Among...

View source: R/mc.table.R

mc.tableR 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:

  1. x1 ~ x2 + x3 + x4

  2. x1 ~ x3 + x4

  3. x1 ~ x2 + x4

  4. x1 ~ x2 + x3

  5. x1 ~ x4

  6. x1 ~ x3

  7. x1 ~ x2

The second column corresponds to the regressions:

  1. x2 ~ x1 + x3 + x4

  2. x2 ~ x3 + x4

  3. x2 ~ x1 + x4

  4. x2 ~ x1 + x3

  5. x2 ~ x4

  6. x2 ~ x3

  7. x2 ~ x1

and so on.

Examples

## Replicate table 21.3 in the textbook
mc.table(data.printer[,-1])


desk documentation built on May 29, 2024, 6:05 a.m.

Related to mc.table in desk...