Returns a tidy data frame of pairwise correlations for the predefined
variable clusters in the lifecalc dataset. Useful as a quick diagnostic
before fitting multivariate models — high within-cluster correlations
signal multicollinearity that will inflate VIF and destabilise OLS
coefficient estimates.
Arguments
- data
A data frame with the same column names as lifecalc. Defaults to the bundled
lifecalcdataset.
Value
A data frame with columns cluster, var1, var2, and r
(Pearson correlation), sorted by descending |r| within each cluster.
Examples
data(lifecalc)
clusters <- lifecalc_cor_clusters(lifecalc)
head(clusters, 10)
#> cluster var1 var2 r
#> 1 employment EmploymentScore ConsumptionScore 0.8304135
#> 2 education EducationScore LiteracyScore 0.8205925
#> 3 employment EmploymentScore MobilityScore 0.8006234
#> 4 employment EmploymentScore NetworkScore 0.7838297
#> 5 education EducationScore CuriosityScore 0.7290875
#> 6 employment ConsumptionScore MobilityScore 0.7243490
#> 7 health MedicalScore RecoveryScore 0.7163789
#> 8 employment NetworkScore ConsumptionScore 0.7001022
#> 9 employment NetworkScore MobilityScore 0.6956512
#> 10 health MedicalScore SleepScore 0.6955574
# High correlations within the education cluster
subset(clusters, cluster == "education")
#> cluster var1 var2 r
#> 2 education EducationScore LiteracyScore 0.8205925
#> 5 education EducationScore CuriosityScore 0.7290875
#> 11 education EducationScore VerificationScore 0.6778783
#> 14 education LiteracyScore CuriosityScore 0.6279810
#> 15 education LiteracyScore VerificationScore 0.5686698
#> 20 education CuriosityScore VerificationScore 0.5145045