Understanding Multiple Linear Regression Easily (Part 2: Calculating the Coefficient of Determination Manually)

Understanding Multiple Linear Regression Easily (Part 2: Calculating the Coefficient of Determination Manually)


Understanding Multiple Linear Regression Easily (Part 1: Calculating the Regression Equation Manually)


In the previous post, we explained how to manually calculate the regression equation in multiple linear regression analysis. Now, in this post, I will explain how to calculate the coefficient of determination (R2) in multiple linear regression analysis.


No.Yield (yi)Time (xi1)Moisture (xi2)
14.340.2
25.550.2
36.860.2
48.070.2
54.040.3
65.250.3
76.660.3
87.570.3
92.040.4
104.050.4
115.760.4
126.570.4

To calculate the coefficient of determination (R2), we need to compute simple linear regression equations for each independent variable (x). When analyzing the linear regression equations for Time and Moisture respectively, you can obtain the following results:

### Yield in response to time
model= lm (yield ~ time, data=dataA)
summary(model)

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  -1.7333     1.1652  -1.488    0.168    
time          1.3167     0.2076   6.342 8.44e-05 ***

### Yield in response to moisture
model= lm (yield ~ moisture, data=dataA)
summary(model)

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)    7.908      1.818   4.350  0.00144 **
moisture      -8.000      5.847  -1.368  0.20119   

Therefore, 
Time: ŷi=-1.73 + 1.31 xi1
Moisture: ŷi=7.9 - 8.0* xi2

Next, I will use each of these regression equations to partition the data.



1) Time

No.Yield
(yi)
Time
(xi1)
Time:
ŷi=-1.73+1.31xi1
Data:
(yi - ȳ)2
Fit:
i - ȳ)2
Error:
i - yi)2
14.343.531.53.90.6
25.554.850.00.40.4
36.866.171.70.40.4
48.077.486.23.90.3
54.043.532.33.90.2
65.254.850.10.40.1
76.666.171.20.40.2
87.577.484.03.90.0
92.043.5312.33.92.4
104.054.852.30.40.7
115.766.170.00.40.2
126.577.481.03.91.0
Meanȳ= 5.5SST:
Σ(yi - ȳ)2
32.5
SSR:
Σ(ŷi - ȳ)2
26.0
SSE:
Σ(ŷi - yi)2
6.5

2) Moisture

No.Yield
(yi)
Moisture
(xi1)
Moisture:
ŷi=7.9-8.0*xi2
Data:
(yi - ȳ)2
Fit:
i - ȳ)2
Error:
i - yi)2
14.30.26.311.50.64.0
25.50.26.310.00.60.7
36.80.26.311.70.60.2
48.00.26.316.20.62.9
54.00.35.512.30.02.3
65.20.35.510.10.00.1
76.60.35.511.20.01.2
87.50.35.514.00.04.0
92.00.44.7112.30.67.3
104.00.44.712.30.60.5
115.70.44.710.00.61.0
126.50.44.711.00.63.2
Meanȳ= 5.5SST:
Σ(yi - ȳ)2
32.5
SSR:
Σ(ŷi - ȳ)2
5.1
SSE:
Σ(ŷi - yi)2
27.3


Now, let’s create an ANOVA table.

SourcedfSSMSFp-value
Model2SSR: 26.0 +5.1 = 31.131.1 / 2 =15.615.6 / 0.1 = 104.1<.001
Error9SSE: 32.5 – 31.1 = 1.31.3 / 9 = 0.1
Total11SST: 32.532.5 / 11 = 2.95

Then, the coefficient of determination (R^2) is calculated using the following formula:

31.1 / 32.5 ≈ 0.96


Leave a Reply

If you include a website address in the comment section, I cannot see your comment as it will be automatically deleted and will not be posted. Please refrain from including website addresses.