Download STAT 530/J530: Homework 3 - Eigenvalues and Eigenvectors - Prof. B. Habing and more Assignments Statistics in PDF only on Docsity!
STAT 530/J530 B.Habing Univ. of S.C. (^1)
STAT 530/J
September 23 rd^ , 2008
Instructor: Brian Habing
Department of Statistics
LeConte 203
Telephone: 803-777-
STAT 530/J530 B.Habing Univ. of S.C. (^2)
Homework 3
sat3.txt contains the educational data
for each state: Part03 is the % of
students taking the SAT in 2003;
Verbal03, Math03, and Total03 are
the state averages for the respective
sections; and Expend01 is the per
pupil educational spending in 2001.
STAT 530/J530 B.Habing Univ. of S.C. (^3)
1) Construct a graphical display to
support the argument that more
money is not associated with higher
test scores.
2) Construct a graphical display to
counter the argument in 1 by also
taking the percentage of student in the
state taking the exam into account.
STAT 530/J530 B.Habing Univ. of S.C. (^4)
3) Considering the three variables
Part03, Total03, and Expend
choose a method of detecting outliers
that seems reasonable to you to
identify any states you think are
outliers and briefly explain your
results.
STAT 530/J530 B.Habing Univ. of S.C. (^5)
Eigenvalues and Eigenvectors
The eigenvectors of the covariance
matrix are exactly the coefficients
for principal components…
And the eigenvalues are the
variances of the new variables!
STAT 530/J530 B.Habing Univ. of S.C. (^6)
Eigenvalues and Eigenvectors?!?
Consider the equation:
(Σ-λΙ)x=
λ is an eigenvalue
x is an eigenvector
We typically make the length of x be 1.
We typically order them from largest λ to
smallest.
STAT 530/J530 B.Habing Univ. of S.C. (^10)
Example Cont.
pc1<-cbind((1/sqrt(2))(ex1[,1]+ex1[,2]), (1/sqrt(2))(-ex1[,1]+ex1[,2])) bvbox(pc1) var(pc1)**
1.533 -0. -0.003 0.
STAT 530/J530 B.Habing Univ. of S.C. (^11)
Example Cont.
STAT 530/J530 B.Habing Univ. of S.C. (^12)
Example Cont.
> cbind(round(ex1,3),round(pc1,3)) [,1] [,2] [,3] [,4] [1,] -0.075 0.686 0.432 0. [2,] -0.792 0.300 -0.348 0. [3,] 1.381 -0.767 0.434 -1. [4,] 1.756 0.890 1.870 -0. [5,] 0.445 1.080 1.078 0. [6,] -0.133 -0.272 -0.286 -0.
STAT 530/J530 B.Habing Univ. of S.C. (^13)
Example Cont.
Could also use these functions…
eigen(cov(ex1))$vectors princomp(ex1,cor=F)$loadings
eigen(cov(ex1))$values round(var(princomp(ex1,cor=F)$scores),2)
princomp(ex1,cor=F)$scores
STAT 530/J530 B.Habing Univ. of S.C. (^14)
Now, Let’s try the oildata…
oildata<-
read.table("http://www.stat.sc
.edu/~habing/courses/data/oild
ata.txt",header=TRUE)
sect3<-
as.matrix(oildata[,12:31])
oilpc<-princomp(sect3,cor=F)
STAT 530/J530 B.Habing Univ. of S.C. (^15)
Now, Let’s try the oildata…
> oilpc$loadings[,1] Q1 Q2 Q3 Q 0.14749703 -0.18642164 -0.24432644 0. Q5 Q6 Q7 Q 0.35633250 -0.17468260 -0.04253903 0. Q9 Q10 Q11 Q 0.25808813 0.29008088 0.01900861 -0. Q13 Q14 Q15 Q -0.24074574 0.07216813 0.38062551 0. Q17 Q18 Q19 Q -0.23470978 -0.23005868 -0.19195023 -0.