Descriptive Statistics and Matrix Algebra
Descriptive Statistics and Matrix Algebra
◎Summation form:
1 n
⊙Sample mean: xi i xij , i=1, 2, …, p.
n j 1
○Sample mean: i x p ( x );
all x i
i i i
xi f i ( xi )dxi , i=1, 2, …, p.
1 n
⊙Sample covariance: sik ( xij xi )( xkj xk ) , i=1, 2, …, p; k=1, 2, …, p.
n j 1
○Sample covariance: sik ( xi i )( xk k ) dxi dxk , i=1, 2,…, p ; k=1, 2, …, p.
sik
(x
j 1
ij xi )( xkj xk )
⊙Sample correlation coefficient: rik , i=1, 2, …, p;
n n
sii skk
(x
j 1
ij xi ) 2
(x
j 1
kj xk ) 2
k=1, 2, …, p.
◎Array form:
x1
x
⊙Sample means: X 2 , μ E ( X )
x p
1
s11 s12 s1 p
s s22 s2 p
⊙Sample variance and covariance: S p ; E ( X )( X )'
21
s p1 sp2 s pp
1 r12 r1 p
r 1 r2 p
⊙Sample correlation: R 21
rp1 rp 2 1
◎Distance concepts
⊙Euclidean distance: d ( P, Q ) ( x1 y1 ) 2 ( x2 y2 ) 2 ... ( x p y p ) 2
( x1 y1 ) 2 ( x2 y2 ) 2 ( x p y p )2
⊙Statistical distance: d ( P, Q ) ...
s11 s22 s pp
⊙If s11=s22=…=spp, then Euclidean distance = Statistical distance.
x p p 1
⊙Transpose operator: X’= [x1, x2,…, xp] 1 p
x1 y1 x1 y1
x y x y
⊙Addition operator: X Y
2 2 2 2
x p y p x p y p
cx1
cx
⊙Multiplication by a scalar c: cX
2
cx p
⊙Length of X : LX x12 x22 ... xn2 ; LX X ' X
⊙Length of cX= c LX c x12 x22 ... xn2 .
X 'Y
⊙ cos( ) . If cos( ) 0 (i.e. X’Y =0), then X and Y are perpendicular.
LX LY
⊙X1, X2, …, Xk are said to be linearly dependent if there exist constants c1, c2,…, ck not all zero,
such that c1X1+ c2X2 +…+ ckXk =0.
X 'Y X 'Y 1
⊙Projection (shadow) of a vector X on a vector Y: Y Y.
Y 'Y LY LY
2
X 'Y X 'Y
⊙Length of projection: LX LX cos( ) .
LY LX LY
◎Some Basics of Matrix Algebra
⊙Matrix product AB
⊙If AB=BA=I, then B is called the inverse of A and is denoted by A-1.
⊙Orthogonal matrices: Q’Q = QQ’ = I or Q’=Q-1.
⊙Let A be a ( k k ) square symmetric matrix:
○A has k pairs of eigenvalues and eigenvectors: 1 , e1 , 2 , e2 ,..., k , ek . The eigenvectors can
be chosen to satisfy: 1= e1’e1 = e2’e2 = … = ek’ek.
○ 1 , 2 ,..., k satisfy A I 0 .
○Spectral decomposition: A = 1e1e1 ' 2e2e2 '... k ek ek ' and Aei i ei .
○If X ' AX 0 , then A is said to be nonnegative definite. If equality holds only for X’= [0,
0, …,0], then A is said to be positive definite.
○If all i 0 for all i, then A is said to be nonnegative definite.
1 0 0
k 0 2 0
○ A i ei ei ' PP' , where P=[e1, e2, …, ek] and .
i 1
0 0 p
k
1
○ A1 P1P ' ei ei ' .
i 1 i
k
○A square-root matrix: A1 / 2 P1 / 2 P' i ei ei ' , which has following properties:
i 1
‧(A1/2)’ =A1/2. (That is A1/2 is symmetric).
‧A1/2 A1/2 =A.
‧(A1/2) -1 = P1 / 2 P' A1/2.
‧A1/2A-1/2= A-1/2A1/2 = I.
‧A-1/2A-1/2 =A-1.
3
○ E (cX 1 ) cE ( X 1 ) c1 .
○ E (aX 1 bX 2 ) cE ( X 1 ) bE ( X 2 ) a1 b2 .
○ Var (cX 1 ) E (cX 1 c1 ) 2 c 2Var ( X 1 ) c 2 11 .
○ Var (aX 1 , bX 2 ) E (aX 1 a1 )(bX 2 b2 ) abCov ( X 1 , X 2 ) ab 12 .
○ Var (aX 1 bX 2 ) E[(aX 1 bX 2 ) (a1 b 2 )]2 E[a ( X 1 1 ) b( X 2 2 )]2 .
E[a 2 ( X 1 1 ) 2 b 2 ( X 2 2 ) 2 2ab ( X 1 1 )( X 2 2 )]
a 2 Var ( X 1 ) b 2 Var ( X 2 ) 2abCov ( X 1 , X 2 ) a 2 11 b 2 22 2ab 12 .
○Z=c’X = c1X1+c2X2+…+cpXp:
‧mean: E(Z) =E(CX)=Cμ
‧variance: Cov(Z)= Cov(CX) = CΣC’.
2 2
1 1
⊙Multivariate Normal Distribution ( N p ( , ) ): f ( X ) e (1 / 2 )( X )' ( X )
( 2 )
1/ 2
p/2
○Constant probability density contour: ( x )' 1 ( x ) c 2 (Surface of an ellipsoid
centered atμ with axes c i ei ).
○If a random vector X having a multivariate normal distribution, the followings hold true:
‧Linear combination of the components of X are normally distributed.
‧All subsets of the components of X have a (multivariate) normal distribution.
‧Zero covariance implies that the corresponding components are independently distributed.
‧The conditional distribution of the components are (multivariate) normal.
4
§ Inferences About a Mean Vector
( x 0 ) 1 n 1 n
◎Univariate: H 0 : 0 ; H1 : 0 t
s/n
, where x x j ; s
n j 1
n 1 j 1
( x j x)2 .
( x 0 ) 2
t 2
n( x 0 )( s ) 1 ( x 0 ) . n ( x 0 )( s ) 1 ( x 0 ) t n21 ( / 2) Reject H0.
s/n
◎Multivariate: H 0 : 0 ; H1 : 0 T 2 n( X 0 )' S 1 ( X 0 ) , where
1 n 1 n
X
n j 1
X j ;S ( X j X )( X j X )' . T2 is called Hotelling’s T2, which is
n 1 j 1
(n 1) p
distributed as Fp ,n p .
(n p)
◎Hotelling’s T2 and Likelihood ratio tests
max L( 0 , )
n/2
⊙Likelihood ratio =
. 2 / n is called Wilk’s lambda.
max L( , ) 0
0
,
1 1 n
where, L( 0 , )
(2 ) np / 2
n/2
exp( ( x j 0 )' 1 ( x j 0 ) (under hypothesis H0)
2 j 1
T 2 1
⊙ (1
2/n
)
(n 1)
◎Generalized likelihood ratio methods
max L( )
0
⊙Under H 0 : , c.
max L( )
max L( )
0
⊙When the sample size n is large, 2 ln 2 ln( ) is approximately, a v2 v 0 .
max L( )
Where v-v0= (dimension of )- (dimension of 0). v=p+p(p+1)/2; v0=0+p(p+1)/2.
◎Confidence Interval
⊙Let X1, X2,…, Xn be a random sample from an Np(μ,Σ) population withΣ positive definite,
then the 100(1-α)% confidence interval:
p ( n 1) p ( n 1)
n ( X 0 )' S 1 ( X 0 ) c 2 Fp ,n p ( ) i c / n i Fp ,n p ( )
(n p) n(n p )
p ( n 1)
At center X, the axes of the confidence ellipsoid are i Fp ,n p ( ) ei
n(n p )
○A numerical example on Page 181.
p ( n 1) s p ( n 1) s
x1 Fp ,n p ( ) 11 1 x 1 Fp ,n p ( ) 11
(n p) n (n p) n
5
p ( n 1) s p ( n 1) s
x2 Fp ,n p ( ) 22 1 x 2 Fp ,n p ( ) 22
(n p) n (n p) n
…
p( n 1) s pp p( n 1) s pp
xp Fp ,n p ( ) 1 x p Fp ,n p ( )
(n p) n (n p) n
⊙Simultaneous confidence interval with the Bonferroni method for multiple comparisons:
p p
P[all li true] = 1- P[at lease one li false] = 1 P[li false ] = 1 (1 P[li true ]) =
i 1 i 1
sii sii
1 (1 2 ... P ) x i t n 1 ( ) Z x i t n 1 ( ) , i=1,2,…,p.
2p n 2p n
p ( n 1)
Conclusion Choose which of Fp ,n p ( ) and t n 1 ( ) is smaller.
n(n p ) 2p
6
§ MANOVA
◎Paired comparisons
⊙Univariate (t-test):
○Dj= x1j – x2j, j=1,2,…,n
D 1 n 1 n
○t
sd / n
, where, D
n j 1
D j , s d
n 1 j 1
( D j D)2 .
⊙Multivariate (T-test):
(n 1) p
○ T 2 n( D )' S d1 ( D ) is distributed as Fp ,n p
(n p)
p ( n 1) sd i
○Simultaneous confidence interval: d i Fp ,n p ( )
(n p) n
sd i
○Bonferroni confidence interval: d i tn 1 ( )
2p n
◎A repeated measures design
⊙A total of q treatments are compared with respect to a single response variable for each of the
objects.
(n 1)( q 1)
○ T 2 n(C X )' (CSC ' ) 1 (C X ) Fq 1, n q 1 ( )
(n q 1)
( n 1)( q 1) C ' SC
○Simultaneous confidence interval: C X Fq 1,n q 1 ( )
( n q 1) n
C ' SC
○Bonferroni confidence interval: C X tn 1 ( )
2(q 1) n
1 2 1 1 0 0 1
1 0 1 0 2
where C is the contrast matrix. Case 1:
3
1
1 q 1 0 0 1 3
2 1 1 1 0 0 0 1
0 1 1 0 0 2
Case 2:
2
3
q q 1 0 0 0 11 3
◎Comparing mean vectors from two populations (both are multivariate normal)
⊙When n1 and n2 are small andΣ1=Σ2.
n1 n2
( x1 j x1 )( x1 j x1 )' ( x2 j x 2 )( x2 j x 2 )'
j 1 j 1 ( n1 1) S1 ( n2 1) S 2
S pooled
n1 n 2 2 n1 n2 2
7
○To test H 0 : 1 2 . E ( X 1 X 2 ) E ( X 1 ) E ( X 2 ) 1 2 ;
1 1 1 1
Cov ( X 1 X 2 ) Cov ( X 1 ) Cov ( X 2 ) ( ) ( ) S pooled
n1 n2 n1 n2
1
1 1
○Likelihood ratio test: T ( X 1 X 2 )' S pooled ( X 1 X 2 )
2
n1 n2
○Simultaneous confidence interval:
( n1 n2 2) p 1 1
l( X 1 X 2 ) Fp ,n1 n2 p 1 ( ) l ' ( ) S pooled l
( n1 n2 p 1) n1 n2
⊙When n1 - p and n2 – p are large andΣ1 Σ2. (Hold true even for the populations not
come from multivariate Normal)
1
1 1
○Likelihood ratio test: T ( X 1 X 2 )' S1 S 2 ( X 1 X 2 ) p2 ( )
2
n1 n2
l 1 j 1 l 1 l 1 j 1
( xlj x ) 2 nl ( x l x ) 2 ( xlj x l ) 2
l 1 j 1 l 1 l 1 j 1
Residual (error) g nl g
SS res ( xlj x l ) 2 n
l 1
l g
l 1 j 1
SS tr
g 1
○F as Fg 1, ( )
SS res nl g
n l g
8
⊙One-way MANOVA:
Source of variation Sum of squares (SS) Degrees of freedom
Treatment g g 1
B nl ( x l x )( xi x )'
l 1
Residual (error) g nl g
W ( xlj x l )( xlj x l )' n
l 1
l g
l 1 j 1
W
○Wilks’ lambda: *
B W
○Distribution of Wilk s’ lambda:
No. of No. of Sampling distribution for multivariate normal data
variables groups
p=1 g>=2 n l g 1 *
g 1 *
~ Fg 1, n g
l
p=2 g>=2 n l g 1 1 *
~ F2 ( g 1), 2 ( n g 1)
g 1 * l
p>=1 g=2 n l p 1 1 *
*
~ Fp , n p 1
p l
p>=1 g=3 n l p 2 1 *
~ F2 p , 2 ( n p 2 )
p * l
l 1 k 1 j 1
( xlkj x ) 2 bn ( x l x ) 2 gn ( x k x ) 2 n ( x lk x l x k x ) 2 +
l 1 k 1 l 1 k 1
g b n
( x
l 1 k 1 j 1
lkj x lk ) 2
Factor 2 b b 1
SS fac 2 gn ( x k x ) 2
k 1
Interaction g b ( g 1)( b 1)
SS int n ( x lk x l x k x ) 2
l 1 k 1
9
Total (corrected for the mean) g b n gbn 1
SS cor ( xlkj x ) 2
l 1 k 1 j 1
SS int
( g 1)( b 1)
○Test the interaction: F as F( g 1)( b 1), gb ( n 1) ( )
SS res
gb( n 1)
SS fac1 SS fac 2
g 1 b 1
○Test the main factor F as Fg 1, gb( n 1) ( ) ; F as
SS res SS res
gb( n 1) gb( n 1)
Fb 1, gb ( n 1) ( )
Factor 2 b b 1
SS fac 2 gn ( x k x )( x k x )'
k 1
Interaction g b ( g 1)( b 1)
SS int n ( x lk x l x k x ) ( x lk x l x k x )'
l 1 k 1
SS res
○Wilks’ lambda for testing interaction: *
SS int SS res
p 1 ( g 1)( b 1)
gb( n 1) ln * as (2g 1)( b 1) p ( )
2
SS res
○Wilks’ lambda for testing factor 1: *
SS fac1 SS res
p 1 ( g 1)
gb( n 1) ln * as (2g 1) p ( )
2
SS res
○Wilks’ lambda for testing factor 2: *
SS fac 2 SS res
p 1 (b 1)
gb( n 1) ln * as (2b1) p ( )
2
10
§ Multivariate Linear Regression Models
n 0
Y x
1 1n x
2 2n x
r rn n
In matrix form:
Y1 1 x11 x r1 0 1
Y 1 x x r 2 1 2
2 12
Yn 1 x1n x r 3 r n
Y X
[n 1][ n ( r 1)][( r 1) 1][ n 1]
where, the error term are assumed to have the properties:
E ( ) 0 ; Cov ( ) E ( ' ) 2 I (constant).
⊙Multiple regression vs. ANOVA (using three dummy variables for three level factor)
⊙Least squares estimation
○To minimize the error sum of squares (ESS):
Min ESS ' (Y X )' (Y X ) ˆ ( X ' X ) 1 X ' Y distributed as
N r 1 ( , 2 ( X ' X ) 1 )
n n n
○Decomposition: ( y j y ) 2 ( yˆ j y ) ˆ 2j
j 1 j 1 j 1
11
○Adjusted R-square = 1-(1-R2)(n-1)/(n-r-1)
○Estimation confidence interval: X 0 ' ˆ t n r 1 ( ) X 0 ' ( X ' X ) 1 X 0
2
○Prediction confidence interval: X 0 ' ˆ t n r 1 ( ) (1 X 0 ' ( X ' X ) 1 X 0 )
2
ˆ
Var (Y0 X 0 ' ) (1 X 0 ' ( X ' X ) X 0 )
2 1
⊙Model checking
○Plot residuals
‧against the predicted values y.
‧against the predictor variable x.
‧against time (sequence of observations).
‧Q-Q plot (normal distribution check).
○Multicollinearity (X’X)-1 is nearly zero and numerically unstable. VIF and TOL.
n n
○Serial correlation Durbin-Watson test. ( j j 1 ) 2 / 2j
j 2 j 1
12
R 1 1 p i
Pillai’s trace: ; tr[ R( R E ) ]
1
(The same way of univariate
RE p p i 1 1 i
R-square)
1 1 p
Hotelling-Lawley trace: tr ( E 1R ) i
p p i 1
Roy’s maximum root: max max( 1 , 2 ,..., p ) 1
All of above statistics can be approximated by F distribution.
nˆ
2 ln n ln
n ln nˆ n (ˆ ˆ )
1 1
1
For n large, the modified statistic: [n r 1 ( m r q 1)] ln ~ m2 ( r q ) .
2 1
⊙Predicted values
Yˆ Xˆ X ( X ' X ) 1 X ' Y
ˆ Y Yˆ Xˆ X ( X ' X ) 1 X ' Y
X ' ˆ X ' [ I X ( X ' X ) 1 X ' ]Y 0
Yˆ ' ˆ ˆ ' X ' [ I X ( X ' X ) 1 X ' ]Y 0
Y ' Y (Yˆ ˆ )(Yˆ ˆ ) Yˆ ' Yˆ ˆ' ˆ 0 0
total sum predicted sum of residual (error)
of squares = squares and cross- + sum of squares and
and cross-products product cross-product
◎Simultaneous-Equation Models
⊙Structural equations: BYt X t ut , t=1, 2, …, T
⊙With G endogenous variables and K exogenous variables.
13
⊙Reduced form: Yt X t vt , t=1, 2, …, T (Only for B is a nonsigular matrix)
⊙Estimation methods:
○Single equation method: estimate each equation with related restrictions separately by least
squares method. Y Y1 X 1 u (Y1:other included endogenous variables)
○ System method: estimate all equations with all restrictions together by maximum
likelihood method.
○Two-stage least squares (2SLS)
○Limited-information maximum-likelihood method
○Three-stage least squares (3SLS)
○Full-information maximum-likelihood method
14
§ Discrimination Analysis
15
○P(correctly classified asπ2)= P ( X R2 2 ) P ( 2 ) P ( 2 2) p 2
○P(misclassified asπ2)= P ( X R2 1 ) P ( 1 ) P ( 2 1) p1
⊙Consider misclassification costs are significantly different.
Classify as:
π1 π2
π1 0 C ( 2 1)
True population:
π2 C (1 2) 0
⊙Expected cost of misclassification (ECM)= c( 2 1) P ( 2 1) p1 c(1 2) P (1 2) p 2
f1 ( x ) c(1 2) p2 f1 ( x ) c(1 2) p2
⊙Region R1 & R2 R1 : ; R2 :
f 2 ( x ) c( 2 1) p1 f 2 ( x ) c( 2 1) p1
where, fi(x) is the p.d.f of the population i.
16
○The linear combination l '1 x is called the sample first discriminant.
○The linear combination l '2 x is called the sample second discriminant.
○The linear combination l 'k x is called the sample kth discriminant.
⊙The minimum expected cost of misclassification method
○ ECM p1ECM (1) p2 ECM (2) ... pg ECM ( g )
g g g 1
p1 ( P (k 1)c(k 1)) p2 ( P (k 2)c(k 2)) ... pg ( P (k g )c(k g ))
k 2 k 1 k 1
k 2
g g
pi ( P ( k i )c ( k i ))
i 1 k 1
k i
g
○Allocate x to k for which p f ( x )c ( k i )
k 1
i i is smallest.
k i
1 1
○The quadratic discrimination score: d kQ ( x) ln k ( x k )' k ( x k ) ln pi
2 2
1
○The linear discrimination score: d kQ ( x ) k' 1 x k ' k k ln pi (if i )
2
17
§ Logistic Regression
◎ Classification with two population & without assumptions of normality of exploratory
variables.
⊙Linear regression models of the form: E(y |x1, . . . , xk) = β0 + β1x1 + ···+ βkxk
⊙Let Pr(y = 1|x1, x2,. . . , xk) as the outcome, which is equal to E(y|x1, . . . , xk) when the
response (y) is coded as 0 or 1.
⊙To simplify notation, let the outcome of our model be π(X) = Pr(y = 1|x1, . . . , xk), where x
represents x1, x2,. . . , xk.
⊙π(X) represents the probability of the outcome of interest and lies in the interval [0, 1].
⊙π(X)/(1 − π(X)) belongs to the interval (0,∞).
⊙log{π(X)/(1 − π(X))} belongs to the interval (−∞,∞); this is the same range of values to
which the expression β0 + β1x1 + ···+ βkxk belongs.
⊙The basis for logistic regression is the equation (statistical model) log{π(X)/1-π(X)} =β0
+ β1X1 + · · · + βkXk.
⊙π(X)/1−π(X) is the odds of the outcome of interest for an individual with covariates X.
⊙log {π(X)/1−π(X)} is called the log odds or the logit.
18
§ Principal Components
e ' e
choice of l=ek+1 and e’k+1ek=0, k=1, 2, …, p-1. k 1 k 1 k 1 Var ( yk 1 ) .
ek 1 ' ek 1
○Total population variance =
p p
11 22 ... pp Var ( xi ) 1 2 ... p Var ( yi ) .
i 1 i 1
○The proportion of total variance due to (explained by) the kth principal component =
k
.
1 2 ... p
eki i
⊙The correlation coefficients between the components yi and the variables xk: y i , x k ,
kk
i, k =1, 2, …, p.
◎If the random variables X = [x1, x2,…, xp] is distributed as N p ( , ) , then is centered
19
ellipsoids: ( X )' 1 ( X ) c 2 of constant density have axes c i ei , i=1, 2, …,p. Let
1 1 1
=0, c 2 X ' 1 X (e1 ' X ) 2 (e2 ' X ) 2 ... (e p ' X ) 2
1 2 p
1 1 1
c2 y1 y2 ...
2 2 2
yp (Figure 8.1 on page 346)
1 2 p
○The proportion of (standardized) population variance due to the kth principal component =
k
. 1 2 ... p 0 are the eigenvalues of .
p
20
§ Factor Analysis
0 0 p
⊙ ( X ) F ' ( LF ) F ' LFF 'F ' , so Cov ( X , F ) E ( X ) F ' LE ( FF ' ) E (F ' ) L .
⊙Covariance structure for the Orthogonal Factor Model:
○ Cov ( X ) LL '
Var ( xi ) li1 li 2 ... lim i
2 2 2
◎Methods of Estimation
⊙Principal component method
⊙Maximal likelihood method
◎Factor Rotation
⊙L*=LT, where TT’=T’T=I. The estimated covariance (or correlation) matrix remains
unchanged. LL ' L'TT ' L L * L*' .
cos sin
Taking m=2 at a time, L * L T where T (clockwise rotation);
( p 2) ( p 2 ) ( 2 2 )
sin cos
cos sin
T (counterclockwise rotation).
sin cos
21
⊙Rotated loadings must be inspected to find a meaningful interpretation of the original data.
⊙Varimax rotation (proposed by Kaiser,1958) selects the orthogonal transformation T that
p *2
2
lij
1 m p *4 i 1
makes: V lij as large as possible.
p j 1 i 1 p
◎Factor Scores
⊙The estimated value of common factors are called factor scores.
⊙Usually, the estimated rotated loadings are used to compute factor score.
⊙The weighted least square method:
f ( L' 1 L ) 1 L 1 ( x )
If factor loadings are estimated by the principal component method: f ( L' L) 1 L( x )
⊙The regression method: f L' S 1 ( x ) .
22