_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 螻給郁骸蟯螻

Contents

1 蟆曙誤
2 螻給(Covariance)
3 螻給壱
4 企 襭 蟯螻襯 蠏碁襦 蠍
5 れ蟯螻
6 覿覿蟯螻
7 碁Μ 蠍 (る襯 蠏碁)


1 蟆曙誤 #

  • R蠍磯 る 覿/螳覈,蟾覈蠏/蟲一
  • 一企 一危
  • Windows R [] -> [襴覲蟆] 一危郁 襴襦 覲蟆]

2 螻給(Covariance) #

  • 螻給一 螳 覲 ク谿 螻
  • 覲螳 蟯蟯螻襯 覲願鍵 覿 覦覯, るジ 覦覯朱 蟯覿(Correlation) .
  • 螻給 > 0 蟆曙: X螳 貉れ Y螳 貉れ蟇磯, X螳 讌 Y螳 讌 蟆曙
  • 螻給 < 0 蟆曙: X螳 貉れ Y螳 讌蟇磯, X螳 讌 Y螳 貉れ 蟆曙
  • 螻給 = 0 蟆曙: X Y螳 蠏豺煙 蟇磯 覲螳 螻 螳 螳讌 蟆曙
  • 豸′ 磯 螳 殊覩襦 蟯蟯螻 襯 願鍵 覿.
  • 蟯螻 蟯螻 , -1 <= 蟯螻 <= 1
  • 蟯螻 = 螻給(X,Y) / 譴ク谿(X) * 譴ク谿(Y)

3 螻給壱 #

  • 襷蠏碁襦 螻給一 企.
  • 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

> pairs(cost.d)
pairs.JPG

蟆郁骸 伎 企慨覃..
  • fule(磯觜), repair(襴觜), capital(覲瑚) 覈 蟯蟯螻襯 螳讌.
  • fule螻 repair 蟯螻 0.62
  • fule螻 capital 蟯螻 0.16
  • repair capital 蟯螻 0.35
  • 蠏碁覩襦 fule(磯觜), repair(襴觜)螳 螳 蟯蟯螻螳 り 覲 .
  • 覲危 蟯螻螳 0.8 伎伎伎 覩瑚 り 覲碁り .

#譟郁唄覿 一
#覲瑚 譟郁唄朱 譯殊伎  磯觜(襴暑) 襴觜(覦覲)伎 蟯螻
coplot(repair~fuel|capital, data=cost.d)
coplot.jpg

4 企 襭 蟯螻襯 蠏碁襦 蠍 #

れ X1, X2 覲 蟯螻螳 0.98 蠏碁.
> 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")
rmvnorm01.JPG

5 れ蟯螻 #

  • れ蟯螻 覲螳 るジ 覲(覲蠏碁9)螻殊 蟯螻襯 覩誤. (蟯螻)
  • 0 <= れ蟯螻 <= 1
  • Kshirsagar 1972 襷濠係 譟磯 蠏谿蟆 .

mcc.f<-function(x, var1, var2)
{
	s<-var(x)
	s0<-sqrt(s[var1,var1])
	s0q<-s[var1,var2]
	Sq<-s[var2,var2]
	
	sqrt(s0q%*%solve(Sq)%*%s0q)/s0 
}

れ螻 螳 襯 伎 れ蟯螻襯 蟲 .
cost.d <-read.table("cost.d", header=T)
source("mcc.f")
mcc.f(cost.d, 1, c(2,3))

          [,1]
[1,] 0.6160264

蟆郁骸
  • れ郁螻 0.6160264
  • 讀, fuel螻 (repair, capital) 蟯蟯螻企.
  • solve 蟲 願, %*% 螻煙企.

6 覿覿蟯螻 #

覲 蠏碁9螳 蟯螻. れ 襯 伎.
pcc.f<-function(x,z1,z2,x2)
{
	x<-as.matrix(x)
	s<-var(x)
	s22<-s[x2,x2]

	y1<-x[,z1]-x[,x2]%*%solve(s22)%*%s[z1,x2]
	y2<-x[,z2]-x[,x2]%*%solve(s22)%*%s[z2,x2]
	cor(y1,y2)
}

soil.d <-read.table("soil.d", header=T)
source("pcc.f")
pcc.f(soil.d, 1, 2, c(3,4))

          [,1]
[1,] 0.7475448

蟆郁骸 0.748企. soil.d 焔襭手 .

7 碁Μ 蠍 (る襯 蠏碁) #

企蟆 襾豪.

  • るジ 襭 谿企ゼ 企 伎豺襯 覦蟆
  • 襭螳 蟇磯Μ 讌
  • 襭 蠏碁9

#る襯れ 蠏碁(碁Μ 蠍, 襭螳 蟇磯Μ襯 蟇磯Μ襯 讌 伎)
andrews.f<-function(x,v)
{
 
	n<-nrow(x) 
	p<-ncol(x)
	nv<-length(v)

	x<-as.matrix(x)
	m<-cov.wt(x)$center
	M<-matrix(m*rep(1,n*p),n,p,byrow=T)
	d<-diag(1/sqrt(diag(cov.wt(x)$cov)))

	x<-(x-M)%*%d

	l<-100
	tt<-seq(from=-pi,to=pi,length=l);
	andr.v<-c(rep(1/sqrt(2),l))

	for(i in 1:((p-1)/2)) 
		andr.v<-c(andr.v,sin(i*tt),cos(i*tt))
  
	if( p%%2 == 0 ) 
		andr.v<-andr.v[-( ((p-1)*l+1): p*l )]

	andr.m<-matrix(andr.v,nrow=l,ncol=p)

	y <- andr.m%*%t(x)
	z <- matrix(0,nv*l,2)
	lab<-vector("numeric",nv*l)

 
	plot(rep(tt,n),as.vector(y),type="n",xlab="t",ylab="Andrews plot")
	for(i in 1:nv) {
		lines(tt,y[,v[i]])
		for(j in 1:l ) {
			z[(i-1)*l+j,1]<-tt[j]
			z[(i-1)*l+j,2]<-y[j,v[i]]
			lab[(i-1)*l+j]<-v[i]
		}
	}
	abline(h=0)
	identify(z,labels=lab)
}

andrews.f(cost.d, c(1:36))
andrews.jpg

蠏碁殊 螳 覲朱蟆 殊 螻′ 襷一るゼ 企Ν覃 螳 . 9, 21 るジ 襭 谿企ゼ 覲伎企襦 螳レ煙 . る襯 蠏碁殊 9, 21, 23企 豢覿.
andrews.f(cost.d, c(9, 21, 23))
andrews02.jpg
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

碁レ 蟆 螻 襷 蟆 詞朱る 螻褐 . (蟯危)