Method of Least Squares (Least Squares Regression):

3
Method of Least Squares (Least Squares Regression): x y -5 -2 2 4 7 3.5 y=a+bx n 1 i 2 i i ) bx a y ( q : Sum of squares of errors 0 ) bx a y ( 2 0 a q i i 0 ) bx a y ( x 2 0 b q i i i i i i 2 i i i y x y b a x x x n 6. Method of Least Squares: (pp. 1001) 5 . 42 5 . 5 b a 78 4 4 3 5 . 42 5 . 5 3 4 4 78 218 1 b a a=1.188 b=0.484 y=1.188+0.48 4x Examp 6.1:

description

6. Method of Least Squares:. (pp. 1001). Method of Least Squares (Least Squares Regression):. Examp 6.1:. : Sum of squares of errors. y=a+bx. a=1.188 b=0.484. y=1.188+0.484x. mls.txt. 3 -5,-2 2,4 7,3.5. Sub mlsquares_Click () ' Change File mls.txt for different problems ' y=a+b*x - PowerPoint PPT Presentation

Transcript of Method of Least Squares (Least Squares Regression):

Page 1: Method of Least Squares (Least Squares Regression):

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):

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):

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: