Professional Documents
Culture Documents
Explaination and Analysis
Explaination and Analysis
0 Explanation
Number 1
Number 2
y=[25; 37; 49; 62; 74; 83; 95; 105; 121; 135; 150]
Number 3
plot(x,y,'o');
Number 4
xlabel('X');
Number 5
ylabel('Y');
Number 6
xi=x.^2;
Number 7
Xy=x*y
Number 8
totalx=sum(x)
Number 9
totaly=sum(y)
Number 10
totalxi=sum(xi)
Number 11
totalxy=sum(xy)
Number 12
powertotalx = totx.^2
Number 13
n=11
Number 14
a1 = ((n.*totalxy)-(totalx*totaly))/((n.*totalxi)-(powertotalx))
Number 15
ybar = mean(y)
Number 16
ybar = mean(y)
Number 17
a0 = (ybar)-(a1.*xbar)
Number 18
Sr = sum((y-a0-a1.*x).^2)
Number 19
St = sum((y-ybar).^2)
Number 20
Syx = sqrt(Sr/(n-2))
Number 21
r2 = (St-Sr)/(St)
Number 22
p = polyfit (x,y,1);
Number 23
xp = 0:5:25;
Number 24
yp = polyval(p,xp);
Number 25
plot (x,y,'o',xp,yp);
Number 26
p = polyfit(x,y,2);
Number 27
xp = 0:5:25;
Number 28
yp = polyval(p,xp);
Number 29
plot(x,y,'o',xp,yp);
We started by write the in the command window which we write the coding vector of ‘x’ and
‘y’ as shown in Number 1 and 2. We received a set of 11 different coordinate of the data in each
vector. After that, we used coding in Number 3 to plot the graph and the coding in Number 4 and 5
to determine the titles in horizontal axis and vertical axis in the graph. Next, we used the coding in
Number 6 until 12 as a formula in order to calculate the value of ‘a1’. We also declare n as 11
because of the amount of coordinate we received is 11 which will be used in Number 12 and 13
which is to calculate the arithmetic mean. After that we used the value to find the ‘a0’ which the
formula is stated in Number 17.
After that, we used the formula in Number 18 to find the sum of the square residual, Sr and
St which is the error of regression that is in Number 19. The value of Sr and St is used to calculate the
standard error of estimate, Sy/x and r2 which is the coefficient of determination. These value is
crucial for analysis. To start with the polynomial, we used polyfit function in Number 22 to obtain
the value of polynomial. Coding in Number 24 shows that the vector ‘yp’ which is the valuemof
polynomial at each vector ‘xp’ which has been declare in coding Number 23. Lastly, we used coding
in 29 to plot the graph using the data that has been calculate.
We have two different graph which differs by the degree of polynomial which is n=1 and
n=2. The analysis of the graph is shown below.
Analysis
The graph plot in Task 3 in the least square regression model using degree pf polynomial
(n=1)
The graph plot in Task 5 in the least square regression model using degree pf polynomial
(n=2)
Standard error of estimate, Sy/x =2.3868