I've created a variance-covariance matrix using vcov()
. My sense is that ggcorrplot
will visualize the matrix, but I can't make it work. I suspect it's because I've got two dependent variables, because all is fine when I do the same with a fit containing only one dependent variable. Where am I going wrong? Here is some data:
training_set_NORM <- data.frame(MD_EARN_WNE_P10 = c(.3094,.2901,.3401,.1311,.2022,.1301,.0872,.1412,.1184,.1296,.5555,.6666,.7777,.8888,.9999,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), ADM_RATE = c(.8177,.8189,.7979,.7734,.5744,.5273,.3197,.4319,.5107,.8827,.5655,.6766,.7677,.8688,.9699,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), UGDS = c(.1026,.4263,.3231,.024,.0116,.0886,.0281,.0141,.0276,.0721,.5755,.6566,.7877,.8788,.9799,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), SAT_AVG = c(.7097,.639,.6865,.4012,.4134,.4231,.3707,.5231,.4853,.5012,.9755,.6966,.7977,.8988,.9899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), TUITIONFEE_OUT = c(.3776,.4907,.5054,.4428,.3325,.3199,.3833,.4315,.3221,.4132,.3755,.3966,.3977,.3988,.3899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), AVGFACSAL = c(.361,.3951,.4204,.1525,.1908,.2242,.1797,.1068,.2517,.2845,.4755,.4966,.4977,.4988,.4899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), PFTFAC = c(.6127,.7398,.8642,.4628,.4176,.6636,.42,1,.6779,1,.5745,.5946,.5973,.5985,.5895,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), RET_FT4_POOLED = c(.8077,.8615,.9,.5043,.5902,.7204,.5879,.7183,.7134,.7182,.9255,.2966,.2977,.2988,.2899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), INEXPFTE = c(.0462,.0577,.0476,.0263,.0314,.0329,.0389,.0382,.0737,.0364,.17255,.1926,.1927,.1928,.1829,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), C100_4_POOLED = c(.2421,.5332,.5318,.1136,.3775,.1823,.1934,.3783,.3122,.2001,.2885,.2986,.2987,.2988,.1889,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), GRAD_DEBT_MDN = c(.537,.586,.538,.583,.704,.568,.674,.704,.608,.561,.0756,.0666,.0967,.0968,.0869,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), COSTT4_A = c(.2136,.2993,.324,.3632,.3994,.1429,.181,.389,.2255,.1699,.4745,.4466,.9447,.8944,.9494,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904), X40.year.NPV = c(.3005,.2631,.3126,.1084,.1789,.1221,.0835,.1278,.1057,.1257,.9051,.6061,.7071,.8081,.0891,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904)
And here's the model I'm using:
lm_joined1 <- lm(cbind(MD_EARN_WNE_P10, X40.year.NPV) ~ ADM_RATE UGDS SAT_AVG TUITIONFEE_OUT AVGFACSAL PFTFAC RET_FT4_POOLED INEXPFTE C100_4_POOLED, data = training_set_NORM)
I want to check covariance, so I use vcov(lm_joined1)
, which yields a rather large output. So I want to visualize the matrix. Here's my attempt:
cor_matrix3 = vcov(lm_joined1, method='pearson',use='complete.obs')
head(cor_matrix3)
ggcorrplot(cor_matrix3, method = c("square"), type = c("full"),
ggtheme = ggplot2::theme_minimal,
title = "Correlation Matrix: Select Variables", show.legend = TRUE,
legend.title = "Corr", show.diag = FALSE, outline.color = "gray",
hc.order = TRUE, lab = TRUE, lab_col = "black",
lab_size = 2, tl.cex = 10, tl.col = "black", tl.srt = 45, digits = 2)
theme(
legend.key.width = unit(.6, "cm"), #to resize legend
legend.key.height = unit(1.4, "cm"),
)
This does print a matrix with all variables, but every single box is zero
:
CodePudding user response:
Edit 2: Try lm
only with the significant variables from the full model. Also, with increasing observations, the covariance matrix does appear to get sparser. This may be because of the junk data you added or actually a phenomenon in your data, that there is no covariance structure...
library(tidyverse)
library(ggcorrplot)
training_set_NORM <- data.frame(MD_EARN_WNE_P10 = c(.3094,.2901,.3401,.1311,.2022,.1301,.0872,.1412,.1184,.1296,.5555,.6666,.7777,.8888,.9999,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
ADM_RATE = c(.8177,.8189,.7979,.7734,.5744,.5273,.3197,.4319,.5107,.8827,.5655,.6766,.7677,.8688,.9699,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
UGDS = c(.1026,.4263,.3231,.024,.0116,.0886,.0281,.0141,.0276,.0721,.5755,.6566,.7877,.8788,.9799,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
SAT_AVG = c(.7097,.639,.6865,.4012,.4134,.4231,.3707,.5231,.4853,.5012,.9755,.6966,.7977,.8988,.9899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
TUITIONFEE_OUT = c(.3776,.4907,.5054,.4428,.3325,.3199,.3833,.4315,.3221,.4132,.3755,.3966,.3977,.3988,.3899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
AVGFACSAL = c(.361,.3951,.4204,.1525,.1908,.2242,.1797,.1068,.2517,.2845,.4755,.4966,.4977,.4988,.4899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
PFTFAC = c(.6127,.7398,.8642,.4628,.4176,.6636,.42,1,.6779,1,.5745,.5946,.5973,.5985,.5895,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
RET_FT4_POOLED = c(.8077,.8615,.9,.5043,.5902,.7204,.5879,.7183,.7134,.7182,.9255,.2966,.2977,.2988,.2899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
INEXPFTE = c(.0462,.0577,.0476,.0263,.0314,.0329,.0389,.0382,.0737,.0364,.17255,.1926,.1927,.1928,.1829,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
C100_4_POOLED = c(.2421,.5332,.5318,.1136,.3775,.1823,.1934,.3783,.3122,.2001,.2885,.2986,.2987,.2988,.1889,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
GRAD_DEBT_MDN = c(.537,.586,.538,.583,.704,.568,.674,.704,.608,.561,.0756,.0666,.0967,.0968,.0869,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
COSTT4_A = c(.2136,.2993,.324,.3632,.3994,.1429,.181,.389,.2255,.1699,.4745,.4466,.9447,.8944,.9494,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
X40.year.NPV = c(.3005,.2631,.3126,.1084,.1789,.1221,.0835,.1278,.1057,.1257,.9051,.6061,.7071,.8081,.0891,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904))
nrow(training_set_NORM)
#> [1] 50
lm_joined2 <- lm(cbind(MD_EARN_WNE_P10, X40.year.NPV) ~ UGDS SAT_AVG TUITIONFEE_OUT AVGFACSAL RET_FT4_POOLED,
data = training_set_NORM)
cor_matrix3 = vcov(lm_joined2, complete = TRUE, method='pearson',use='complete.obs')
# head(cor_matrix3)
ggcorrplot::ggcorrplot(cor_matrix3, method = c("square"), type = c("full"),
ggtheme = ggplot2::theme_minimal,
title = "Correlation Matrix: Select Variables", show.legend = TRUE,
legend.title = "Corr", show.diag = FALSE, outline.color = "gray",
hc.order = TRUE, lab = TRUE, lab_col = "black",
lab_size = 2, tl.cex = 10, tl.col = "black", tl.srt = 45, digits = 2)
theme(
legend.key.width = unit(.6, "cm"), #to resize legend
legend.key.height = unit(1.4, "cm"),
)
Created on 2022-04-15 by the reprex package (v2.0.1)
Edit: this still works for 50 obs (your data has some extra commas, so copy mine and replace yours).
library(tidyverse)
library(ggcorrplot)
training_set_NORM <- data.frame(MD_EARN_WNE_P10 = c(.3094,.2901,.3401,.1311,.2022,.1301,.0872,.1412,.1184,.1296,.5555,.6666,.7777,.8888,.9999,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
ADM_RATE = c(.8177,.8189,.7979,.7734,.5744,.5273,.3197,.4319,.5107,.8827,.5655,.6766,.7677,.8688,.9699,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
UGDS = c(.1026,.4263,.3231,.024,.0116,.0886,.0281,.0141,.0276,.0721,.5755,.6566,.7877,.8788,.9799,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
SAT_AVG = c(.7097,.639,.6865,.4012,.4134,.4231,.3707,.5231,.4853,.5012,.9755,.6966,.7977,.8988,.9899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
TUITIONFEE_OUT = c(.3776,.4907,.5054,.4428,.3325,.3199,.3833,.4315,.3221,.4132,.3755,.3966,.3977,.3988,.3899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
AVGFACSAL = c(.361,.3951,.4204,.1525,.1908,.2242,.1797,.1068,.2517,.2845,.4755,.4966,.4977,.4988,.4899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
PFTFAC = c(.6127,.7398,.8642,.4628,.4176,.6636,.42,1,.6779,1,.5745,.5946,.5973,.5985,.5895,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
RET_FT4_POOLED = c(.8077,.8615,.9,.5043,.5902,.7204,.5879,.7183,.7134,.7182,.9255,.2966,.2977,.2988,.2899,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
INEXPFTE = c(.0462,.0577,.0476,.0263,.0314,.0329,.0389,.0382,.0737,.0364,.17255,.1926,.1927,.1928,.1829,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
C100_4_POOLED = c(.2421,.5332,.5318,.1136,.3775,.1823,.1934,.3783,.3122,.2001,.2885,.2986,.2987,.2988,.1889,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
GRAD_DEBT_MDN = c(.537,.586,.538,.583,.704,.568,.674,.704,.608,.561,.0756,.0666,.0967,.0968,.0869,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
COSTT4_A = c(.2136,.2993,.324,.3632,.3994,.1429,.181,.389,.2255,.1699,.4745,.4466,.9447,.8944,.9494,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904),
X40.year.NPV = c(.3005,.2631,.3126,.1084,.1789,.1221,.0835,.1278,.1057,.1257,.9051,.6061,.7071,.8081,.0891,.0204,.0305,.0406,.0507,.0608,.0709,.0214,.0315,.0416,.0517,.0618,.0719,.0325,.0426,.0527,.0628,.0729,.0591,.0692,.0793,.0894,.0995,0022,.0033,.0044,.0055,.0066,.0077,.0088,.0099,.0908,.0907,.0906,.0905,.0904))
nrow(training_set_NORM)
#> [1] 50
lm_joined1 <- lm(cbind(MD_EARN_WNE_P10, X40.year.NPV) ~ ADM_RATE UGDS SAT_AVG TUITIONFEE_OUT AVGFACSAL PFTFAC RET_FT4_POOLED INEXPFTE C100_4_POOLED,
data = training_set_NORM)
cor_matrix3 = vcov(lm_joined1, complete = TRUE, method='pearson',use='complete.obs')
# head(cor_matrix3)
ggcorrplot::ggcorrplot(cor_matrix3, method = c("square"), type = c("full"),
ggtheme = ggplot2::theme_minimal,
title = "Correlation Matrix: Select Variables", show.legend = TRUE,
legend.title = "Corr", show.diag = FALSE, outline.color = "gray",
hc.order = TRUE, lab = TRUE, lab_col = "black",
lab_size = 2, tl.cex = 10, tl.col = "black", tl.srt = 45, digits = 2)
theme(
legend.key.width = unit(.6, "cm"), #to resize legend
legend.key.height = unit(1.4, "cm"),
)
Created on 2022-04-15 by the reprex package (v2.0.1)
This works for me for 15 obs:
library(tidyverse)
library(ggcorrplot)
training_set_NORM <- data.frame(MD_EARN_WNE_P10 = c(.3094,.2901,.3401,.1311,.2022,.1301,.0872,.1412,.1184,.1296,.5555,.6666,.7777,.8888,.9999), ADM_RATE = c(.8177,.8189,.7979,.7734,.5744,.5273,.3197,.4319,.5107,.8827,.5655,.6766,.7677,.8688,.9699), UGDS = c(.1026,.4263,.3231,.024,.0116,.0886,.0281,.0141,.0276,.0721,.5755,.6566,.7877,.8788,.9799), SAT_AVG = c(.7097,.639,.6865,.4012,.4134,.4231,.3707,.5231,.4853,.5012,.9755,.6966,.7977,.8988,.9899), TUITIONFEE_OUT = c(.3776,.4907,.5054,.4428,.3325,.3199,.3833,.4315,.3221,.4132,.3755,.3966,.3977,.3988,.3899), AVGFACSAL = c(.361,.3951,.4204,.1525,.1908,.2242,.1797,.1068,.2517,.2845,.4755,.4966,.4977,.4988,.4899), PFTFAC = c(.6127,.7398,.8642,.4628,.4176,.6636,.42,1,.6779,1,.5745,.5946,.5973,.5985,.5895), RET_FT4_POOLED = c(.8077,.8615,.9,.5043,.5902,.7204,.5879,.7183,.7134,.7182,.9255,.2966,.2977,.2988,.2899), INEXPFTE = c(.0462,.0577,.0476,.0263,.0314,.0329,.0389,.0382,.0737,.0364,.17255,.1926,.1927,.1928,.1829), C100_4_POOLED = c(.2421,.5332,.5318,.1136,.3775,.1823,.1934,.3783,.3122,.2001,.2885,.2986,.2987,.2988,.1889), GRAD_DEBT_MDN = c(.537,.586,.538,.583,.704,.568,.674,.704,.608,.561,.0756,.0666,.0967,.0968,.0869), COSTT4_A = c(.2136,.2993,.324,.3632,.3994,.1429,.181,.389,.2255,.1699,.4745,.4466,.9447,.8944,.9494), X40.year.NPV = c(.3005,.2631,.3126,.1084,.1789,.1221,.0835,.1278,.1057,.1257,.9051,.6061,.7071,.8081,.0891))
nrow(training_set_NORM)
#> [1] 15
lm_joined1 <- lm(cbind(MD_EARN_WNE_P10, X40.year.NPV) ~ ADM_RATE UGDS SAT_AVG TUITIONFEE_OUT AVGFACSAL PFTFAC RET_FT4_POOLED INEXPFTE C100_4_POOLED,
data = training_set_NORM)
cor_matrix3 = vcov(lm_joined1, complete = TRUE, method='pearson',use='complete.obs')
# head(cor_matrix3)
ggcorrplot::ggcorrplot(cor_matrix3, method = c("square"), type = c("full"),
ggtheme = ggplot2::theme_minimal,
title = "Correlation Matrix: Select Variables", show.legend = TRUE,
legend.title = "Corr", show.diag = FALSE, outline.color = "gray",
hc.order = TRUE, lab = TRUE, lab_col = "black",
lab_size = 2, tl.cex = 10, tl.col = "black", tl.srt = 45, digits = 2)
theme(
legend.key.width = unit(.6, "cm"), #to resize legend
legend.key.height = unit(1.4, "cm"),
)
Created on 2022-04-15 by the reprex package (v2.0.1)