check_non_linear_correlations
Source:R/check-non-linear-correlations.R
check_non_linear_correlations.Rdgenerates a correlation matrix among all columns of a data.frame
Details
The function uses gam to estimate a correlation coefficient among continuous variables (continuous~s(continuous), lm to approximate the correlation coefficient between a continuous variable (as response) and a factor variable (as a predictor) through the call lm(continuous~factor), and nnet to approximate the correlation for factor variables as responses using a multinomial model fit through a call to multinom(factor~factor) or (factor~continuous).
Missing values are handled pairwise: each pair of predictors is evaluated on the rows for which both are present, including the intercept-only model the factor-response estimates are scaled by.
Note
The resulting "correlation" matrix is asymmetric as the row variable is used as the "response" and the column variable is used as the "predictor". The use of gam may be slightly oversensitive for continuous-continuous correlations and users may wish to increase cov.cutoff. Inspect individual relationships manually. Values are only approximate "correlations" and are in fact the sqrt of the R-square values reported for each of the fitted relationships. Note that the function assumes a gaussian distribution for continuous response variables. Substantial deviations from this assumption will yield spurious "correlation" estimates.