You are on page 1of 21

MULTIPLE LINEAR REGRESSION

SAMPLE PROBLEM

The survival rate of sperm (y %) from an animal semen was measured at different concentrations u
types of materials (x1, x2 & x3). The data obtained are given in the table below. Find the multiple li
regression model for the given data. Determine also the coefficient of determination and interpret
y x1 x2 x3
26.7 1.51 4.5 12.05
32.4 6.09 4.62 10.65
27.1 5.99 7.61 8.45
39.6 10.29 3.83 9.75
19.6 0.96 10.8 10.65
27.9 0.99 5.05 11.15
27.6 3.87 5.82 9.25
26.4 6.09 7.92 10.35
32.5 3.85 3.62 9.95
25.7 3.92 6.8 10.45

Estimate the % survival rate if x1= 5.58%, x2= 8.5% & x3= 11.3%.

EXAMPLE FIND: 𝑦=𝑏_0+𝑏_1 𝑥_1+𝑏_2 𝑥_2+𝑏_3 𝑥_3


n= 13
Sample y x1 x2 x3 x1^2 x2^2 x3^2 x1*x2
1 26.7 1.51 4.5 12.05 2.2801 20.25 145.2025 6.795
2 32.4 6.09 4.62 10.65 37.0881 21.3444 113.4225 28.1358
3 27.1 5.99 7.61 8.45 35.8801 57.9121 71.4025 45.5839
4 39.6 10.29 3.83 9.75 105.8841 14.6689 95.0625 39.4107
5 19.6 0.96 10.8 10.65 0.9216 116.64 113.4225 10.368
6 27.9 0.99 5.05 11.15 0.9801 25.5025 124.3225 4.9995
7 27.6 3.87 5.82 9.25 14.9769 33.8724 85.5625 22.5234
8 26.4 6.09 7.92 10.35 37.0881 62.7264 107.1225 48.2328
9 32.5 3.85 3.62 9.95 14.8225 13.1044 99.0025 13.937
10 25.7 3.92 6.8 10.45 15.3664 46.24 109.2025 26.656
y_bar 28.55
SUM= 285.5 43.56 60.57 102.7 265.288 412.2611 1063.725 246.6421
n= 13
Normal Equations:
b0 b1 b2 b3 B inv(A)= minverse
A= 10 43.56 60.57 102.7 285.5 27.90041167
43.56 265.288 246.6421 433.36 1347.34 -0.571619126
60.57 246.6421 412.2611 619.2885 1642.442 -0.48287658
102.7 433.36 619.2885 1063.725 2922.195 -2.179713273
*Use Ctrl+shift then press enter
Matrix Inverse:
X=inv(A)*B NORMAL EQUATIONS
b0
X mmult A= n
b0= 32.75822 *Use Ctrl+shift then press enter sum x1
b1= 1.03574 sum x2
b2= -1.517749 sum x3
b3= 0.046067

ANS: y= 32.7582 + 1.0357 x1 - 1.5177 x2 + 0.0461 x3

If values of x1, x2 & x3 are given, y can be obtained using the above equation.
x1 5.58
x2 8.5
x3 11.3
y 26.15733
rent concentrations using three
w. Find the multiple linear
ination and interpret the results.

R^2 Computation
SSR SST
x1*x3 x2*x3 x1*y x2*y x3*y yi^ (yi^-y_bar)^2 (yi-y_bar)^2
18.1955 54.225 40.317 120.15 321.735 28.04742 0.252587778 3.4225
64.8585 49.203 197.316 149.688 345.06 32.54448 15.95590482 14.8225
50.6155 64.3045 162.329 206.231 228.995 27.80149 0.560263387 2.1025
100.3275 37.3425 407.484 151.668 386.1 38.05215 90.29092789 122.1025
10.224 115.02 18.816 211.68 208.74 17.85145 114.4590206 80.1025
11.0385 56.3075 27.621 140.895 311.085 26.63261 3.676378006 0.4225
35.7975 53.835 106.812 160.632 255.3 28.35935 0.036347969 0.9025
63.0315 81.972 160.776 209.088 273.24 27.52209 1.056595584 4.6225
38.3075 36.019 125.125 117.65 323.375 31.70993 9.985151606 15.6025
40.964 71.06 100.744 174.76 268.565 26.97902 2.467972721 8.1225
238.7411503 252.225
433.36 619.2885 1347.34 1642.442 2922.195
R^2=
check first if coefficient matrix is non singular SSE=
det(A)= 173754.374 use mdeterm
-0.571619126 -0.48287658 -2.1797133 non zero --> non singular
0.0230594769 0.011133964 0.0393119 mtrix inverse exist
0.011133964 0.027828364 0.0258832
0.03931194 0.025883216 0.1803014
ft then press enter

b1 b2 b3 B
sumx1 sumx2 sumx3 sum(y)
sum x1^2 sum x1*x2 sum x1*x3 sum(x1*y)
sum x1*x2 sum x2^2 sum x2*x3 sum(x2*y)
sum x1*x3 sum x2*x3 sum x3^2 sum(x3*y)
(yi-y_bar)^2

good fit
0.94654 indicates the proportion of variation described by the three independent variables
13.48385
NON LINEAR REGRESSION
This is another interpolating method which can be used if there exists non linear relationship betwee

EXAMPLE 2 𝑦=𝑏_0+𝑏_1 𝑥+𝑏_2 𝑥^2


〖𝑥 =𝑥 〗 _1 10 15 20 25 30 35
y 26.3 30.6 31.9 31.2 31.8 30.3
n= 6
𝑥_2=𝑥^2 100 225 400 625 900 1225
〖𝑦𝑥〗 _1=𝑦𝑥 263 459 638 780 954 1060.5
〖𝑦𝑥〗 _2= 〖𝑦𝑥〗 ^2 2630 6885 12760 19500 28620 37117.5
〖𝑥 _1 𝑥 〗 _2=𝑥^3 1000 3375 8000 15625 27000 42875
𝑥_2^2=𝑥^4 10000 50625 160000 390625 810000 1500625
Normal Equations
b0 b1 b2 B inverse inv(A)
6 135 3475 182.1 9.371429 -0.887143 0.018571
135 3475 97875 4154.5 -0.887143 0.089071 -0.001929
3475 97875 2921875 107512.5 0.018571 -0.001929 4.286E-05
mmult X=inv(A)*B
b0 17.56286 NORMAL EQUATIONS
b1 1.153 b0 b1 b2
b2 -0.022714 A= n sumx1 sumx2
sumx1 sum x1^2 sum x1*x2
ANS 𝑦=17.56+21.153𝑥−0.0227𝑥^2 sumx2 sum x1*x2 sum x2^2

y=?
x= 40
y= 27.34
linear relationship between two variables.

SUM
135 r= 0.587634 nonlinear
182.1 R^2=

3475
4154.5
107512.5
97875
2921875

det(A)= 61250000
non singular
matrix inverse exists

B
sum(y)
sum(x1*y)
sum(x2*y)
y x1 x2 x3
26.7 1.51 4.5 12.05
32.4 6.09 4.62 10.65
27.1 5.99 7.61 8.45
39.6 10.29 3.83 9.75
19.6 0.96 10.8 10.65
27.9 0.99 5.05 11.15
27.6 3.87 5.82 9.25
26.4 6.09 7.92 10.35
32.5 3.85 3.62 9.95
25.7 3.92 6.8 10.45

SUMMARY OUTPUT

Regression Statistics
Multiple R 0.972903074
R Square 0.946540392
Adjusted R Squar0.919810588
Standard Error Standard Error
Observations 10

ANOVA
df SS MS F Significance F
Regression 3 238.7411503 79.58038344 35.41142274 0.000327441
Residual 6 13.48384967 2.247308278
Total 9 252.225

Coefficients Standard Error t Stat P-value Lower 95%


Intercept 32.75821544 7.918385322 4.136981734 0.006099169 13.38262456
X Variable 1 1.035739993 0.227643918 4.549825016 0.003892557 0.478715392
X Variable 2 -1.51774926 0.250077813 -6.069108 0.000908206 -2.12966762
X Variable 3 0.046067029 0.636547662 0.072370118 0.944659517 -1.51150899

RESIDUAL OUTPUT

Observation Predicted Y Residuals


1 28.04741888 -1.34741888
2 32.5444843 -0.1444843
3 27.80149256 -0.70149256
4 38.05215386 1.547846145
5 17.85144773 1.748552265
6 26.63261167 1.26738833
7 28.35934857 -0.75934857
8 27.52209165 -1.12209165
9 31.70992905 0.790070949
10 26.97902173 -1.27902173
Upper 95% Lower 95.0% Upper 95.0%
52.13380633 13.38262456 52.13380633
1.592764594 0.478715392 1.592764594
-0.90583089 -2.12966762 -0.90583089
1.603643046 -1.51150899 1.603643046
MULTIPLE LINEAR REGRESSION
SAMPLE PROBLEM

The survival rate of sperm (y %) from an animal semen was measured at different concentrations u
types of materials (x1, x2 & x3). The data obtained are given in the table below. Find the multiple li
regression model for the given data. Determine also the coefficient of determination and interpret
y x1 x2 x3
26.7 1.51 4.5 12.05
32.4 6.09 4.62 10.65
27.1 5.99 7.61 8.45
39.6 10.29 3.83 9.75
19.6 0.96 10.8 10.65
27.9 0.99 5.05 11.15
27.6 3.87 5.82 9.25
26.4 6.09 7.92 10.35
32.5 3.85 3.62 9.95
25.7 3.92 6.8 10.45

Estimate the % survival rate if x1= 5.58%, x2= 8.5% & x3= 11.3%.

EXAMPLE FIND: 𝑦=𝑏_0+𝑏_1 𝑥_1+𝑏_2 𝑥_2+𝑏_3 𝑥_3


n= 13
y x1 x2 x3 x1^2 x2^2 x3^2 x1*x2
1 26.7 1.51 4.5 12.05
2 32.4 6.09 4.62 10.65
3 27.1 5.99 7.61 8.45
4 39.6 10.29 3.83 9.75
5 19.6 0.96 10.8 10.65
6 27.9 0.99 5.05 11.15
7 27.6 3.87 5.82 9.25
8 26.4 6.09 7.92 10.35
9 32.5 3.85 3.62 9.95
10 25.7 3.92 6.8 10.45
y_bar
SUM=
n= 13
Normal Equations:
b0 b1 b2 b3 B inv(A)= minverse
A=
*Use Ctrl+shift then press enter
Matrix Inverse:
X=inv(A)*B NORMAL EQUATIONS
b0
X mmult A= n
b0= *Use Ctrl+shift then press enter sumx1
b1= sumx2
b2= sumx3
b3=

ANS:

If values of x1, x2 & x3 are given, y can be obtained using the above equation.
x1
x2
x3
y
rent concentrations using three
w. Find the multiple linear
ination and interpret the results.

SSR
x1*x3 x2*x3 x1*y x2*y x3*y yi^ (yi^-y_bar)^2

check first if coefficient matrix is non singular


det(A)= use mdeterm
non zero --> non singular
mtrix inverse exist
ft then press enter

b1 b2 b3 B
sumx1 sumx2 sumx3 sum(y)
sum x1^2 sum x1*x2 sum x1*x3 sum(x1*y)
sum x1*x2 sum x2^2 sum x2*x3 sum(x2*y)
sum x1*x3 sum x2*x3 sum x3^2 sum(x3*y)
SST
(yi-y_bar)^2

0
good fit
R^2= indicates the proportion of variation explained by the three independent variables
SSE=

non singular
y x1 x2 x3
26.7 1.51 4.5 12.05
32.4 6.09 4.62 10.65
27.1 5.99 7.61 8.45
39.6 10.29 3.83 9.75
19.6 0.96 10.8 10.65
27.9 0.99 5.05 11.15
27.6 3.87 5.82 9.25
26.4 6.09 7.92 10.35
32.5 3.85 3.62 9.95
25.7 3.92 6.8 10.45
NON LINEAR REGRESSION
This is another interpolating method which can be used if there exists non linear relationship betwee

EXAMPLE 2 𝑦=𝑏_0+𝑏_1 𝑥+𝑏_2 𝑥^2 y_bar


〖𝑥 =𝑥 〗 _1 10 15 20 25 30 35
y 26.3 30.6 31.9 31.2 31.8 30.3 30.35
n= 6
𝑥_2=𝑥^2 100 225 400 625 900 1225
〖𝑦𝑥〗 _1=𝑦𝑥 263 459 638 780 954 1060.5
〖𝑦𝑥〗 _2= 〖𝑦𝑥〗 ^2 2630 6885 12760 19500 28620 37117.5
〖𝑥 _1 𝑥 〗 _2=𝑥^3 1000 3375 8000 15625 27000 42875
𝑥_2^2=𝑥^4 10000 50625 160000 390625 810000 1500625
Normal Equations
b0 b1 b2 B inverse inv(A)
6 135 3475 182.1 9.371429 -0.887143 0.018571
135 3475 97875 4154.5 -0.887143 0.089071 -0.001929
3475 97875 2921875 107512.5 0.018571 -0.001929 4.286E-05
mmult X=inv(A)*B
b0 17.56286 NORMAL EQUATIONS
b1 1.153 b0 b1 b2
b2 -0.022714 A= n sumx1 sumx2
sumx1 sum x1^2 sum x1*x2
ANS 𝑦=17.56+21.153𝑥−0.0227𝑥^2 sumx2 sum x1*x2 sum x2^2

y=?
x= 40
y= 27.34

yi^ Sum
26.82142857143 29.74714 31.53714 32.19143 31.71 30.09286
RSS
12.45081632653 0.363437 1.409308 3.390859 1.8496 0.066122 19.53014
TSS
16.4025 0.0625 2.4025 0.7225 2.1025 0.0025 21.695
linear relationship between two variables.

SUM
135 r= 0.587634 nonlinear
182.1 R^2= 0.900214
6 90.02%
3475
4154.5
107512.5
97875 35
2921875
30
det(A)= 61250000
25
non singular
matrix inverse exists 20

15

B 10
sum(y)
5
sum(x1*y)
sum(x2*y) 0
1 2 3 4 5 6
4 5 6

You might also like