Processing math: 100%



Time-Series Analysis


By Prof. Seungchul Lee
http://iai.postech.ac.kr/
Industrial AI Lab at POSTECH

1. So Far

  • Regression, Classification, Dimension Reduction,

  • Based on snapshot-type data



  • Sequence matters



  • What is a sequence?
    • sentence
    • medical signals
    • speech waveform
    • vibration measurement
  • Sequence Modeling
    • Most of the real-world data is time-series
    • There are important bits to be considered
      • Past events
      • Relationship between events
        • Causality
        • Credit assignment
  • Learning the structure and hierarchy
  • Use the past and present observations to predict the future

2. (Determinstic) Sequences and Difference Equations

We will focus on linear difference equations (LDE), a surprisingly rich topic both theoretically and practivally.

For example,

y[0]=1,y[1]=12,y[2]=14,

or by closed-form expression,

y[n]=(12)n,n0

or with a difference equation and an initial condition,

y[n]=12y[n1],y[0]=1

High order homogeneous LDE

y[n]=α1y[n1]+α2y[n2]++αky[nk]

3. (Stochastic) Time Series Analysis

3.1. Stationarity and Non-Stationary Series

  • A series is stationary if there is no systematic change in mean and variance over time

    • Example: radio static
  • A series is non-stationary if mean and variance change over time

    • Example: GDP, population, weather, etc.

3.2. Testing for Non-Stationarity

Formally

  • Augmented DickeyFuller test

Informally

  • Auto-Correlation Function (ACF)
  • Normal Quantile Plot (Q-Q plot)

Q-Q Plot

  • Compare distribution of the residuals to normal
  • Scatter plot of residual quantiles against normal
    • Stationary data: quantiles match normal (45o line)
    • Non-stationary data: quantiles do not match (points off 45o line)

3.3. Dealing with Non-Stationarity


Linear trends




Non-linear trends

  • For example, population may grow exponentially





Seasonal trends

  • Some series may exhibit seasonal trends

  • For example, weather pattern, employment, inflation, etc.




Combining Linear, Quadratic, and Seasonal Trends

  • Some data may have a combintation of trends




  • One solution is to apply repeated differencing to the series

  • For example, first remove seasonal trend. Then remove linear trend

  • Inspect model fit by examining residuals Q-Q plot

  • Anternatively, include both linear and cyclical trend terms into the model
Yt=β1+β2Yt1+β3t+β4tβ5+β6sin2πst+β7cos2πst+ut

4. Markov Process

4.1. Sequential Processes

  • Most classifiers ignored the sequential aspects of data
  • Consider a system which can occupy one of N discrete states or categories qt{S1,S2,,SN}
  • We are interested in stochastic systems, in which state evolution is random
  • Any joint distribution can be factored into a series of conditional distributions


p(q0,q1,,qT)=p(q0)p(q1q0)p(q2q1q0)p(q3q2q1q0)


Amost impossible to compute !!


p(q0,q1,,qT)=p(q0)p(q1q0)p(q2q1)p(q3q2)


Possible and tractable !!

4.2. Markov Process

  • (Assumption) for a Markov process, the next state depends only on the current state:


p(qt+1qt,,q0)=p(qt+1qt)
  • More clearly


p(qt+1=sjqt=si)=p(qt+1=sjqt=si,any earlier history)


  • Given current state, the past does not matter
  • The state captures all relevant information from the history
  • The state is a sufficient statistic of the future

4.3. State Transition Matrix

For a Markov state 𝑠 and successor state 𝑠′, the state transition probability is defined by


Pss=P[St+1=sSt=s]


State transition matrix P defines transition probabilities from all states s to all successor states s.





Example: MC episodes

  • sample episodes starting from S1
In [16]:
import numpy as np

P = [[0, 0, 1],
    [1/2, 1/2, 0],
    [1/3, 2/3, 0]]
In [17]:
print(P[1][:])
[0.5, 0.5, 0]
In [18]:
a = np.random.choice(3,1,p = P[1][:])
print(a)
[1]
In [19]:
# sequential processes
# sequence generated by Markov chain
# S1 = 0, S2 = 1, S3 = 2

# starting from 0
x = 0
S = []
S.append(x)

for i in range(50):    
    x = np.random.choice(3,1,p = P[x][:])[0]    
    S.append(x)
     
print(S)    
[0, 2, 1, 0, 2, 1, 1, 0, 2, 1, 1, 1, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 0, 2, 1, 0, 2, 1, 1, 1, 1, 0, 2, 1, 1, 0, 2, 1, 0, 2, 1]

5. Hidden Markov Models

  • Discrete state-space model
    • Used in speech recognition
    • State representation is simple
    • Hard to scale-up the training
  • Assumption
    • We can observe something that is affected by the true state
    • Natual way of thinking
  • Limited sensors (incomplete state information)
    • But still partially related
  • Noisy senors
    • Unreliable




  • True state (or hidden variable) follows Markov chain
  • Observation emitted from state

    • Yt is noisily determined depending on the current state Xt
  • Forward: sequence of observations can be generated

  • Question: state estimation
P(XT=siY1Y2YT)
  • HMM can do this, but with many difficulties

6. Kalman Filter

  • Linear dynamical system of motion



xt+1=Axt+Butzt=Cxt
  • A, B, C ?

  • Continuous State space model

    • For filtering and control applications
    • Linear-Gaussian state space model
    • Widely used in many applications:
      • GPS, weather systems, etc.
  • Weakness

    • Linear state space model assumed
    • Difficult to apply to highly non-linear domains
In [20]:
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')