Data Science

[시계열분석-6]추세의 모델링

Author
Irealist
Date
2016-12-04 08:14
Views
1287

『Disclaimer: 본 글은 대학원의 시계열분석 수업 및 시계열분석 서적에 관한 공부 내용을 정리하는 시리즈입니다. 

본 내용은 필자가 전부 직접 요약하여 적은 개인 노트이며, 개인 공부 및 복습이 주목적일 뿐, 상업적 의도는 없습니다. 

Source: Regression Modeling with Actuarial and Financial Applications by Edward W. Frees


Objective of the analysis: Observe, understand, take action


6-1. 용어의 정의


Process: series of actions that lead to a particular end

Stochastic process: ordered collections of random variables that quantify a process

Longitudinal data: measurements of a process that evolves over time

Time series: single measurement of a process denoted by y1, ..., yt

Cross-sectional data: unordered data


Time Series 데이터의 예시

Dow Jones Index: perfectly defined, precisely measured

Mississippi discharge: perfectly defined, loosely measured

GDP: loosely defined, loosely measured


시계열 데이터를 다룰 때, 아래 형식의 regression은 causal model이라 불린다.

01.jpg

이 모델은 econometrics에서 casual relationship에 많이 사용되는데, 설명변수들이 단순한 시간의 함수일 때는 잘 적용될 수 있다.




6-2. Fitting Trends in Time


일반적으로 시계열은 세 종류의 패턴으로 나뉜다. Trends in time(T), seasonality(S), random(ε).

02.jpg

03.jpg

따라서 위 두 식으로 간단히 표현 가능하다. 각 패턴의 효과는 아래에 표현되어 있다.

04.jpg

가장 간단한 모델은, observation들이 i.i.d.라 가정하면 

05.jpg

위와 같고, linear trend를 모델링하려면 아래처럼 한다. 이는 higher polynomial로 연장가능하다.

06.jpg


Seasonality는 binary variable을 사용하거나, 삼각함수를 사용하여 모델 가능하다.



6-3. Stationarity and Random Walk Models


6-3-1. Stationarity

07.jpg

여기서 두번째 항목을 연장하면, 

08.jpg

이고, stationary process는 constant mean and variance를 갖음을 알 수 있다.

Strict/strong stationarity는 mean, variance 뿐만 아니라 전체 distribution가 constant over time임을 말한다.


6-3-2. White Noise

White noise process는 yt가 i.i.d인 시계열을 말한다. (No apparent patterns)

어떤 시계열 observation이 있고, ybar가 sample average, sy가 sample s.d라고 하면, 미래의 어떤 yT+l 의 forecast interval은 l과 상관없이 아래와 같다.

09.jpg

여기서 sy는 population s.d보다 작기 때문에, 1+(1/T)는 correction term이다.

우리의 모델링 노력은 주로 series를 white noise series로 "filter"를 통해 reduce하는 것을 목표로 하며, 모든 패턴이 filter되고 나면 uncertainty가 irreducible이라고 한다.


6-3-3. Random Walk

6-3-3-1. RW 모델의 정의

랜덤워크 모델은 아래와 같이 recursively 정의되며, c는 white noise다.

10.jpg

이를 확장하면,

11.jpg

이다. 즉, random walk는 white noise process의 partial sum이다.


Random walk는 series가 observe된 time point에 따라 variability(그리고 종종 mean도)가 달라지므로 stationary하지 않다.

확장한 식에서 평균과 분산을 구하면, 보다시피 평균과 분산이 constant가 아닌 t의 함수임을 알 수 있다.

12.jpg

13.jpg


6-3-3-2. RW 모델의 Forecast

어떤 series of observations가 random walk라고 식별되면, forecast는 아래와 같이 difference를 통해 한다.

14.jpg

위를 이용하면, yT+l의 95% prediction interval은 아래와 같다.

15.jpg


6-3-3-3. RW 모델의 식별


어떤 series가 RW 모델에서 오는지를 식별하려면, 가장 먼저 RW가 nonstationary이기에 stationarity를 체크하는 것이 좋다.

그러려면, modest size의 successive samples들의 mean과 variance가 비슷한지를 확인한다. (처음 5개, 다음 5개, 다음 5개, ...)

Control chart는 어떤 series of observations의 평균 ybar와 표준편차 sy를 구한 후, UCL, LCL을 각각 ybar +- 3sy로 설정하여 눈으로 확인하는 표다.

XBar chart는 sucessive observations of modest size를 합해, 그 그룹들의 평균으로 control chart를 만든다. 그룹들의 평균이므로 더욱더 variability가 작다.

R chart는 XBar처럼 그룹을 나눈 후, 각 그룹별 (최대값-최소값) range를 이용해 control chart를 만든다.


RW는 기본적으로 linear trend in time을 따르고, variability of series가 t와 함께 커진다.

따라서 만약 어떤 series가 nonstationary라고 생각하면,

1) Control chart를 이용해 linear trend / variability를 체크한다.

2) Data가 RW를 따르면 그 difference는 WN를 따르므로, difference를 체크하여 stationary인지를 확인한다.

3) Original series와 differenced series의 표준편차를 비교하여 전자가 더 커야 한다.


6-3-4. Linear Trend in Time Model vs RW Model


Linear trend in time 모델은 아래와 같고,

16.jpg

RW 모델의 경우 white noise process ct를 아래와 같이 decompose 하면,

18.jpg

RW 모델식은 아래와 같이 된다.

17.jpg19.jpg


따라서 두 모델 간에 deterministic portion이 linear function of time인 것은 차이가 없고, error component만 다르다. 

Linear trend in time model의 error component는 stationary WN이고, RW model의 error component는 nonstationary RW이다.


6-4. Filtering to Achieve Stationarity


데이터를 WN으로 만들기 위한 filtering으로는 대표적으로 transformation이 있다. 특히 spread out data의 경우 logarithm transformation이 유효하다.

20.jpg

좌상은 기존 index, 우상은 differenced. 좌하는 log변환한 index, 우하는 log변환후 differenced.

로그 변환의 difference는 proportional changes라고 해석될 수 있다.

21.jpg


6-5. Forecast Evaluation


Validation은 비슷하게 out-of-sample로 행할 수 있다.

22.jpg

그리고 여러 모델들의 forecast를 비교하려면 아래와 같은 방법들이 있다.

23.jpg




Total 0

Total 38
Number Title Author Date Votes Views
Notice
[공지]Data Science 게시판의 운영에 관하여
Irealist | 2020.05.18 | Votes 0 | Views 1238
Irealist 2020.05.18 0 1238
22
[강화학습-2]Sutton 교과서 챕터 3: Finite Markov Decision Processes
Irealist | 2020.05.15 | Votes 0 | Views 1390
Irealist 2020.05.15 0 1390
21
[강화학습-1]Sutton 교과서 챕터 1: 강화학습이란?
Irealist | 2020.05.15 | Votes 0 | Views 2170
Irealist 2020.05.15 0 2170
20
[일반]데이터 과학 공부 방법 - 머신러닝, 딥러닝, 강화학습
Irealist | 2020.05.15 | Votes 0 | Views 2631
Irealist 2020.05.15 0 2631
19
[일반]데이터 과학 공부 방법 - 선행 과목 및 유용한 사이트 정리 (1)
Irealist | 2020.05.15 | Votes 0 | Views 4946
Irealist 2020.05.15 0 4946
18
[계산통계학]Automatic Differentiation
Irealist | 2017.01.23 | Votes 0 | Views 1127
Irealist 2017.01.23 0 1127
17
[시계열분석-8]시계열 모델과 예측
Irealist | 2016.12.04 | Votes 0 | Views 989
Irealist 2016.12.04 0 989
16
[시계열분석-7]자기상관과 AR모델
Irealist | 2016.12.04 | Votes 0 | Views 2037
Irealist 2016.12.04 0 2037
15
[시계열분석-6]추세의 모델링
Irealist | 2016.12.04 | Votes 0 | Views 1287
Irealist 2016.12.04 0 1287
14
[회귀분석-5]회귀분석 결과의 해석
Irealist | 2016.12.03 | Votes 0 | Views 629
Irealist 2016.12.03 0 629
13
[회귀분석-4]변수 선택 및 모델의 진단
Irealist | 2016.12.03 | Votes 0 | Views 2102
Irealist 2016.12.03 0 2102
12
[회귀분석-3]다중 회귀 분석 II
Irealist | 2016.10.12 | Votes 0 | Views 972
Irealist 2016.10.12 0 972
11
[회귀분석-2]다중 회귀 분석
Irealist | 2016.10.09 | Votes 0 | Views 1701
Irealist 2016.10.09 0 1701
10
[알고리즘-7]그래프의 최단 거리
Irealist | 2016.10.09 | Votes 0 | Views 560
Irealist 2016.10.09 0 560
9
[알고리즘-6]DFS의 응용
Irealist | 2016.09.29 | Votes 0 | Views 1240
Irealist 2016.09.29 0 1240
8
[회귀분석-1]기본 회귀 분석
Irealist | 2016.09.25 | Votes 0 | Views 1131
Irealist 2016.09.25 0 1131