[시계열] 확률과정 및 시계열 이론(1)

확률과정(Random process, Stochastic process):

  • 의미: 확률변수의 순서열(sequence of infinit random variables)
  • 확률과정Y={,Y1,Y0,Y1,}
    • 확률변수Yt는 평행우주 t시간의 표본 generator
  • 시계열 자료는 확률 과정의 표본
  • 앙상블 평균E[Yt]: 복수의 시계열 자료 표본에서 특정한 시간 t의 값만 평균(평행우주에서 yt시간 값만 추출)
    • 현실세계는 불가능: 현실세계가 표본 하나
    • 앙상블 평균 추정의 조건
      • 정상과정(stationary process) & 에르고딕 과정(ergodic process)

1. 확률과정의 기댓값, 자기공분산, 자기상관계수

  • ‘자기(auto)’: 표본 하나의 set 내에서의 cov & cor
  • 확률과정 기댓값: μt=E[Yt]
  • 자기공분산(auto-covariance): 방향 & 거리
    • γt,s=Cov[Yt,Ys]=E[(YtE[Yt])(YsE[Ys])]
  • 자기상관계수(auto-correlation): 방향
    • ρt,s=γt,sγtγs=Corr[Yt,Ys]=Cov[Yt,Ys]Var[Yt]Var[Ys]1

2. 정상확률과정

  • Y1,Y2,의 평균, 표준오차 등이 변하지 않음.
  • 쉽게 말하자면, 평균, 분산 등 모멘트 공식에 절대시간 t변수가 없고, 시차 k변수가 존재(이후 MA, AR 모델 등에서 확인)
  • 즉, 에르고딕 성질에 의해, 표본들이 하나의 generator에서 생성됨

2.1. 자기공분산: 시간 변수의 차이lag k에만 의존

γt,t+k=γ0,kγk

2.2. 자기상관계수: 시간 변수의 차이lag k에만 의존

ρt,t+k=ρ0,kρk=γkγ0

  • eg) ACF of AR(1): ρk=γkγ0=(ϕ)kϕ<0 그래프는 진동

2.3 정상확률과정 특징

  • 확률과정 특성은 확률변수Yt의 결합확률밀도함수 사용
  • 협의의 정상확률과정(strictly stationary process): 모든 모멘트가 ‘절대시간’에 의존하지 않고 시차lag에만 의존
    • E[YtYt+k1]=E[YsYs+k1]
  • 광의의 정상확률과정(weak stationary process)
    • 1, 2차 모멘텀에 대해서만 ‘절대시간’ 의존하지 않음
    • E[Yt]=E[Ys]=μ
    • E[YtYt+k]=E[YsYs+k]
  • 순수하게 백색잡음이라면, 어떤 시차lag에서도 자기상관ρ는 1

3. 에르고딕 성질

  • 정상확률 과정의 확률변수들(Yt,Yt+1,)은 무조건부 분포 동일
  • 따라서 현실 시계열 데이터를 하나의 분포에서 나온 표본 데이터로 간주
  • moment method(점 추정)에 따라 모수추정 가능: μ=E[X]=x¯

4. 백색 잡음 white noise

  • 확률과정 ϵ={ϵ1,ϵ2,}
  • ϵti.i.d(independent and identically distributed)

5. 랜덤 워크 Random walk

  • IMA(1,0)
  • 과거 백색잡음의 cumsum

Appendix

A1. Non-stationarity

Trend & Seasonality

  • Trend
  • Seasonality: additive or multiplicative

A2. Stationarity

A white noise series(sequence of random numbers)

  • a flat looking series
  • no trend
  • no constant variance over time
  • no a constant autocorrelation structure over time
  • no periodic fluctuations

A3. STL(Seasonal and Trend Decomposition using Loess)

A4. Application

  • explanation
  • control: identify anomal
  • forecasting

A5. Remove trend and seasonality

Xt=μt+St+Zt
  • μt trend component: 추정 방법 3가지
    • LSE: deterministic μt=f(t)
    • Smoothing by rolling mean: stocahstic, ARIMA
    • Differencing: stocahstic, ARIMA
  • St: seasonal component
  • Zt: random noise component

예시) CO2 Data

1
2
3
import statsmodels.api as sm
data = sm.datasets.get_rdataset("CO2", package="datasets")
df = data.data
1
2
3
4
5
6
7
8
9
10
11
12
def yearfraction2datetime(yearfraction, startyear=0):
import datetime
import dateutil
year = int(yearfraction) + startyear
month = int(round(12 * (yearfraction - year)))
delta = dateutil.relativedelta.relativedelta(months=month)
date = datetime.datetime(year, 1, 1) + delta
return date

df["datetime"] = df.time.map(yearfraction2datetime)
df["month"] = df.datetime.dt.month
df.tail()
time value datetime month
463 1997.583333 362.57 1997-08-01 8
464 1997.666667 360.24 1997-09-01 9
465 1997.750000 360.83 1997-10-01 10
466 1997.833333 362.49 1997-11-01 11
467 1997.916667 364.34 1997-12-01 12
1
plt.plot(df['value'])
[<matplotlib.lines.Line2D at 0x7ff3474934e0>]

pngpng

질문

  • Moving Average, Smoothing, differencing 관계
< !-- add by yurixu 替换Google的jquery并且添加判断逻辑 -->