colindiag: Collinearity Diagnostics

Description Usage Arguments Value Author(s) References Examples

View source: R/colindiag.R

Description

Perform a (multi)collinearity diagnostic of a correlation matrix of predictor variables based several indicators, as shown by Olivoto et al. (2017).

Usage

1
colindiag(.data, group_var = NULL, n = NULL, verbose = TRUE)

Arguments

.data

The data to be analyzed. Must be a symmetric correlation matrix or a dataframe containing the predictor variables and one possible grouping variable.

group_var

A possible factor to group the data. If more than two factors are in the dataset, the extra factor column(s) will be excluded with a message.

n

If a correlation matrix is provided, then n is the number of objects used to compute the correlation coefficients.

verbose

If verbose = TRUE then some results are shown in the console.

Value

The following values are returned. Please, note that if a grouping variable is used, then the results are returned into a list.

cormat

A symmetric Pearson's coefficient correlation matrix between the variables

corlist

A hypothesis testing for each of the correlation coefficients

evalevet

The eigenvalues with associated eigenvectors of the correlation matrix

VIF

The Variance Inflation Factors, being the diagonal elements of the inverse of the correlation matrix.

CN

The Condition Number of the correlation matrix, given by the ratio between the largest and smallest eigenvalue.

det

The determinant of the correlation matrix.

largest_corr

The largest correlation (in absolute value) observed.

smallest_corr

The smallest correlation (in absolute value) observed.

weight_var

The variables with largest eigenvector (largest weight) in the eigenvalue of smallest value, sorted in decreasing order.

Author(s)

Tiago Olivoto [email protected]

References

Olivoto, T., V.Q. Souza, M. Nardino, I.R. Carvalho, M. Ferrari, A.J. Pelegrin, V.J. Szareski, and D. Schmidt. 2017. Multicollinearity in path analysis: a simple method to reduce its effects. Agron. J. 109:131-142. doi:10.2134/agronj2016.04.0196. 10.2134/agronj2016.04.0196.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Using the correlation matrix
cor_iris = cor(iris[,1:4])
n = nrow(iris)
colindiag(cor_iris, n = n, verbose = FALSE)

# Using the pipe operator %>%
library(dplyr)
cor_iris %>% colindiag(n = n, verbose = FALSE)

# Diagnostic by species, storing into an object
col_diag_spec = iris %>% colindiag(group_var = Species)

TiagoOlivoto/WAASB documentation built on April 1, 2019, 10:25 a.m.