tmp <- textConnection(
"tv 蠍磯レ 襷るル 碁
1 46 34 28 39
2 60 31 50 46
3 81 59 63 72
4 94 84 92 92
5 76 67 86 52
6 31 53 41 39
7 34 38 25 25
8 78 75 64 76
9 54 43 38 55
10 86 53 60 70
11 53 43 34 42
12 78 31 52 67
13 96 66 77 88
14 71 90 86 65
15 67 58 60 70
16 32 68 74 45
17 44 55 60 42
18 59 46 42 67
19 76 30 37 64
20 84 51 54 79")
x <- read.table(tmp, header=TRUE)
close.connection(tmp)
#head(x)
library("sqldf")
d1 <- sqldf("select , 蠍磯レ from x")
d2 <- sqldf("select 襷るル, 碁 from x")
rs1 <- cancor(d1, d2)
rs1$cor
> X <- with(x, -0.007865095 * (-65.00) + -0.006951716 * (蠍磯レ-53.75))
> Y <- with(x, -0.007865095 * (襷るル-56.15) + -0.006951716 * (碁-59.75))
> cor.test(X,Y)
Pearson's product-moment correlation
data: X and Y
t = 13.0087, df = 18, p-value = 1.362e-10
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8772728 0.9806609
sample estimates:
cor
0.9507151
> plot(X,Y)
#install.packages("CCA")
library("CCA")
rs2 <- cc(d1, d2)
plot(rs2$scores$xscores[,1], rs2$scores$yscores[,1])
3 るジ 覦覯 #
#install.packages("yacca")
library("yacca")
rs3 <- cca(d1, d2)
rs3
> rs3
Canonical Correlation Analysis
Canonical Correlations:
CV 1 CV 2
0.9558493 0.6976745
X Coefficients:
CV 1 CV 2
-0.03428316 0.03920114
蠍磯レ -0.03030183 -0.05234068
Y Coefficients:
CV 1 CV 2
襷るル -0.02577813 -0.05651435
碁 -0.03411328 0.05890991
Structural Correlations (Loadings) - X Vars:
CV 1 CV 2
-0.8654311 0.5010280
蠍磯レ -0.7527465 -0.6583105
Structural Correlations (Loadings) - Y Vars:
CV 1 CV 2
襷るル -0.8653783 -0.5011192
碁 -0.9098212 0.4150005
Aggregate Redundancy Coefficients (Total Variance Explained):
X | Y: 0.7675629
Y | X: 0.823285
> plot(rs3)
伎 企慨覃...
- 1譴蟯覲(CV1) - 覲蠏碁9X 覲蠏碁9Y 豕 蟯 螻 0.96
- 2譴蟯覲(CV2) - 覲蠏碁9X 覲蠏碁9Y 豕 蟯 螻 れ朱 蟯螻 0.7
Canonical Correlations:
CV 1 CV 2
0.9558493 0.6976745
Aggregate Redundancy Coefficients (Total Variance Explained):
X | Y: 0.7675629
Y | X: 0.823285
Structural Correlations (Loadings) - X Vars:
CV 1 CV 2
-0.8654311 0.5010280
蠍磯レ -0.7527465 -0.6583105
Structural Correlations (Loadings) - Y Vars:
CV 1 CV 2
襷るル -0.8653783 -0.5011192
碁 -0.9098212 0.4150005
- 譴(canonical loadings) - 蟆讀 覦覯
- X蠏碁9 覲 , 蠍磯レ炎骸 CV1, CV2 蟯螻
- Y蠏碁9 覲 襷るル, 碁 CV1, CV2 蟯螻
- 谿瑚: 譴蟲谿(canonical cross-loadings, 覲 企 覲蠏碁9 觜蟲蠏碁9 譴蟯覲 蟯蟯螻)朱 蟆 .
X Coefficients:
CV 1 CV 2
-0.03428316 0.03920114
蠍磯レ -0.03030183 -0.05234068
Y Coefficients:
CV 1 CV 2
襷るル -0.02577813 -0.05651435
碁 -0.03411328 0.05890991
譴蟯螻
- CV1
- X = -0.03428316 * + -0.03030183 + 蠍磯レ
- Y = -0.02577813 * 襷るル + -0.03411328 * 碁
- CV2
- X = 0.03920114 * + -0.05234068 + 蠍磯レ
- Y = -0.05651435 * 襷るル + 0.05890991 * 碁
> X <- with(x, -0.03428316 * + -0.03030183 * 蠍磯レ)
> Y <- with(x, -0.02577813 * 襷るル + -0.03411328 * 碁)
> cor.test(X,Y)
Pearson's product-moment correlation
data: X and Y
t = 13.8003, df = 18, p-value = 5.156e-11
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8896248 0.9827032
sample estimates:
cor
0.9558493
企 譴蟯螻蟾讌 碁? (Bartlett's test)
> F.test.cca(rs3)
F Test for Canonical Correlations (Rao's F Approximation)
Corr F Num df Den df Pr(>F)
CV 1 0.95585 30.00045 4.00000 32 2.029e-10 ***
CV 2 0.69767 16.12224 1.00000 17 0.0008971 ***
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1