Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
M M O
M
p1
p2
pp
4.2
21 a22
the determinant for a 33 matrix can be defined as
4.3
a32
a31 a32 a33
for a matrix A.
a23
a21
a21 a 23
a12
a 13
a33
a31
a31 a 33
a22
a
32
0.5 1.25
The determinant of a matrix can be found in PROC IML
using det(sigma) where sigma is the matrix of interest.
4.2 Eigenvalues
Eigenvalues are also known as characteristic roots.
Definition 4.3: Eigenvalues of are the roots of the
polynomial equation defined by I 0 where I is an
identity matrix.
If p=2, then the eigenvalues are the roots of
11
12
11 12 0
21
22
21 22 0
4.4
2
In general, the eigenvalues are the p roots of
c1p + c2p-1 + c3p-2 + + cp + cp+1 = 0 where cj denote
constants.
Since is a symmetric matrix, the eigenvalues are real
numbers and can be ordered from largest to smallest as
1 2 p where 1 is the largest.
Example: Bivariate normal distribution (bi_norm.sas)
2.25 2.252 4(.25 1.25)
4.5
tr( ) i
p
i 1
L
i 1 2
i 1
a1
a
2
4.6
0.7882
0.6154 for 2=0.6096.
0.5
1
0.5 1.25
0.6154
0.6154
1.6404
and
0.7882
0.7882
0.7882
0.7882
0.6096
0.6154
0.6154
4.7
0.7882054 -0.615412
CHECK1_LEFT CHECK1_RIGHT
lambda1
1.0095149
1.0095149
1.2929629
1.2929629
CHECK2_LEFT CHECK2_RIGHT
lambda2
0.4804993
0.4804993
-0.375163
-0.375163
Note:
SAS gives the eigenvector for the largest eigenvalue
first.
These eigenvectors have a length of one.
Positive Definite and Positive Semidefinite Matrices
Definition 4.5: If a symmetric matrix has all of its eigenvalues
positive, the matrix is called a positive definite matrix.
Definition 4.6: If a symmetric matrix has all nonnegative
eigenvalues and if at least one of the eigenvalues is actually
0, then the matrix is called a positive semidefinite matrix.
Definition 4.7: If a matrix is either positive definite or positive
semidefinite, the matrix is defined to be a nonnegative
matrix.
Covariance and correlation matrices are always
nonnegative!
4.8
4.9
0.0
-1.0
-0.5
a2
0.5
1.0
Eigenvectors of
-1.0
-0.5
0.0
0.5
1.0
a1
0.6154
0.7882 for 1=1.6404 and
0.7882
0.6154 for 2=0.6096
4.10
eig$vectors[1,1]
############################################################
# Eigenvector plot
#Square plot (default is m which means maximal region)
par(pty = "s")
#Set up some dummy values for plot
a1<-c(-1,1)
a2<-c(-1,1)
plot(x = a1, y = a2, type = "n", main =
expression(paste("Eigenvectors of ", Sigma)),
xlab = expression(a[1]), , ylab = expression(a[2]) ,
panel.first=grid(col="gray", lty="dotted"))
#Run demo(plotmath) for help on greek letters and other
# characters
#draw line on plot - h specifies a horizontal line, lwd is
# line width
abline(h = 0, lty = 1, lwd = 2)
#v specifies a vertical line
abline(v = 0, lty = 1, lwd = 2)
arrows(x0 = 0, y0 = 0, x1 = 0.6154, y1 = 0.7882, col = 2,
lty = 1)
arrows(x0 = 0, y0 = 0, x1 = 0.7882, y1 = -0.6154, col = 2,
lty = 1)
#Note: the first arrows statement could also have been
# done by:
# arrows(x0 = 0, y0 = 0, x1 = eig$vectors[1,1], y1 =
#
eig$vectors[2,1], col = 2, lty = 1)
4.11
4.12
-10
-5
X2
10
15
20
25
-10
-5
10
15
20
25
X1
mu = [15, 20]', sigma = [(1, 0.5)', (0.5, 1.25)']
Notes:
The eigenvectors for 1 and 2 point in the direction of
the ellipses major and minor axes.
The X1 and X2 axes are switched from the contour plot
shown in Chapter 1.
Below is the R code
library(mvtnorm) #Need for dmvnorm() function
#sequence of numbers from 10-25 by 0.1
4.13
x1<-seq(from = 10, to = 25, by = 0.1)
x2<-seq(from = 10, to = 25, by = 0.1)
#Finds all possible combinations of x1 and x2
all<-expand.grid(x1, x2)
#Finds f(x) - dmvnorm() is in the mvtnorm package
f.x<-dmvnorm(all, mean = mu, sigma = sigma)
#Puts f(x) values in a matrix - need for contour(), but
# not for contourplot()
f.x2<-matrix(f.x, nrow=length(x1), ncol=length(x2))
par(pty = "s")
#The f.x2 values need to be in a matrix. Think of x1 as
# denoting the rows and x2 as denoting the columns
# corresponding to the values of x1 and x2 used to
# produce a f(x) in a cell of the matrix
contour(x = x1, y = x2, z = f.x2, xlim = c(-10,25), ylim =
c(-10,25), levels = c(0.01, 0.001),
xlab = expression(X[1]), ylab = expression(X[2]),
panel.first=grid(col="gray", lty="dotted"),
main = "Contour plot for bivariate normal
distribution \n with eigenvectors plotted",
sub = "mu = [15, 20]', sigma = [(1, 0.5)', (0.5,
1.25)']")
abline(h = 0, lty = 1, lwd = 2)
abline(v = 0, lty = 1, lwd = 2)
#Vector lengths are 10 in order to help see better on the
# plot
arrows(x0 = 0, y0 = 0, x1 = 10*0.6154, y1 = 10*0.7882, col
= 2, lty = 1)
arrows(x0 = 0, y0 = 0, x1 = 10*0.7882, y1 = 10*(-0.6154),
col = 2, lty = 1)
4.14
1
(2)
p/2
1/ 2
1
( x m)S - 1( x m)
4.15
Note:
As 2 goes to 0, the contours become a straight line.
Thus, the data can be viewed in ONE dimension!
4.5 Geometric Descriptions (p=3)
Vectors
Plot 31 vectors in 3-dimensions with each axis
corresponding to a one of the three variable values.
4.16
4.17
4.18