By: Prof. Y. Peter Chiu 9 / 20 / 2010

34
1 By: Prof. Y. Peter By: Prof. Y. Peter Chiu Chiu 9 / 20 / 2010 9 / 20 / 2010 Chapter 2 - B 預預

description

Chapter 2 - B 預測. By: Prof. Y. Peter Chiu 9 / 20 / 2010. §. F16: 趨勢方法(1)線性 迴 歸分析. 假設數據 (x 1 , y 1 ) , (x 2 , y 2 ) ,…, (x n , y n ) 有如下的線性關係為 Y=a+bX 定義 [16.1] 我們的目標是決定 a & b ,以使 g(a,b) 最小化 。. Fig.2-7 p.75. . . (1) 線性迴歸分析. [16.2(a)] [16.2(b)]. . . [16.3(a)] - PowerPoint PPT Presentation

Transcript of By: Prof. Y. Peter Chiu 9 / 20 / 2010

Page 1: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

1

By: Prof. Y. Peter Chiu By: Prof. Y. Peter Chiu

9 / 20 / 2010 9 / 20 / 2010

Chapter 2 - B

預測

Page 2: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

2

§. F16:§. F16: 趨勢方法(趨勢方法( 11 )線性迴歸分析)線性迴歸分析 假設數據 (x1 , y1) , (x2 , y2) ,…, (xn , yn) 有如下的線性關係為 Y=a+bX 定義 [16.1]

我們的目標是決定 a & b,以使 g(a,b) 最小化。

n

1i

2ii bxay)b,a(g

0bxayx2

b

g

0bxay2a

g

0b

g&0

a

g

n

1iiii

~

n

1iii

~

Page 3: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

3

Fig.2-7 p.75

Page 4: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

4

n

1i

2i

n

1ii

n

1iii

n

1ii

n

1ii

xbxayx

xbany [16.2(a)]

[16.2(b)]

n

x i

2iiii

2iiii

xbnxanyxn

xbxanyx[16.3(a)]

[16.3(b)]

2

i

2

iiiiixxnbyxyxn

16.3(b)-16.3(a)

[16.4]

(1)(1) 線性迴歸分析線性迴歸分析

Page 5: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

5

22

xy i i i i

xx i i

S n x y x y

S n x x

[16.5(a)]

[16.5(b)]

xx

xy

xxxy

S

Sb

SbS

[16.6]

[16.7]

從 16.2(a)

n

1ii

n

1ii xbany

xbya

n

xb

n

ya

n

1ii

n

1ii

其中

i

i

xn

1x

yn

1y

定義

[16.8]

[16.9]

Page 6: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

6

§. F17:§. F17: 線性預測分析的應用線性預測分析的應用x 週期 t

y 需求量 即 Di

Data: (1,D1) , (2,D2) , …, (n,Dn)

[17.1]

tbaD̂t

6

1n21nnn321tx

2

1nnn321tx

222n

1i

2i

2i

n

1i

n

1iii

Page 7: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

7

From 16.5(a)

1 1

1

2

xy i i i i

n n

i ii i

S n x y x y

n nn i D D

22

2

2

2

1 2 1 1

6 4

xx i i

n n

S

n

n x

n n

x

From 16.5(b)

From 16.7xx

xy

S

Sb

From 16.9

2

1nbDa

2

1n

n

x

2

1nnx

Page 8: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

8

Example 17.1Example 17.1

如何利用迴歸分析求解n=4

QTR FAILURES FORECAST 1 175 2 186 Trend-Based 3 225 4 285 5 ?

n

1ii

n

1iixy D

2

1nnDinS

4

1nn

6

1n21nnS

222

xx

xx

xy

S

Sb

2

1nbDa

tbaD̂t

Page 9: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

9

73887109448

2852251861752

144

28542253186217514Sxy

201001204

144

6

18144S

222

xx

73836.9

20xy

xx

Sb

S

1217.75 92.25 125.5

2

na D b

5 125.5 36.9 5ˆ 310D a b t ?D̂D̂ 6t 重新計算 ... (當 D5 存在時)

Page 10: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

10

§. F18 : §. F18 : 課堂問題探討 課堂問題探討

Chapter 2 : Chapter 2 : [ [ # 28 (b), (c), (d)(d) ] ] pp.76-77

Preparation Time : 20 ~ 25 minutesPreparation Time : 20 ~ 25 minutes Discussion : 10 ~ 15 minutesDiscussion : 10 ~ 15 minutes

Page 11: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

11

§. F19:§. F19: 趨勢方法 趨勢方法 (2) Holt’s(2) Holt’s 的雙重指數平滑方法的雙重指數平滑方法

(1) 適用於時間序列具有線性趨勢 (2) α,β

(3) 截距及斜率 St=αDt+(1-α)(St-1+Gt-1) [19.1]

Gt=β(St-St-1)+(1-β)Gt-1 [19.2]

(4) Ft,t+τ=St+τ . Gt [19.3]

Ft,t+1 =St+Gt

Ft+1 =St+Gt

=Ft=

Page 12: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

12

Example 19.1 /Example 19.1 / 解決方案解決方案

使用 Holt’s method 的雙重指數平滑方法 QTR Failure Forecast (D.E.S) Error∣ ∣ 1 175 2 186 193.9 7.9 3 225 202.9 22.1 4 285 215.1 69.9 5 305 232.8 72.2 6 190 251.4 61.1

假設 S0=175 & G0=10 ; α=0.1 β=0.1

S1=αDt=1+(1-α)(S0+G0)

=(0.1)(175)+(0.9)(175+10)=184

G1=β(S1-S0)+(1-β)G0

=(0.1)(184-175)+(0.9)(10)=9.9

Page 13: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

13

F2=F1,2=F1,1+1=S1+1 . G1=193.9

S2=αD2+(1-α)(S1+G1)

=(0.1)(186)+(0.9)(184+9.9)=193.1

G2=β(S2-S1)+(1-β)G1

=(0.1)(193.1-184)+(0.9)(9.9)=9.8

F3=S2+1 . G2=202.9

S3=αD3+(1-α)(S2+G2)

=(0.1)(225)+(0.9)(202.9)=205.1

G3=β(S3-S2)+(1-β)G2

=(0.1)(205.1-193.1)+(0.9)(9.8)=10.0

F4=S3+1 . G3=215.1

S4= (0.1)(285)+(0.9)(215.1)=222.1

G4= (0.1)(222.1-205.1)+(0.9)(10.0)=10.7

解決方案解決方案19.1 :19.1 :

Page 14: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

14

QTR MA(3) ε ∣ ∣ ES(0.1) ε ∣ ∣ D.E.S.(0.1,0.1) ε∣ ∣

4 285 195 90 203 82 215.1 69.9

5 305 232 73 211 94 232.8 72.3

6 190 272 82 220 30 251.4 61.1

245 206 203.3

MAD=81.7 68.7 67.7

MSE=6717 5487 4611

Last

3 QTR

F5=S4+1 . G4=232.8

S5= (0.1)(305)+(0.9)(232.8)=240

G5= (0.1)(240-222.1)+(0.9)(10.7)=11.4

F6=240+11.4=251.4

Solution 19.1 :Solution 19.1 :

Page 15: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

15

D.E.S. Retry α=0.1 β=0.1QTR Failure 預測 (D.E.S) ε∣ ∣ 1 175 2 186 3 225 S0=225 G0=25 4 285 (F1=) 250 35 5 305 (F2=) 278.9 26.1 6 190 (F3=) 307.2 117.2

Why not let S0=225 & G0=25

F1=S0+1G0=225+25=250

S1=αDt=1+(1-α)(S0+G0)

=(0.1)(285)+(0.9)(250)=253.5

G1=β(S1-S0)+(1-β)G0

=(0.1)(253.5-225)+(0.9)(25)=25.4

Example Example 19.219.2 / solution

→[(225-186)+(186-175)]/2

Page 16: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

16

F2=S1+1 . G1=253.5+25.4=278.9

S2=(0.1)(305)+(0.9)(278.9)=281.5

G2=(0.1)(281.5-253.5)+(0.9)(25.4)=25.7

F3=281.5+25.7=307.2

QTR Failure MA(3) ES(0.1) D.E.S.(0.1,0.1)

285 195 203 250

305 232 211 278.9

190 272 220 307.2

MAD= 81.7 68.7 59.4

MSE= 6717 5487 5214

Last

3 QTR

Solution 19.2 :Solution 19.2 :

Page 17: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

17

§. F20 :§. F20 : 課堂問題探討 課堂問題探討

Chapter 2 : Chapter 2 : ( ( # 30, , 3131, , 3232 ) ) p.78

Preparation Time : 20 ~ 30 minutesPreparation Time : 20 ~ 30 minutes Discussion : 15 ~ 20 minutesDiscussion : 15 ~ 20 minutes

Page 18: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

18

§. F22:§. F22: 平穩型季節性系列的預測方法平穩型季節性系列的預測方法~ N 期間 (N≧3)

(2) 將每個 xi 除以 μ ~及個別的季節性因素 .

for all xi [22.2]

(1) 由所有實際數據計算 μ

[22.1]n

xi

i

ix

f

(3) 同一每個在季節的因子平均值

[22.3]

Nn

1)N/n(

0jjNi

]N,1[i

ffiAvg

(4) 做預測 : Fi = fi * μ for i [1 , N] [22.4]_

_

Page 19: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

19

Fig.2-8 p.79

Page 20: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

20

Example 2.6Example 2.6 p. 80

某縣交通部門想要確定一日收費橋樑連接城市的不同地區使用率。在目前的研究中,他們是只考慮有上班的日子。假設汽車通過該橋梁的數量,在過去四周每個工作日分別為(單位:千車)

求橋梁日使用率的季節性因子該為何?

Page 21: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

21

4

ffAvg]3.22[ From)3(

3

0jj5i

i

425.16

nx

]1.22[ From )1( i

i

i

xf]2.22[From)2(

N=5 , n=20

For i = 1, 2, …, 5

E 2.6 / solution :E 2.6 / solution :

Page 22: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

22

μ=16.425

Mon. 0.98Tue. 0.74Wed. 0.84Thr. 1.04Fri. 1.40 Σ=5=N

Mon. 16.425*0.981=16.1Tue. 12.1Wed. 13.8Thr. 17.1Fri. 23.0

(4) From [22.4] Forecast Fi :

E 2.6 / solution :E 2.6 / solution :

Page 23: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

23

§. F23 :§. F23 : 課堂問題探討 課堂問題探討

Chapter 2 : Chapter 2 : ( # 33 ( # 33 )) p.83

Preparation Time : 5 ~ 10 minutesPreparation Time : 5 ~ 10 minutes Discussion : 5 minutesDiscussion : 5 minutes

Page 24: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

24

THE ENDTHE END

Page 25: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

25

§. F24:§. F24: 季節性因子分解法(利用移動平季節性因子分解法(利用移動平均數計算)均數計算)(1) 確定季節長度為 N (e.g. N=4) & 計算

MA(N).

(2)MA(N) 值為中心

(3) 估計前面遺漏的週期之數據 (eg. 1,2) 與結束週期之數據 (eg. 7,8)(4) 求取季節性因子即每個時期的實際需求除

以 MA 需求(5) 平均所對應的同期季節的季節性因子 .

單 雙

◇◇

Page 26: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

26

(7) 求取剔除季節性因子後的需求 : (Di / fi )

(8) 做預測依據剔除季節性因後系列 (9) Re-seasonalize after your forecasts are done

in (8) (重置季節性效應) : (Fj )* fi

_

_

__

Period Fi

1 0.558 2 1.061 3 1.415 4 0.966

(6) 季節性因子的常態化

§.§. F24 F24 ◇◇

Page 27: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

27

N=4 MA(4)∴

Perrod Demand MA(4)

1 10

2 20

3 26

4 17

5 12 18.25

6 23 18.72

7 30 19.50

8 22 20.50

Example 2.7 Example 2.7 看課本看課本 …… p.81p.81

◇◇

Page 28: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

28

§. F25 :§. F25 : 課堂問題探討 課堂問題探討

Chapter 2 : Chapter 2 : ( # ( # 3434 a,b,c,d ) a,b,c,d ) p.84

Preparation Time : 15 ~ 20 minutesPreparation Time : 15 ~ 20 minutes Discussion : 10 ~ 15 minutesDiscussion : 10 ~ 15 minutes

◇◇

Page 29: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

29

Fig.2-10 p.85 ◇◇

Page 30: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

30

§.F26§.F26 :應用溫特斯法:應用溫特斯法 Winter’sWinter’s於季節性且含上升趨勢系列 於季節性且含上升趨勢系列

Nc

term error:εt period incomponent seasonal tivemultiplica:c

Slope:G0t timeat Intercept :

c) t G(D

t

t

t

ttt

◆ 三重指數平滑

◇◇

Page 31: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

31

1. 系列

2. 趨勢因素

3. 季節性因子

做預測

)()( 1t1tNt

tt GS) α(1

C

D α S

1t1ttt β)G(1]Sβ[SG

Ntt

tt )C(1)

SD

( C γγ

NτttTtτtt, )cG(SF

§.F26§.F26 :: WintersWinters 的方法 的方法 – – 三重指數平滑三重指數平滑◇◇

Page 32: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

32

§.F26§.F26 :溫特斯法 :溫特斯法 (p.3)(p.3)

◆◆初始化程序初始化程序 (by Winters)(by Winters) ●●系列系列 : S: S00

● ●坡度坡度 : G: G0

● ●季節性因子季節性因子 : C: Ctt

◆ ◆ 計算計算◆ ◆ 平均平均◆ ◆ 標準化標準化

◆ ◆ 預測 預測 ::NτttTtτtt, )cG(SF

◇◇

Page 33: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

33

§.§. F27 : F27 : 問題探討問題探討

Chapter 2 : Chapter 2 : ( ( # 35 a, b, c# 35 a, b, c ) )

( ( # 36# 36 ) ) p.89p.89

Preparation Time : 20 ~ 25 minutesPreparation Time : 20 ~ 25 minutes

Discussion : 15 ~ 20 minutesDiscussion : 15 ~ 20 minutes

◇◇

Page 34: By:  Prof. Y. Peter Chiu    9 / 20 / 2010

34

THE ENDTHE END