Docsity

STAT 530/J530: Finding Principal Components with Maximum Variance - Prof. B. Habing, Study notes of Statistics

Toggle sidebar
bg1
1
STAT 530/J530 B.Habing Univ. of S.C. 1
STAT 530/J530
September 15th, 2005
Instructor: Brian Habing
Department of Statistics
LeConte 203
Telephone: 803-777-3578
STAT 530/J530 B.Habing Univ. of S.C. 2
3-D Example
PROC IML;
sigma = {1 .2 2,
.2 1 2,
2 2 10};
mu = {0 0 0};
n = 1000;
seed = 91505;
q=NROW(sigma);
MUMAT=REPEAT(mu,n,1);
SROOT=ROOT(sigma);
Z=NORMAL(REPEAT(seed,n,q));
x=Z*SROOT+MUMAT;
CREATE mvnormdata FROM x;
APPEND FROM x;
QUIT;
STAT 530/J530 B.Habing Univ. of S.C. 3
Goal
Find the coefficients (a’s) of the x’s so
that:
Y=a1X1+a2X2+···+aqXq
has the largest possible variance subject
to the condition that the length of the
coefficient vector is 1.
pf3
pf4

Partial preview of the text

Download STAT 530/J530: Finding Principal Components with Maximum Variance - Prof. B. Habing and more Study notes Statistics in PDF only on Docsity!

STAT 530/J530 B.Habing Univ. of S.C. (^1)

STAT 530/J

September 15 th^ , 2005

Instructor: Brian Habing Department of Statistics LeConte 203 Telephone: 803-777- E-mail: [email protected]

STAT 530/J530 B.Habing Univ. of S.C. (^2)

3-D Example

PROC IML; sigma = {1 .2 2, .2 1 2, 2 2 10}; mu = {0 0 0}; n = 1000; seed = 91505; q=NROW(sigma); MUMAT=REPEAT(mu,n,1); SROOT=ROOT(sigma); Z=NORMAL(REPEAT(seed,n,q)); x=ZSROOT+MUMAT; CREATE mvnormdata FROM x; APPEND FROM x; QUIT;*

STAT 530/J530 B.Habing Univ. of S.C. (^3)

Goal

Find the coefficients (a’s) of the x’s so that:

Y=a 1 X 1 +a 2 X 2 +···+a (^) q Xq

has the largest possible variance subject to the condition that the length of the coefficient vector is 1.

STAT 530/J530 B.Habing Univ. of S.C. (^4)

Example Cont.

library(MASS) mu<-c(5,0,-1) sigma<- matrix(c(1,0.2,2,0.2,1,2,2,2,10), ncol=3,byrow=T) x<-mvrnorm(n=1000,mu,sigma)

coef<-princomp(x,cor=F)$loadings[,1]

pc1<-princomp(x,cor=F)$scores[,1]

STAT 530/J530 B.Habing Univ. of S.C. (^5)

Example Cont.

We should be able to check that the values are correct using the formula before… so we get:

pc1[1]

x[1,1]coef[1] +x[1,2]coef[2] +x[1,3]coef[3]***

Are they all off?!?

STAT 530/J530 B.Habing Univ. of S.C. (^6)

Some Matrix Background

The dot product of two vectors a and b is a 1 b 1 +a 2 b 2 +···+a (^) qb (^) q

In vector notation this is:

It relates to distance by:

It relates to orthogonality by:

STAT 530/J530 B.Habing Univ. of S.C. (^10)

Example Cont.

eigen(cov(x))$vectors princomp(x,cor=F)$loadings

eigen(cov(x))$values round(var(princomp(x,cor=F)$scores),2)

STAT 530/J530 B.Habing Univ. of S.C. (^11)

Scree Plot

plot(princomp(x,cor=F))

STAT 530/J530 B.Habing Univ. of S.C. (^12)

Oildata

plot(princomp(x,cor=F))