Method of Least Squares (Least Squares Regression):
-
Upload
kyla-price -
Category
Documents
-
view
60 -
download
8
description
Transcript of Method of Least Squares (Least Squares Regression):
![Page 1: Method of Least Squares (Least Squares Regression):](https://reader036.fdocuments.us/reader036/viewer/2022082407/56813251550346895d98d070/html5/thumbnails/1.jpg)
Method of Least Squares (Least Squares Regression):
x y
-5 -2
2 4
7 3.5
y=a+bx
n
1i
2ii )bxay(q : Sum of squares of errors
0)bxay(20a
qii
0)bxay(x20b
qiii
ii
i2ii
i
yx
y
b
a
xx
xn
6. Method of Least Squares: (pp. 1001)
5.42
5.5
b
a
784
43
5.42
5.5
34
478
218
1
b
a a=1.188 b=0.484
y=1.188+0.484x
Examp 6.1:
![Page 2: Method of Least Squares (Least Squares Regression):](https://reader036.fdocuments.us/reader036/viewer/2022082407/56813251550346895d98d070/html5/thumbnails/2.jpg)
Sub mlsquares_Click ()' Change File mls.txt for different problems' y=a+b*x fl = fl0 + "mls.txt": Open fl For Input As 1Input #1, n: ReDim x(n), y(n) For i = 1 To n: Input #1, x(i), y(i): Next i Close #1 Call cls1: Print n: Print For i = 1 To n: Print x(i), y(i): Next i: Print a11 = n: a12 = 0: a22 = 0: b1 = 0: b2 = 0 For j = 1 To n a12 = a12 + x(j) a22 = a22 + x(j) ^ 2 b1 = b1 + y(j) b2 = b2 + x(j) * y(j) Next j a21 = a12 det = (a11 * a22 - a12 * a21) a = (a22 * b1 - a12 * b2) / det b = (-a21 * b1 + a11 * b2) / det Print : Print " A, B : ", a, bEnd Sub
3-5,-22,47,3.5
mls.txt
![Page 3: Method of Least Squares (Least Squares Regression):](https://reader036.fdocuments.us/reader036/viewer/2022082407/56813251550346895d98d070/html5/thumbnails/3.jpg)
x y
0 200
3 230
5 240
8 270
10 290
y=a+bx
ii
i2ii
i
yx
y
b
a
xx
xn
6950
1230
b
a
19826
265
6950
1230
526
26198
314
1
b
a
y=200.13 + 8.82x
Examp 6.2: