螻給(Covariance)
- 螻給一 螳 覲 ク谿 螻
- 覲螳 蟯蟯螻襯 覲願鍵 覿 覦覯, るジ 覦覯朱 蟯覿(Correlation) .
- 螻給 > 0 蟆曙: X螳 貉れ Y螳 貉れ蟇磯, X螳 讌 Y螳 讌 蟆曙
- 螻給 < 0 蟆曙: X螳 貉れ Y螳 讌蟇磯, X螳 讌 Y螳 貉れ 蟆曙
- 螻給 = 0 蟆曙: X Y螳 蠏豺煙 蟇磯 覲螳 螻 螳 螳讌 蟆曙
- 豸′ 磯 螳 殊覩襦 蟯蟯螻 襯 願鍵 覿.
- 蟯螻 蟯螻 , -1 <= 蟯螻 <= 1
- 蟯螻 = 螻給(X,Y) / 譴ク谿(X) * 譴ク谿(Y)
螻給壱
- 襷蠏碁襦 螻給一 企.
- cov.wt 襯 伎
- 蟆郁骸
- $cov 螻給壱
- $center 螳 伎 蠏
- $n.obs
- $cor 蟯螻
> cost.d <-read.table("cost.d", header=T)
> cov.wt(cost.d, cor=T)
$cov
fuel repair capital
fuel 23.013361 12.366395 2.906609
repair 12.366395 17.544111 4.773082
capital 2.906609 4.773082 13.963334
$center
fuel repair capital
12.218611 8.112500 9.590278
$n.obs
[1] 36
$cor
fuel repair capital
fuel 1.0000000 0.6154424 0.1621444
repair 0.6154424 1.0000000 0.3049570
capital 0.1621444 0.3049570 1.0000000
> set.seed(2)
> library(mvtnorm)
> x <- rmvnorm(20, sigma=matrix(c(1, 0.98, 0.98, 1), 2))
> x
[,1] [,2]
[1,] 0.62872170 1.05125106
[2,] -0.61625134 -0.81208810
[3,] 2.23543105 2.23568460
[4,] 0.36178518 0.79807392
[5,] -0.05901189 -0.04696427
[6,] -1.44903706 -1.81448776
[7,] 0.85017069 0.81754232
[8,] -0.56312456 -0.61359221
[9,] 2.03787185 1.86925931
[10,] 0.07583804 0.13642630
[11,] 0.79101426 0.83645122
[12,] 0.96199934 0.86826634
[13,] 0.37699900 0.58472713
[14,] -0.98481735 -0.87797193
[15,] 0.88841158 0.52652788
[16,] -2.16636324 -1.92376783
[17,] -0.41200937 -0.78035322
[18,] -0.54347793 -0.67618649
[19,] 0.43040268 0.20810378
[20,] 0.17868536 0.08269170
> plot(x[,1], x[,2], xlab="X1", ylab="X2")