Motor Trend Car Road Tests
head(mtcars)
cor(mtcars)
mpg cyl disp hp drat wt qsec vs am gear
mpg 1.0000000 -0.8521620 -0.8475514 -0.7761684 0.68117191 -0.8676594 0.41868403 0.6640389 0.59983243 0.4802848
cyl -0.8521620 1.0000000 0.9020329 0.8324475 -0.69993811 0.7824958 -0.59124207 -0.8108118 -0.52260705 -0.4926866
disp -0.8475514 0.9020329 1.0000000 0.7909486 -0.71021393 0.8879799 -0.43369788 -0.7104159 -0.59122704 -0.5555692
hp -0.7761684 0.8324475 0.7909486 1.0000000 -0.44875912 0.6587479 -0.70822339 -0.7230967 -0.24320426 -0.1257043
drat 0.6811719 -0.6999381 -0.7102139 -0.4487591 1.00000000 -0.7124406 0.09120476 0.4402785 0.71271113 0.6996101
wt -0.8676594 0.7824958 0.8879799 0.6587479 -0.71244065 1.0000000 -0.17471588 -0.5549157 -0.69249526 -0.5832870
qsec 0.4186840 -0.5912421 -0.4336979 -0.7082234 0.09120476 -0.1747159 1.00000000 0.7445354 -0.22986086 -0.2126822
vs 0.6640389 -0.8108118 -0.7104159 -0.7230967 0.44027846 -0.5549157 0.74453544 1.0000000 0.16834512 0.2060233
am 0.5998324 -0.5226070 -0.5912270 -0.2432043 0.71271113 -0.6924953 -0.22986086 0.1683451 1.00000000 0.7940588
gear 0.4802848 -0.4926866 -0.5555692 -0.1257043 0.69961013 -0.5832870 -0.21268223 0.2060233 0.79405876 1.0000000
carb -0.5509251 0.5269883 0.3949769 0.7498125 -0.09078980 0.4276059 -0.65624923 -0.5696071 0.05753435 0.2740728
carb
mpg -0.55092507
cyl 0.52698829
disp 0.39497686
hp 0.74981247
drat -0.09078980
wt 0.42760594
qsec -0.65624923
vs -0.56960714
am 0.05753435
gear 0.27407284
carb 1.00000000
library(corrplot)
corrplot 0.92 loaded
corrplot(cor(mtcars), method="color")
library(corrplot)
corrplot(cor(mtcars), method="number")
library(corrplot)
corrplot(cor(mtcars), method="pie")
library(corrplot)
corrplot(cor(mtcars), method="circle")
corrplot.mixed(cor(mtcars))
corrplot(cor(mtcars), order="hclust")
mtcarsCorMtest <- cor.mtest(mtcars, conf.level = .95)
mtcarsCorMtest
$p
mpg cyl disp hp drat wt qsec vs am
mpg 0.000000e+00 6.112687e-10 9.380327e-10 1.787835e-07 1.776240e-05 1.293959e-10 1.708199e-02 3.415937e-05 2.850207e-04
cyl 6.112687e-10 0.000000e+00 1.802838e-12 3.477861e-09 8.244636e-06 1.217567e-07 3.660533e-04 1.843018e-08 2.151207e-03
disp 9.380327e-10 1.802838e-12 0.000000e+00 7.142679e-08 5.282022e-06 1.222320e-11 1.314404e-02 5.235012e-06 3.662114e-04
hp 1.787835e-07 3.477861e-09 7.142679e-08 0.000000e+00 9.988772e-03 4.145827e-05 5.766253e-06 2.940896e-06 1.798309e-01
drat 1.776240e-05 8.244636e-06 5.282022e-06 9.988772e-03 0.000000e+00 4.784260e-06 6.195826e-01 1.167553e-02 4.726790e-06
wt 1.293959e-10 1.217567e-07 1.222320e-11 4.145827e-05 4.784260e-06 0.000000e+00 3.388683e-01 9.798492e-04 1.125440e-05
qsec 1.708199e-02 3.660533e-04 1.314404e-02 5.766253e-06 6.195826e-01 3.388683e-01 0.000000e+00 1.029669e-06 2.056621e-01
vs 3.415937e-05 1.843018e-08 5.235012e-06 2.940896e-06 1.167553e-02 9.798492e-04 1.029669e-06 0.000000e+00 3.570439e-01
am 2.850207e-04 2.151207e-03 3.662114e-04 1.798309e-01 4.726790e-06 1.125440e-05 2.056621e-01 3.570439e-01 0.000000e+00
gear 5.400948e-03 4.173297e-03 9.635921e-04 4.930119e-01 8.360110e-06 4.586601e-04 2.425344e-01 2.579439e-01 5.834043e-08
carb 1.084446e-03 1.942340e-03 2.526789e-02 7.827810e-07 6.211834e-01 1.463861e-02 4.536949e-05 6.670496e-04 7.544526e-01
gear carb
mpg 5.400948e-03 1.084446e-03
cyl 4.173297e-03 1.942340e-03
disp 9.635921e-04 2.526789e-02
hp 4.930119e-01 7.827810e-07
drat 8.360110e-06 6.211834e-01
wt 4.586601e-04 1.463861e-02
qsec 2.425344e-01 4.536949e-05
vs 2.579439e-01 6.670496e-04
am 5.834043e-08 7.544526e-01
gear 0.000000e+00 1.290291e-01
carb 1.290291e-01 0.000000e+00
$lowCI
mpg cyl disp hp drat wt qsec vs am gear
mpg 1.00000000 -0.9257694 -0.92335937 -0.8852686 0.4360484 -0.93382641 0.08195487 0.4103630 0.3175583 0.15806177
cyl -0.92576936 1.0000000 0.80724418 0.6816016 -0.8429083 0.59657947 -0.77927809 -0.9039393 -0.7369979 -0.71802597
disp -0.92335937 0.8072442 1.00000000 0.6106794 -0.8487237 0.78115863 -0.67961513 -0.8488377 -0.7792690 -0.75751468
hp -0.88526861 0.6816016 0.61067938 1.0000000 -0.6895522 0.40251134 -0.84759984 -0.8559675 -0.5456270 -0.45447743
drat 0.43604838 -0.8429083 -0.84872374 -0.6895522 1.0000000 -0.84997951 -0.26594700 0.1081948 0.4843991 0.46414402
wt -0.93382641 0.5965795 0.78115863 0.4025113 -0.8499795 1.00000000 -0.49335358 -0.7571117 -0.8386752 -0.77446381
qsec 0.08195487 -0.7792781 -0.67961513 -0.8475998 -0.2659470 -0.49335358 1.00000000 0.5346428 -0.5356240 -0.52261830
vs 0.41036301 -0.9039393 -0.84883771 -0.8559675 0.1081948 -0.75711174 0.53464277 1.0000000 -0.1915957 -0.15371324
am 0.31755830 -0.7369979 -0.77926901 -0.5456270 0.4843991 -0.83867523 -0.53562398 -0.1915957 1.0000000 0.61589632
gear 0.15806177 -0.7180260 -0.75751468 -0.4544774 0.4641440 -0.77446381 -0.52261830 -0.1537132 0.6158963 1.00000000
carb -0.75464796 0.2184331 0.05367539 0.5431200 -0.4259976 0.09273981 -0.81780480 -0.7661329 -0.2971204 -0.08250603
carb
mpg -0.75464796
cyl 0.21843307
disp 0.05367539
hp 0.54311998
drat -0.42599760
wt 0.09273981
qsec -0.81780480
vs -0.76613289
am -0.29712041
gear -0.08250603
carb 1.00000000
$uppCI
mpg cyl disp hp drat wt qsec vs am gear
mpg 1.0000000 -0.7163171 -0.7081376 -0.5860994 0.8322010 -0.7440872 0.6696186 0.8223262 0.7844520 0.7100628
cyl -0.7163171 1.0000000 0.9514607 0.9154223 -0.4646481 0.8887052 -0.3055388 -0.6442689 -0.2126675 -0.1738615
disp -0.7081376 0.9514607 1.0000000 0.8932775 -0.4805193 0.9442902 -0.1001493 -0.4808327 -0.3055178 -0.2565810
hp -0.5860994 0.9154223 0.8932775 1.0000000 -0.1186280 0.8192573 -0.4774331 -0.5006318 0.1152646 0.2332119
drat 0.8322010 -0.4646481 -0.4805193 -0.1186280 1.0000000 -0.4839784 0.4263400 0.6839680 0.8501319 0.8427222
wt -0.7440872 0.8887052 0.9442902 0.8192573 -0.4839784 1.0000000 0.1852649 -0.2556982 -0.4532461 -0.2944887
qsec 0.6696186 -0.3055388 -0.1001493 -0.4774331 0.4263400 0.1852649 1.0000000 0.8679076 0.1291876 0.1469065
vs 0.8223262 -0.6442689 -0.4808327 -0.5006318 0.6839680 -0.2556982 0.8679076 1.0000000 0.4883712 0.5175379
am 0.7844520 -0.2126675 -0.3055178 0.1152646 0.8501319 -0.4532461 0.1291876 0.4883712 1.0000000 0.8949546
gear 0.7100628 -0.1738615 -0.2565810 0.2332119 0.8427222 -0.2944887 0.1469065 0.5175379 0.8949546 1.0000000
carb -0.2503183 0.7397479 0.6536467 0.8708249 0.2663358 0.6755700 -0.3988165 -0.2756654 0.3982389 0.5684422
carb
mpg -0.2503183
cyl 0.7397479
disp 0.6536467
hp 0.8708249
drat 0.2663358
wt 0.6755700
qsec -0.3988165
vs -0.2756654
am 0.3982389
gear 0.5684422
carb 1.0000000
corrplot(
cor(mtcars),
p.mat = mtcarsCorMtest$p,
sig.level = .05,
order = "hclust",
addrect = 3
)
Pearson’s product-moment correlation
cor.test(
mtcars$mpg,
mtcars$wt,
alternative = "two.sided",
method = "pearson",
conf.level = 0.95
)
Pearson's product-moment correlation
data: mtcars$mpg and mtcars$wt
t = -9.559, df = 30, p-value = 1.294e-10
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.9338264 -0.7440872
sample estimates:
cor
-0.8676594
Kendall’s rank correlation
cor.test(
mtcars$mpg,
mtcars$wt,
alternative = "greater",
method = "kendall",
conf.level = 0.9,
exact = FALSE
)
Kendall's rank correlation tau
data: mtcars$mpg and mtcars$wt
z = -5.7981, p-value = 1
alternative hypothesis: true tau is greater than 0
sample estimates:
tau
-0.7278321
Spearman’s rank correlation
cor.test(
mtcars$mpg,
mtcars$wt,
alternative = "less",
method = "spearman",
conf.level = 0.8,
exact = FALSE
)
Spearman's rank correlation rho
data: mtcars$mpg and mtcars$wt
S = 10292, p-value = 7.438e-12
alternative hypothesis: true rho is less than 0
sample estimates:
rho
-0.886422
LS0tCnRpdGxlOiAiQ29ycmVsYXRpb24gQW5hbHlzaXMiCm91dHB1dDoKICBodG1sX25vdGVib29rOgogICAgY29kZV9mb2xkaW5nOiBzaG93CiAgICBmaWdfY2FwdGlvbjogeWVzCiAgICB0aGVtZTogdW5pdGVkCiAgICB0b2M6IHllcwotLS0KCiMjIE1vdG9yIFRyZW5kIENhciBSb2FkIFRlc3RzCgpgYGB7cn0KaGVhZChtdGNhcnMpCmBgYAoKYGBge3J9CmNvcihtdGNhcnMpCmBgYAoKYGBge3J9CmxpYnJhcnkoY29ycnBsb3QpCmNvcnJwbG90KGNvcihtdGNhcnMpLCBtZXRob2Q9ImNvbG9yIikKYGBgCgpgYGB7cn0KbGlicmFyeShjb3JycGxvdCkKY29ycnBsb3QoY29yKG10Y2FycyksIG1ldGhvZD0ibnVtYmVyIikKYGBgCgpgYGB7cn0KbGlicmFyeShjb3JycGxvdCkKY29ycnBsb3QoY29yKG10Y2FycyksIG1ldGhvZD0icGllIikKYGBgCgpgYGB7cn0KbGlicmFyeShjb3JycGxvdCkKY29ycnBsb3QoY29yKG10Y2FycyksIG1ldGhvZD0iY2lyY2xlIikKYGBgCgpgYGB7cn0KY29ycnBsb3QubWl4ZWQ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