0% found this document useful (0 votes)
26 views

Assignment 2

This document describes conducting a multiple linear regression analysis with two predictor variables manually and in R. It includes: 1) Writing the regression model with two predictors for n observations in equation and matrix form. 2) Defining the data matrix, response vector, estimates for the beta vector, error variance, variance covariance matrix for beta-hat. 3) Constructing an ANOVA table and testing hypotheses about the predictor variables.

Uploaded by

Tariq
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Assignment 2

This document describes conducting a multiple linear regression analysis with two predictor variables manually and in R. It includes: 1) Writing the regression model with two predictors for n observations in equation and matrix form. 2) Defining the data matrix, response vector, estimates for the beta vector, error variance, variance covariance matrix for beta-hat. 3) Constructing an ANOVA table and testing hypotheses about the predictor variables.

Uploaded by

Tariq
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

*Assignment 1(a):*

*(i) Write down the structure of Response variable for n values. (ii). Write down the appropriate
model in matrix notation. (iii) Define Data Matrix, Response vector for this Example and
Estimate Beta vector, Error variance, variance covariance matrix for Beta-hat then construct
ANOVA table and test appropriate hypothesis. *

 */Do it manually and in R using both lm() and matrix multiplications method/*

Solution:
(i):
Multiple linear regression models are defined by the equation

Y=β0+β1X1+β2X2+ϵ
For n observations:

Y11=β0+β1X11+β2X12+ϵ11
Y21=β0+β1X21+β2X22+ϵ21
Y31=β0+β1X31+β2X32+ϵ31
⋮ ⋮ ⋮ ⋮ ⋮

Yn1=β0+β1Xn1+β2Xn2+ϵn1
(ii):
Then in matrix form we have:
Y = X β+ ϵ … ( A )

[ ][ ][ ] [ ]
Y 11 1 X 11 X 12 β 0 ϵ 11
Y 21 1 X 21 X 22 β 1 ϵ 21
Y 31 = 1 X 31 X 32 β 2 + ϵ 31 … (i )
⋮ ⋮ ⋮ ⋮
Y n1 1 X n1 X n2 βn ϵ n1

(iii):
Data matrix with Response vector are below

[ ][ ] [ ]
58 1 111 16 ϵ 11
59 1 105 17 ϵ 21

[]
60 1 118 15 ϵ 31
β0
65 = 1 105 18 ϵ 41 …(ii)
β1 +
67 1 94 15 ϵ 51
β2
69 1 81 17 ϵ 61
70 1 78 18 ϵ 71
80 1 76 20 ϵ 81

⇧ ⇧ ⇧ ⇧
Response vector Design matrix Beta vector Random variation vector

By using R software, we estimate the Beta vector:

[ ][ ]
β0 75.8933
β 1 = −0.3150
β2 1.1969

And Random variation vector is:

[ ][ ]
ϵ 11 −2.0778999
ϵ 21 −4.1648976
ϵ 31 3.3241092
ϵ 41 = 0.6381729
ϵ 51 2.7638362
ϵ 61 −1.7251706
ϵ 71 −2.8671342
ϵ 81 4.1089841
Error variance is:
2
σ =3.710531

variance covariance matrix for Beta-hat:

Var ( ^β| X ) =¿

[ ]
1 111 16
1 105 17
1 118 15
X= 1 105 18
1 94 15
1 81 17
1 78 18
1 76 20

[ ]
8 768 136
X́ X = 768 75552 12932
136 12932 2332

Then we have Var ( ^β| X ) after putting the values of ¿ and σ 2.

[ ]
196.7140541 −0.708207865 −7.54484016
Var ( β| X ) = −0.7082079 0.003516433 0.021801819
^
−7.5448402 0.021801819 0.32069789
Anova Results:
Analysis of Variance Table

Analysis of Variance Table

Response: Y
Df Sum Sq Mean Sq F Value Pr(>F)
X1 1 286.584 286.584 20.8151 0.006044 **
X2 1 16.576 16.576 1.2039 0.322545
Residuals 5 68.840 13.768
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
For X1: β 1 ≠ 0 because P-value is less then 0.05 so, we reject H0 .
And for X2: β 2=0 because P-value is greater then 0.05 so, we do not reject H0 .

You might also like