Professional Documents
Culture Documents
1
Multiple Linear Regression
3. Multivariate multiple linear regression: several y’s
and several x’s. In the preceding illustration, we may
wish to predict several y’s (such as number of years
of college the person will complete or GPA in the
sciences, arts, and humanities).
• To further distinguish case 2 from case 3, we could
designate case 2 as univariate multiple regression
because there is only one y. Thus in case 3,
multivariate indicates that there are several y’s and
multiple implies several x’s.
• The term multivariate regression usually refers to
case 3.
Prof. M. R. Karim, Stats., R.U. 3
2
Model with Two Predictor Variables
• The parameters of the model are β0, β1, and β2,
and the error term is εi.
• Assuming that E{εi } = 0, the regression function
for the model is:
E{Y} = β0 +β1X1 +β2X2
• Analogous to simple linear regression, where the
regression function is a line, regression function
with two predictors is a plane.
3
Model with Two Predictor Variables
• The parameter β1 indicates the change in the
mean response E{Y} per unit change in X1 when
X2 is held constant.
• Likewise, β2 indicates the change in the mean
response E{Y} per unit change in X2 when X1 is
held constant.
• The parameters β1 and β2 are sometimes called
partial regression coefficients because they
reflect the partial effect of one predictor variable
when the other predictor variable is included in
the model and is held constant.
Prof. M. R. Karim, Stats., R.U. 7
4
Model with more than two predictor variables
• It can also be written: p 1
Yi 0 k X ik i
k 1
5
Model with Qualitative Predictor Variables
• The general linear regression model
encompasses not only quantitative predictor
variables but also qualitative ones, such as
gender (male, female) or disability status (not
disabled, partially disabled, fully disabled), etc.
• We Use indicator variables that take on the
values 0 and 1 to identify the classes of a
qualitative variable.
6
Model with Qualitative Predictor Variables
• The response function for this regression model
is:
E Y 0 1 X1 2 X 2
7
Model with Qualitative Predictor Variables
• The first-order model with age, gender, and
disability status as predictor variables then is:
Yi 0 1 X i1 2 X i 2 3 X i 3 4 X i 4 i
8
General Linear Regression Model in Matrix Terms
Estimation of Regression Coefficients
1. Least Squares Method:
• To determine the least squares estimator, we write
the sum of squares of the residuals as
n
SSE i2 εε (Y - Xβˆ )(Y - Xβˆ )
i 1
9
General Linear Regression Model in Matrix Terms
Variance-Covariance Matrix
βˆ = X'X X'Y
-1
E βˆ = X'X X'E Y = X'X X'Xβ = β
-1 -1
σ 2 βˆ = X'X X'σ 2 Y X X'X
-1 -1
= σ 2 X'X
-1
10
General Linear Regression Model in Matrix Terms
i 1 i 1 n n
where J is a square matrix with all elements 1,
1 1
J n n
1 1
1
Y I J Y
n
Prof. M. R. Karim, Stats., R.U. 22
11
Analysis of Variance Results
n
SSE i 2 εε (Y - Xβˆ )(Y - Xβˆ )
i 1
12
Analysis of Variance Results
13
Analysis of Variance Results
• Each of the above three sums of squares can now
be seen of the form YAY where the three A
matrices are:
1 1
n
I J , [ I H ], and H J
n
• Since each of these A matrices are symmetric,
SSTO, SSE, and SSR are quadratic forms.
• That is, all sums of squares in the analysis of
variance for linear statistical models can be
expressed as quadratic forms.
Prof. M. R. Karim, Stats., R.U. 27
Source of
DF SS MS F
Variation
1
βˆ XY YJY MSR F = MSR/MSE
Regression (p-1) n = SSR/(p-1) ~ F(k-1, n-k)
YY - βˆ XY
Residual or MSE
(n-p)
error = SSE/(n-p)
1
Total n-1 Y I J Y
n
14
Coefficient of Multiple Determination
• The coefficient of multiple determination,
denoted by R2, is defined as follows:
SSR SSE
R2 1
SSTO SSTO
• The coefficient of determination R2 will have a
value between 0 and 1.
• Adding more X variables to the regression model
can only increase R2 and never reduce it, because
SSE can never become larger with more X
variables and SSTO is always the same for a
given set of responses.
Prof. M. R. Karim, Stats., R.U. 29
15
Next – Remaining Materials
• Kutner, M., Nachtsheim, C. and Neter, J.
(2007). Applied Linear Statistical Models.
6th Edition, McGraw Hill/Irwin Series.
Ym 0 m 1m z1 rm zr m
16
Multivariate Multiple Regression
17
Multivariate Multiple Regression
• In matrix notation, the design matrix
18
Multivariate Multiple Regression
ε1'
11 12 1m
ε '
22 2 m 2
ε n m 21 ε (1) ε (2) ε ( m )
n1 n 2 nm
'
ε n
• The multivariate linear regression model is
Ynm Z n( r 1)β ( r 1)m ε nm
with
E (ε (i ) ) 0, Cov ε (i ) , ε ( k ) ik I, i, k 1, 2, ,m
Prof. M. R. Karim, Stats., R.U. 37
19
Multivariate Multiple Regression
• Simply stated, the ith response Y(i) follows the
linear regression model
Y(i ) Zβ (i ) ε (i ) , i 1, 2, , m
with Cov(ε (i ) ) ii I.
• In conformity with the single-response solution,
we take
β (i ) Z ' Z Z ' Y(i )
1
ˆ
20
Multivariate Multiple Regression
• For any choice of parameters
B b (1) b (2) b ( m )
• The matrix of errors is Y - ZB.
• The error sum of squares and cross products
matrix is
Y ZB ' Y ZB
Y(1) Zb (1) ' Y(1) Zb (1) Y Zb (1) ' Y( m ) Zb ( m )
(1)
Y( m ) Zb ( m ) ' Y(1) Zb (1) Y( m) Zb( m) ' Y( m) Zb( m)
21
Multivariate Multiple Regression
• Using the least squares estimates β̂ , we can form
the matrices of
ˆ Zβˆ Z Z ' Z 1 Z ' Y
Predicted values: Y
Residuals: ˆ I Z Z ' Z 1 Z ' Y
εˆ Y Y
• The orthogonality conditions among the
residuals, predicted values, and columns of Z,
which hold in classical linear regression, hold in
multivariate multiple regression.
• They follow from Z'[I - Z(Z'Z)-1Z'] = Z' - Z' =0.
22
Multivariate Multiple Regression
or ˆ 'Y
Y 'Y Y ˆ εˆ ' εˆ
Total SS and Predicted SS and Residual SS and
cross products cross products and cross prod.
23
Multivariate Multiple Regression
z1 0 1 2 3 4
y1 1 4 3 8 9
y2 -1 -1 2 3 2
Solution:
• We have
1 1 1 1 1 0.6 0.2
, Z ' Z
1
Z'
0 1 2 3 4 0.2 0.1
βˆ (1) Z ' Z Z ' y (1) 1 2 '
1
yˆ1 1 2 z1 , yˆ 2 1 z2
1 0 1 1
1 1 3 0
1 1
ˆ Zβˆ 1 2
Y 5 1
2 1
1 3 7 2
1 4 9 3
24
Multivariate Multiple Regression
ˆ 0 1 2 1 0 ' εˆ ' Y
εˆ Y Y ˆ 0 0
0 1 1 1 1 0 0
171 43
Y 'Y ˆ 165 45 , εˆ ' εˆ 6 2
ˆ 'Y
, Y 45 15 2 4
43 19
z1 <- c(0, 1, 2, 3, 4)
y1 <- c(1, 4, 3, 8, 9)
y2 <- c(-1, -1, 2, 3, 2)
25
Multivariate Multiple Regression
beta1.hat <- ZtZ.inv %*% t(Z) %*% y1
beta2.hat <- ZtZ.inv %*% t(Z) %*% y2
beta.hat <- cbind(beta1.hat, beta2.hat)
Y.hat <- Z %*% beta.hat
e.hat <- Y - Y.hat
t(Y) %*% Y
t(Y.hat) %*% Y.hat + t(e.hat) %*% e.hat
# verified
# Prediction
Z.given <- c(1, 2.5)
Y.pred <- Z.given %*% beta.hat
Prof. M. R. Karim, Stats., R.U. 51
# Prediction
Z.given <- c(1, 2.5)
Y.pred <- Z.given %*% coef(lm.fit)
Prof. M. R. Karim, Stats., R.U. 52
26
Multivariate Multiple Regression
Result 7.9 :
For the least squares estimator βˆ βˆ (1) βˆ (2) βˆ ( m )
determined under the multivariate multiple regression
model with full rank ( Z ) r 1 n,
E βˆ (i ) β (i ) or E βˆ β and
Cov βˆ
, βˆ ( k ) ik Z ' Z , i, k 1, 2,..., m
1
(i )
continued...
27
Multivariate Multiple Regression
Proof of Result 7.8 :
The ith response follows the multiple regression model
Y(i ) Zβ (i ) ε (i ) , E ε (i ) 0, E ε (i )ε (' i ) ii I
E εˆ '(i )εˆ ( k ) E ε (' i ) I Z(Z ' Z) 1 Z ' ε ( k )
tr I Z(Z ' Z) 1 Z ' ik I ik tr I Z(Z ' Z) 1 Z '
εˆ '(i )εˆ ( k )
ik (n r 1) E Σ
n r 1
Prof. M. R. Karim, Stats., R.U. 56
28
Multivariate Multiple Regression
Note:
Let Z be an n (r 1) matrix [( r 1) n]
with full rank, i.e. rank(Z)=r 1
(this is necessary for Z ' Z
1
to exist).
Then, using the identity tr(AB)=tr(BA), we have
tr[Z(Z ' Z) 1 Z ']=tr[Z ' Z( Z ' Z) 1 ]
=tr[I ( r 1)( r 1) ]=r 1=rank(Z)
tr I Z(Z ' Z) 1 Z ' tr[I nn ]-tr[I ( r 1)( r 1) ]
=n r 1
Prof. M. R. Karim, Stats., R.U. 57
Z ' Z Z ' E ε ε I Z Z ' Z Z '
1 ' 1
(i ) ( k )
29
Multivariate Multiple Regression
30
Multivariate Multiple Regression
Setting Z Z1 Z 2 , we can write the general model as
n( q 1) n( r q )
β (1)
E (Y) Zβ Z1 Z 2 Z1β (1) Z 2β (2)
β (2)
= Y Z1βˆ (1) ' Y Z1βˆ (1) Y Zβˆ ' Y Zβˆ
ˆ Σ
=n Σ1
ˆ
where βˆ (1) Z1'Z1 Z1'Y, Σ
1
ˆ n 1 Y Zβˆ ' Y Zβˆ
and Σ1
ˆ n 1 Y Z βˆ ' Y Z βˆ
1 (1) 1 (1) .
31
Multivariate Multiple Regression
From Result 7.10, the likelihood ratio, , can be
expressed in terms of generalized variances:
max L(β (1) , Σ)
L(βˆ (1) , Σ
ˆ ) |Σ n/2
β(1) , Σ ˆ|
1
32
Multivariate Multiple Regression
• The data are given in the following Table for
o Z1 = customer orders (in thousands)
o Z2 = add-delete item count (in thousands)
o Y1 = CPU (central processing unit) time (in hours)
o Y2 = disk input/output capacity
y1 y2 z1 z2
141.5 301.8 123.5 2.108
168.9 396.1 146.1 9.213
154.8 328.2 133.9 1.905
146.5 307.4 128.5 0.815
172.8 362.4 151.5 1.061
160.1 369.5 136.2 8.603
108.5 229.1 92.0 1.125
Prof. M. R. Karim, Stats., R.U. 65
33
References
• Draper, N.R. and Smith, H. (1999). Applied
regression analysis. 3rd Edition, Wiley.
• Kutner, M., Nachtsheim, C. and Neter, J.
(2004). Applied Linear Statistical Models.
5th Edition, McGraw Hill/Irwin Series.
• Rencher, A. C. (2002): Methods of Multivariate
Analysis, 2nd ed. Wiley, N.Y.
• Weisberg, S. (2005). Applied Linear Regression,
3rd Edition. John Wiley & Sons, NY.
34