ggcorplot() 是否会为具有两个因变量的 lm() 模型创建相关矩阵?

Will ggcorplot() create a correlation matrix for lm() model having two dependent variables?

我使用 vcov() 创建了一个方差-协方差矩阵。我的感觉是 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)

这是我使用的模型:

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)

我想检查协方差,所以我使用 vcov(lm_joined1),它会产生相当大的输出。所以我想可视化矩阵。这是我的尝试:

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"),
  )

这确实打印了一个包含所有变量的矩阵,但每个框都是 zero:

编辑以回应评论

编辑 2:尝试 lm 仅使用完整模型中的重要变量。此外,随着观察的增加,协方差矩阵似乎变得越来越稀疏。这可能是因为你添加的垃圾数据或者你的数据中实际上存在一种现象,即没有协方差结构...

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"),
  )

reprex package (v2.0.1)

于 2022-04-15 创建

编辑:这仍然适用于 50 个 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,.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"),
  )

reprex package (v2.0.1)

于 2022-04-15 创建

这对我有用 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"),
  )

reprex package (v2.0.1)

于 2022-04-15 创建