Chap13 時間序列模式
• 時間序列是指按時間有順序排列的一串資 料,如每月物價,每年產值,等
• 影響時間序列變化有四個成因:
1. Trend :長期向上或向下的移動趨勢
2. Seasonal variation :以年為基礎的變動原型
3. Cycle :在2到10年中向上或向下的改變(日本地震週期)
第三節 自我相關
• 探討誤差項之間的相關性不為零的情形 σij ≠ 0, for i ≠ j
• 就是變異數矩陣中,非對角線元素不為零的狀況
NN N N
...
...
...
...
...
...
...
...
...
)
var( 12 22 2
1 12
11
使用迴歸來分析時間序列資料時,誤差項可能依時間先後有 相關性,此稱為自相關現象 (autocorrelation),此種資料違背
獨立性的情況,會表現在殘差圖上,需修正模式。
【例】 X:產品年銷售量(salec),Y:某公司的年銷售量
殘差圖
s階 自相關係數(Lag=s)
• 迴歸模式的自我相關(autocorrelation)是指誤差項 前後期彼此相關
• 定義:
– 自相關共變異數:
– s 階自相關係數:
) ,
s cov(t ts
0
s var( )
) ,
) cov(
,
(
s
t s t t s
t
cor t
注意: ρs ρs
資料的自相關現象對迴歸分析結果產生下列現象:
1. 係數的估計量仍為不偏,但無法達到最小變異數。
2. MSE低估真實的誤差變異數。
3. s.e.{bk}低估係數之標準差。
4. t-test,F-test,及confidence interval 無法再直接應用。
一階自相關
• first-order autocorrelation:連續二資料間的相關性,
即εt 與 εt-1 間之相關性
• 與位置無關,ρ1 = cor(εt , εt-1 ) for all t
• 如何檢測出一階自相關?
1. 觀察殘差圖
2. Durbin-Watson 檢定
(εt 與 εt-1 間相關,將反應在 et 與 et-1 間 )
2
1 2
2 1) (
D
t n
t n
t
t t
e e e
et Yt Yˆt
Durbin-Watson 統計量:
自相關的檢定 -- Durbin-Watson Test
註:1、 D ≒ 2(1-r1),0≦D≦4
2、SAS/EG 之 迴歸 / 線性迴歸 或 時間序列/ 誤差為自我迴歸 提供 D-W 值
3、檢定法則:依據 n, p, α查出 dL,α及 dU,α
ρ1>0 ρ1=0 ρ1<0
不確定區
正的自相關檢定 H0 :ρ1= 0, H1 :ρ1> 0 決策
1. D < dL,α時,拒絕 H0 2. D > dU,α時,不拒絕 H0
3. dL,α <D < dU,α時,無法定論,(需要更多資料)
n 15 20 25 30 35 40 45 50 60
dL.05 1.08 1.2 1.29 1.35 1.4 1.44 1.48 1.5 1.55
dU.05 1.36 1.41 1.45 1.49 1.52 1.54 1.57 1.59 1.62
0 dL dU 2 4-dU 4-dL 4
臨界值
負的自相關檢定 H0 :ρ1= 0,H1:ρ1<0
1. (4-D) < dL,α時,拒絕 H0 2. (4-D) > dU,α時,不拒絕 H0
3. dL,α < (4-D) < dU,α時,無法定論,(需要更多資料) 決策
注意: r1 >0 ,0< D < 2, r1 < 0 ,2< D < 4 r1 =ρ1-估計值
【例】 X:產品年銷售量(salec)
Y:某公司的年銷售量 (salei) X-Y 分散圖 殘差圖
SAS/EG / regression/ linear 報表
Durbin-Watson D 3.050
Number of Observations 20
1st Order Autocorrelation -0.531 Parameter Estimates
Variable Label DF Parameter Estimate
Standard Error
t Value Pr > |t|
Intercept Intercept 1 8.42066 1.14606 7.35 <.0001 saleC saleC 1 5.66585 0.04643 122.02 <.0001
Root MSE 0.48788 R-Square 0.9988
Dependent Mean 147.62500 Adj R-Sq 0.9987
Coeff Var 0.33048
(dL=1.2. dU=1.36)
First-order autocorrelative reg. model
ρ為一階自相關係數,代表自相關程度之大小。
AR(1) Model :
Yt = β0 + β1 xt + εt , t= 1,2,…, n
εt = ρ εt-1 + u t , |ρ|<1, u t ~NID(0,σ2)
工作 → 時間序列→ 自我迴歸誤差
如何修正含自相關現象的迴歸模式?
有多種方法,最常用的是 AR(1) errors model, 即,假設迴 歸式中的誤差項是一 AR(1) model.
SAS tip
共變異矩陣:
2 2
1 2
1
1 2
1
2
2 , where
...
...
...
...
...
..
...
}
{
n
n
n n
n
註 : 1、期望值=0
2、ρ愈大,影響愈遠。
ρ( ), ε }
, {ε
, }
σ {ε
0, }
E{ε
2 2 2
2
ρ 1
σ 1
t ρ t
1 σ t
2 t
Ordinary Least Squares Estimates
SSE 4.28442909 DFE 18
MSE 0.23802 Root MSE 0.48788
SBC 31.9341066 AIC 29.942642
Regress R-Square 0.9988 Total R-Square 0.9988
Durbin-Watson 3.0689
Variable DF Estimat e
Standard Error
t Value Approx Pr > |t|
Variable Label
Intercept 1 8.4207 1.1461 7.35 <.0001
saleC 1 5.6659 0.0464 122.02 <.0001 saleC
【例】 X:產品年銷售量(saleC)
Y:某公司的年銷售量 (salei)
執行 Time series / Reg. w Autoregressive Errors 報表
Preliminary MSE 0.1514
Yule-Walker Estimates
SSE 2.9310717 DFE 17
MSE 0.17242 Root MSE 0.41523
SBC 27.6847347 AIC 24.6975379
Regress R-Square 0.9994 Total R-Square 0.9992
Durbin-Watson 2.2424
以 OLS 分析結果
標準誤 AIC R2 D-W
0.488 29.9 0.9988 3.069
AR(1)迴歸估計式:
yt = 8.974 + 5.643 xt + εt , εt = -0.542 εt-1
Variable DF Estimate Standard Error t Value Approx Pr > |t|
Intercept 1 8.9739 0.8424 10.65 <.0001
saleC 1 5.6431 0.0342 164.96 <.0001
Estimates of Autoregressive Parameters
Lag Coefficient Standard Error t Value
1 0.541657 0.203875 2.66