Professional Documents
Culture Documents
Assignment Responsion 08 Linear Regression Line: By: Panji Indra Wadharta 03411640000037
Assignment Responsion 08 Linear Regression Line: By: Panji Indra Wadharta 03411640000037
Assignment Responsion 08 Linear Regression Line: By: Panji Indra Wadharta 03411640000037
By:
PANJI INDRA WADHARTA
03411640000037
1.1 Background
Numerical methods are technique by which mathematical problems are
formulated so that they can be solved with arithmetic and logical operations.
Because digital computers excel at performing such operations, numerical
methods are sometimes referred to as computer mathematics. Under the traditional
teaching mode, the complex equations take a long time to be solved, and need
calculator to get precise answer. Some of students are not easy to understand.
From the above, the course of numerical problem tends to have the problems that
rather difficult to understand and abstract, lack of interest and so on.
MATLAB is an essential numerical calculation and graphics processing
software by MathWorks company launched in 1984, and also one of the world's
most widely used scientific computing software nowadays. It has a powerful
scientific computing and data visualization function and integrates a variety of
toolboxs for different areas. Using MATLAB simulation becomes one of the
effective ways to solve the above problems. The objective in this paper to
illustrate the linear regression line with the matlab code that create by myself. The
descriptive will be presented too, in the sections below.
1.3 Objective
The objective are to create the matlab code and minimize the error
estimate with Matlab.
CHAPTER II
LITERATURE
Σ(y−yˆ)2Σ(y−y^)2
The data used in this research is data on age and value of used
automobiles. After that, we compute the sum of x, y, and xy, x2 in Excel.
Table 3.1. Data on age and value of used automobiles
Age Value
(x) (y)
28.7 2
24.8 3
26 3
30.5 3
23.8 4
24.6 4
23.8 5
20.4 5
21.6 5
22.1 6
3.2 Flowchart
The flowchart for algorithm matlab code is:
clear all
clc
x = [28.7 24.8 26 30.5 23.8 The data set of age (x) and value automobile
24.6 23.8 20.4 21.6 22.1]; (y)
y = [2 3 3 3 4 4 5 5 5 6];
n = length(x);
ssxx = sum(x,'all')^2 -
(1/n)*(sum(x,'all')^2); Calculate the ssxx, ssxy, ssy
ssxy = sum(x,'all')* sum(y, SSxx = Σx2−(1/n)(Σx)2,
'all') - Ssxy = Σxy−(1/n)(Σx)(Σy)
(1/n)*sum(x,'all')*sum(y, SSyy = Σy2−(1/n)(Σy)2,
'all');
ssyy = sum(y,'all')^2 -
(1/n)*sum(y, 'all')^2;
Calculate the mean of data x and y
x_ = mean(x);
y_ = mean(y);
Calculate the parameter b1 and b0 for
b1 = ssxy/ssxx; searching the regression line
b0 = y_ - b1*x_;
Input the parameter b1 and b0 for equation
Y = b1*x + b0; regression line y = b1*x+b0
4.2 Result
Based on the script that made by myself, the generate error is appear in
command window as variable ‘error’. The value is 4.5475e-13, which is show a
very small number. So, we can say that the script is correct, with algorithm used
based on literature. The trend of the line is positive because its up significant to
the right, means the strong correlation between data. The plot of regression linear
and data is:
Figure 4.1. Plot Regression Line and Scatter Plot Data
Cohen, J., Cohen P., West, S.G., & Aiken, L.S. (2003). Applied multiple
regression/correlation analysis for the behavioral sciences. (2nd ed.) Hillsdale,
NJ: Lawrence Erlbaum Associates