POLYMATH Report          REG 
 Multiple linear regression 2016-May-31 
Model: HardHeat = a0 + a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4

Variable Value 95% confidence
a0 60.8989 161.617
a1 1.56273 1.7178
a2 0.526503 1.6694
a3 0.112545 1.74072
a4 -0.126618 1.63541

R^2   R^2adj   Rmsd   Variance  
0.9823245    0.9734867    0.5322918    5.985442   

Source data points and calculated data points
  Wpc1 Wpc2 Wpc3 Wpc4 HardHeat HardHeat calc Delta HardHeat
1 7 26 6 60 78.7 78.6053 0.094703
2 1 29 15 52 74.3 72.8343 1.46572
3 11 56 8 20 104.3 105.941 -1.64111
4 11 31 8 47 87.6 89.3599 -1.75985
5 7 52 6 33 95.9 95.7131 0.186941
6 11 55 9 22 109.2 105.274 3.92608
7 3 71 17 6 102.7 104.122 -1.42238
8 1 31 22 44 72.5 75.688 -3.18805
9 2 54 18 22 93.1 91.6958 1.40424
10 21 47 4 26 115.9 115.62 0.280007
11 1 40 23 34 83.8 81.8053 1.9947
12 11 66 9 12 113.3 112.332 0.968368
13 10 68 8 12 109.4 111.709 -2.30936

Problem source text
# S. 31(a) - Multi-Linear Regression
# Heat of Hardening
# Verified Solution: a0 = 60.8989, a1 = 1.56273, a2 = 0.526503, a3 = 0.112545 , a4 = -0.126618
# Ref.: Comput. Appl. Eng. Educ. 17: 285, 1998
Wpc1 = [7, 1, 11, 11, 7, 11, 3, 1, 2, 21, 1, 11, 10]
Wpc2 = [26, 29, 56, 31, 52, 55, 71, 31, 54, 47, 40, 66, 68]
Wpc3 = [6, 15, 8, 8, 6, 9, 17, 22, 18, 4, 23, 9, 8]
Wpc4 = [60, 52, 20, 47, 33, 22, 6, 44, 22, 26, 34, 12, 12]
HardHeat = [78.7, 74.3, 104.3, 87.6, 95.9, 109.2, 102.7, 72.5, 93.1, 115.9, 83.8, 113.3, 109.4]
mlinfit Wpc1 Wpc2 Wpc3 Wpc4 HardHeat

Matlab formatted problem
Create m file called PolyReg.m and paste the following text into it.
% S. 31(a) - Multi-Linear Regression
% Heat of Hardening
% Verified Solution: a0 = 60.8989, a1 = 1.56273, a2 = 0.526503, a3 = 0.112545 , a4 = -0.126618
% Ref.: Comput. Appl. Eng. Educ. 17: 285, 1998
function PolyReg
   clc;
   % Known vectors
   Wpc1 = [7; 1; 11; 11; 7; 11; 3; 1; 2; 21; 1; 11; 10];
   Wpc2 = [26; 29; 56; 31; 52; 55; 71; 31; 54; 47; 40; 66; 68];
   Wpc3 = [6; 15; 8; 8; 6; 9; 17; 22; 18; 4; 23; 9; 8];
   Wpc4 = [60; 52; 20; 47; 33; 22; 6; 44; 22; 26; 34; 12; 12];
   HardHeat = [78.7; 74.3; 104.3; 87.6; 95.9; 109.2; 102.7; 72.5; 93.1; 115.9; 83.8; 113.3; 109.4];
   % Derived vectors
   % Evaluate regression coefficients
   X = [Wpc1.^0 Wpc1 Wpc2 Wpc3 Wpc4];
   [beta,bint,~,~,stats] = regress(HardHeat,X);
   fprintf('Regression model: HardHeat = a0 + a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4\n');
   disp([' a0 ' num2str(beta(1,1),'%0.5g') ' Conf. interv.= ' num2str(bint(1,2)-beta(1,1),'%0.5g')]);
   disp([' a1 ' num2str(beta(2,1),'%0.5g') ' Conf. interv.= ' num2str(bint(2,2)-beta(2,1),'%0.5g')]);
   disp([' a2 ' num2str(beta(3,1),'%0.5g') ' Conf. interv.= ' num2str(bint(3,2)-beta(3,1),'%0.5g')]);
   disp([' a3 ' num2str(beta(4,1),'%0.5g') ' Conf. interv.= ' num2str(bint(4,2)-beta(4,1),'%0.5g')]);
   disp([' a4 ' num2str(beta(5,1),'%0.5g') ' Conf. interv.= ' num2str(bint(5,2)-beta(5,1),'%0.5g')]);
   disp(' Regression Statistics ');
   disp([' Correlation Coefficient R^2 = ' num2str(stats(1))]);
   disp([' Variance = ' num2str(stats(4))]);
   HardHeat_calc = [Wpc1.^0 Wpc1 Wpc2 Wpc3 Wpc4]*beta;
   % Regression plot
   plot (HardHeat, HardHeat_calc, 'bo');
   xlabel('HardHeat');
   ylabel('HardHeatCalc');
   hold on;
   plot (HardHeat, HardHeat, 'r-');
   hold off;
   % Residuals plot
   figure;
   plot (HardHeat, HardHeat-HardHeat_calc, 'ks');
   xlabel('HardHeat');
   ylabel('HardHeat-HardHeatCalc');
end

General Settings
Number of independent variables = 4
Regression including a free parameter
Number of observations = 13