Professional Documents
Culture Documents
STA302 Week08 Full
STA302 Week08 Full
1/50
Midterm and Final
• If you wrote the midterm, you should receive a mail from Crowdmark.
• For remark request:
• Write me an email within 7 days.
• The request must contain a justification for consideration.
• All remark requests, the whole assignment/ test will be
remarked. There is chance that you might get lower mark points
after remarking.
• Final is on Dec. 12, AM 9-12
• A to J: BN 2N
• K to R: BN 2S
• S to ZHE: BN 3
• Zho to ZZ: ZZ VLAd
2/50
Last Week
• Variable transformations.
• More on logarithmic transformation.
• Box-Cox transformation.
• Interpretation of slope after transformation.
• Chapter 4: Simultaneous Inferences
3/50
Review: from p-value to conclusion
True model Estimated model
Yi = —0 + —1 Xi + ‘i ; Ŷi = b0 + b1 Xi
H0 : —1 = 0; Ha : —1 ”= 0
• test statistic:
b1
tú = |H ≥ tn≠2 b. s×¥× scb.t.tn#xps
s(b1 ) 0
=
• Review on matrices.
• What is matrix?
• Matrix: transpose, multiplication, addition, inverse
• Special matrices: identity, diagonal, column vector, row vector.
• Variance-covariance matrix of a random vector.
• Matrix Differentiation.
* • Simple Linear Regression Model in Matrix form.
• SLR model in matrix form.
• Least Squares Estimation of Regression Parameters in matrix form.
• Fitted values and residuals in matrix form.
• Inference in Regression Analysis
• ANOVA in matrix form
5/50
Review on Matrices
6/50
Review on Matrices
7/50
Review on Matrices (cont.)
8/50
Review on Matrices (cont.)
• Matrix equality: two matrices are called equal if they have . same
dimensions and the corresponding elements
. are equal.
• (ABC )T = C T B T AT
9/50
Review on Matrices (cont.)
Diagonal matrix:
• It is a square matrix and all off-diagonal elements are 0.
S T S T
d1 0 0 1 0 0
D3◊3 = U 0 d2 0 V , I3◊3 = U0 1 0V
0 0 d3 0 0 1
• Scalar matrix: diagonal matrix with all diagonal elements being equal
S T S T
d 0 0 1 0 0
U0 d 0 V = d · U0 1 0V = d · I
0 0 d 0 0 1
12/50
Inverse of a Matrix
A≠1 A = AA≠1 = I
13/50
Inverse of a Matrix (cont.)
14/50
Column Vectors
• 1Õ 1 = n
15/50
Mean of a random Vector
16/50
Mean of a linear combination of Random Vector
S T
5 6 5 6 Y
b a a1,2 a1,3 U 1 V
b2◊1 + A2◊3 Y3◊1 = 1 + 1,1 Y2
b2 a2,1 a2,2 a2,3
Y3
5 6
b1 + a1,1 Y1 + a1,2 Y2 + a1,3 Y3
X2◊1 =
b2 + a2,1 Y1 + a2,2 Y2 + a2,3 Y3
• Mean of X: µx = E (X) = E (b+AY) = b + AE (Y) = b + Aµ
µy
17/50
Var-Cov of Random Vectors
µ
mat of F
Eye
var -
an
ioytljitjl
Var (‘‘) = ‡ 2 I
If
3
L
=
Ty
1
52 = v th )
.
-
.
. .
= VCYN )
{ constant
CMYI ,Yj
variance
errors
uncorrelated
@ )i±j=o are
:
18/50
Var-Cov of Random Vectors
Show Var (Y) = E {[Y ≠ µ] · [Y ≠ µ]Õ }
WY2 ≠ µ2 X #Y ≠ µ Y 2 ≠ µ2
$
Y n ≠ µn )
= E (U .. V 1 1 ... nxn ⇒ matrix
. Hh
Y n ≠ µn nxl
S (Y1 ≠ µ1 )2 (Y1 ≠ µ1 )(Y2 ≠ µ2 ) ... (Y1 ≠ µ1 )(Yn ≠ µn )
T
W .. .. .. .. X
= E (U . . . . V)
..
(Yn ≠ µn )(Y1 ≠ µ1 ) (Yn ≠ µn )(Y2 ≠ µ2 ) . (Yn ≠ µn )2
S
V (Y1 ) Cov (Y1 , Y2 ) ...
T
Cov (Y1 , Yn )
W Cov (Y2 , Y1 ) V (Y2 ) ... Cov (Y2 , Yn )X
=U .. .. .. .. V
. . . .
Cov (Yn , Y1 ) Cov (Yn , Y2 ) ... Var (Yn )
= n◊n
19/50
Var-Cov Random Vectors
20/50
Example: Var-Cov of linear combination of random vector
• Let X = b+AY.
• Using (A + B)C = AB + AC , (AB)T = B T AT ,
• Show the var-cov matrix of X is
X = E {(X ≠ µx )(X ≠ µx )T } = A yA
T # I
proof :
.
x=bt AT
EHKECBTAYI = bt AEIY )
X Ehl
-
° - - =
Now by defh
}
AHMHTLHLMYIT
El
Excel l*µ×)L*µ×T ) =
zi
: CABIEBTA
'
=
} Ef AH .
My )tfµy
a-
)
T
AT
=
A E{ H-µy ) (Y -
µyM } AT
=AZy AT
÷
a. E. D .
21/50
Example 2 on Var-Cov .
Yi~H( 0 ,
Try
{ Yz NLO Tie )
.
6 ⇒ imply
~
,
5 6 5 6 5 2 only .k)=Jnz
Y1 0
.
‡1 ‡1,2
≥ N( , 2 ), Y ≥ N(0, )
Y2 0 ‡1,2 ‡2
Show V (a1 Y1 + a2 Y2 ) = a12 ‡ 2 + a2 ‡22 + 2a1 a2 ‡1,2
Proof : Method 1 :
vcaihtaihl =
vcaihltvcaihltscwlaia ,
ask )
=
airptairitzaiaz Couch ,k )
=
aprptazrit 29929,2
r#
Method 2 :
W=aihtazYz= ( a , as )l¥z ) =
Anika
= =
=
ca , an 1%2
EI
.
's
) ( Aa )
%
=
atop taint 29,925,2
d. E. D.
22/50
Example 3 on Var-Cov
• Example: Y1 , Y2 ≥ N(0, 1) independently.
• Show
5 6 5 65 6 5 6 5 6
W1 1 0 Y1 0 1 fl
W= = ≥ N( , )
W2 fl 1 ≠ fl2 Y2 0 fl 1
= T
proof : W AY and µy= It9)
=
, 181 I =
=L
.
,
•
Elw ) =
EIAT ) =
A Ely) =
02×1
var ( w
Ee AT
) Var ( AT )
.
=
= A
=
AIAT =AA7
Itif ) tfp
'
1 )
=
.
o .
=
( f ) QE .
D .
23/50
Matrix Differentiation
Y = f (X ), where xn◊1
m◊1
.
ˆX U . V U .. W . .
.. .
.. .
.. XV
ˆYn ˆym ˆym ˆym
X . . .
ˆX ˆx1 ˆx2 ˆxn m◊n
24/50
Matrix Differentiation (cont.)
ˆY
MD01 : Y = A X ∆ =A
m◊1 m◊n n◊1 ˆX
Proof:
Hint take
Efta
In
.it?aInMIt*
⇒ Yi =
# AIKXK
⇒
Thing and
=
aij Hit 2 m j⇒ 2 n
. -
,
.
.
, ,
,
2 Yi
=)
Tx
=
[ Air Aiz Ain ]
- -
-
, ,
⇒
QED .
25/50
Matrix Differentiation (cont.)
MD02 : – = Y T
1◊1
A
1◊m m◊n n◊1
X ∆ OM20L
ˆ–
ˆX
= Y T A, and
ˆ–
ˆY 4
= X T AT
Proof:
@ WEYTA ⇒ 2= WTX
⇒
¥× = WT by MDOI
←
-
=
YTA
× , ⇒ 2=51 =
XTATY
⇒ 22
XTAT
Ty
=
a. ED .
26/50
Matrix Differentiation (cont.)
For the special case in which the scalar – is given by the quadratic form
ˆ–
MD03 : – = X T A X ∆ = X T (A + AT )
1◊1 1◊n n◊n n◊1 ˆX
Proof:
An An
-
-
Ain
by defn 2=1×1×2 ,
-
'
j= EYE
! aij
L - ,
Xi
Xj
2¥ #
⇒
.
=
# , akjxj t Aik Xi
=
ix. x. -
-
xn ) Makin ) + ix. .
.
xn ) µa¥m )
,
=
XT Artowk t XTA column k for Kb 2
,
- -
n
,
--
'
⇒
2¥ = XTAT + XTA =
XTIATTAI
27/50
Matrix Differentiation (cont.)
For the special case in which the scalar – is given by the quadratic form,
and the A is a symmetric matrix, ⇒ A=AT
ˆ–
MD04 : – = X T A X ∆ = 2X T A
1◊1 1◊n n◊n n◊1 ˆX
Proof:
¥ = XTIATAT )
=2XTA
QE . D .
28/50
Matrix approach to SLR
29/50
SLR in matrix form
• X Matrix: S T
1 X1
W1 X2 X
W X
Xn◊2 = W. .. X
U .. . V
1 Xn
often referred to as the design matrix.
30/50
SLR in matrix form
,¥x=
iIn .tn?i&xntItExiFIil
ix. !
'
x.
• Product
/
,
n
ÿ
= Mi .
I -
-
Ynl (
l¥n ) =
Fun Yj2
1◊1
=
S T
Exitnxy
2 =a
1 =n(
+ q(XX̄ ≠X̄ )2 ≠ q(XX̄≠X̄ )2
"
n
∆ (XT X)≠1 = U i i
V =n Ein lxixt
1◊1 ≠ q(XX̄≠X̄ )2 q 1 2
(X ≠X̄ )
,
i i
=nS××
f- Exit
mm
=
#IIENKITY
Ali #
= H÷nm¥xtnItnt¥*
31/50
SLR in matrix form
E (Yi ) = —0 + —1 Xi , i = 1, . . . , n
• Let
S T S T
E (Y1 ) 1 X1
WE (Y2 )X W1 X2 X 5 6
W X W X —0
E (Y)n◊1 = W . X , Xn◊2 = W . .. X , — 2◊1 = —
U .. V U .. . V 1
E (Yn ) 1 Xn
32/50
SLR in matrix form (cont.)
33/50
SLR model in matrix form (cont.)
Yi = —0 + —1 Xi + ‘i , i = 1, . . . , n
34/50
SLR model in matrix form (cont.)
Y = X—
— +‘
35/50
Least Squares Estimation of Regression Parameters
• Normal Equations
ÿ ÿ
nb0 + b1 Xi = Yi (1)
ÿ ÿ ÿ
b0 Xi + b1 Xi2 = Xi Yi (2)
X ÕX b = X ÕY
2◊2 2◊1 2◊1
5 q 65 6 5 q 6
n X i b0 Y i
X X ·b = q
Õ q 2 =X Y = q
Õ
Xi Xi b1 Xi Yi
• The vector of the least squares regression coefficients
S 2
T
1 q X̄ q X̄ 2 5 q
5 6
b + ≠ 6
V q Yi
n (Xi ≠X̄ ) 2 (Xi ≠X̄ )
b = 0 = (XÕ X)≠1 XÕ Y = U
b1 ≠ q X̄ 2 q 1 2 Xi Yi
(Xi ≠X̄ ) (Xi ≠X̄ )
36/50
Verify the LS matrix form Exercise :
S 2
T
1
5 6
b0 + q(XX̄ ≠X̄ )2 ≠ q(XX̄≠X̄ )2 5 q 6
V q Yi
n
b= = (XÕ X)≠1 XÕ Y = U i i
b1 ≠ q X̄ 2 q 1 Xi Yi
(Xi ≠X̄ ) (Xi ≠X̄ )2
et sxx =
-2¥ Ni # 12
Elkin ) hit =
'
-
0Elxi-x1lYj-51-TlXiYjtnxjth@Elxiyp-EXj2-nx2proof.L
( )( )
i
-
.be#EIIxjIksxIx=nnI+n5gxI.xEhgxiI
5- ¥i¥±# "
5 =b
)= (
.
aximj.IE/=b.=c*bbi
-
*¥× +
age •
ya
ÿ
,n×Q
Q= [Yi ≠ (—0 + —1 Xi )]2 B :
2×1
T
= (Y ≠ X —) (Y ≠ X —) ' '' 2 zxnnx
¥ ( BTXTY )
= Y T Y ≠ —T X T Y ≠ Y T X — + —T X T X —
1×1 1×2 lxhnxz =¥p ( YTXP )
"nxiLeIFtexxEf
2×h nxl zx ,
lptxtxp )
X Õ Xb = X Õ Y
ˆ Assume X Õ X is invertible
• Solving it for —. =zpT( XTX )
1 MD 04 )
∆ b = (X Õ X )≠1 X Õ Y
38/50
Fitted Values and Residuals
Fitted Values:
39/50
Fitted Values and Residuals (conts.)
⇐
make.tt?IiiIIiwll?d.hiIItIiIIEEI?I
Hat Matrix:
• H = X (X Õ X )≠1 X Õ : Hat matrix or “projection” matrix. I ,
• Important in diagnostics for regression
• Symmetric and idempotent:
.
Eh hi ; = 1
&
H T = H; HH = H -3¥ hiijihii
1
HE [ xixix , ix. 1 '=×[w× .yt×
,
-
,
hij-hjithEiIhiie2n-xtlxTxPItXT-XlXTX5lXT-H@HH-XlXTX5lXTXcXTX51xT-XcxTxjtXT-Hmn_MHH-HH0EiYhIy-hii0Zkhahikh.k
- ;
=
hij
40/50
Residuals
41/50
Residual distribution
e=Y 'T y HY
=
=h HIY where
*
KXHX
'
He
-
-
xitxtxxp
,
⇒ EL HM
f- ) =
H -
HIEN ) 2
xp HXB xp =Xp Xp :O
= -
=
- -
w nm
Van e) Var
=
( EHN )
=
(z -
H) Zy H -
HIT
z .
H is idempotent'
'
= ( z -
His 1 a- H )
x
=P ( THHTHI = 02 I Ht )
42/50
Inference in Regression Analysis
symmetric
ttforvaravmatrixif
Regression Coefficients:
• The variance-covariance matrix of b:
5 6
V (b0 ) V (b0 , b1 ) combo b.) 0-25
Var (b) =
=
-
2
= ‡ (X X )Õ ≠1
"
var ( b
,
)=E÷×
43/50
Inference in Regression Analysis (cont.)
2
=‡
ˆ (X X )
Õ ≠1
• b = (X Õ X )≠1 X Õ Y = AY
T
• ∆ V (b) = V (AY ) = A YA = ‡ 2 AAT = ‡ 2 (X Õ X )≠1
44/50
Mean response and prediction of new observation
45/50
Analysis of Variance Results (ANOVA)
Total Sum of Squares
ÿ 1 Õ 1
SSTO = (Yi ≠ Ȳ )2 = YÕ Y ≠ Y JY = YÕ [I ≠ J]Y
n n
Proof:
Il Yi -
F) 2= Eyeing
2
= zy ,
?
-
K¥2
'
th 141
Hk
Y Y )
= '
-
th
' ' '
=
Y Y -
IY 12 Y)
'
=
y y -
th LYJY )
his ) y
'
=
Y (z
-
46/50
Analysis of Variance Results (ANOVA) (cont.)
Error Sum of Squares
sseeeie-H-xbjlY-Xb1-Htb1xYH-xb1-Y4-Yxb-b1XYtbX1xb_ib-lXXMXYb1-YlXCX1X5l-Yy-Yxb-b1XYtYIIkXExxbtYY-YXb-b1XYtYXbae-b1XY@sSEee1e-ly-FpCy-P1-ktHNj4tHjY-YCz-HH2-HM-Y1CtH1YQ.E.D
47/50
Analysis of Variance Results (ANOVA) (cont.)
Regression Sum of Squares
ÿ 1 Õ 1
SSR = (Ŷi ≠ Ȳ )2 = bÕ XÕ Y ≠ Y JY = YÕ [H ≠ J]Y
n n
Proof:
EYIETTY
DssRt-HiYitl2-EIcYitzFItF2l-2EFYY-2Y2iFkTth.lxi-xHtny2.Yi-botkXi-FbiItb.Xi-2iFitit25enytb.Elxixntny2-5tbilxiX1-O-EiIFi2-2nT2tny2l-Ei.FYi2-nYT0EFi2tlxblTcxbkbTXTxb-blXx1llxX5lMyI-b1XY@ny2.t
-n( EYIP =
'T ((141417 ) ) =
th YJY
ssR= 1
-
2 =
b 'X' Y -
th YYY
30-20=4
IH HTTY
'
)=Y' AT
-
HYITCHY
'
3
= ( ⇒ ssr=
48/50
Analysis of Variance Results (ANOVA) (Summary)
ÿ ÿ 1
SSTO = Yi2 ≠ ( Yi )/n = YÕ (I ≠ J)Y
n
SSE = e Õ e = (Y ≠ Xb)Õ (Y ≠ Xb) = YÕ (I ≠ H)Y
ÿ 1
SSR = (Ŷi ≠ Ȳ )2 = YÕ [H ≠ J]Y
n
49/50
Practice problems and upcoming topics
• Practice problems after today’s lecture: CH5: 5.1, 5.3, 5.4, 5.8, 5.10,
5.12, 5.17, 5.21, 5.23, 5.29, 5.31
• Extra exercises
• Show I ≠ H is symmetric and idempotent.
• Show H(I ≠ H) = 0
• Upcoming topics
• CH6: Models with more than one predictors.
• Reading for upcoming topics: Chapter 6.
50/50