STAT 6104 - Financial Time Series Chapter 1 - Introduction Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 1 / 42
Agenda 1 Basic Description 2 Simple Descriptive Techniques 3 Examples 4 Summary Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 2 / 42
Basic Description What is Time Series? A collection of values X t : t = 1, 2,..., n t : time (e.g. days, months, years) X t : observed data at different time (e.g. temperature,stock price) Example of Time Series : Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 3 / 42
Distinctive feature of time series In classical setting (e.g. t-test, regression), we assume X t s are independent In time series, we assume X t s are dependent!! The dependence in time series is quantified by auto-covariance For small k, Cov(X t, X t+k ) 0 Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 4 / 42
Some nonstandard features of X t 1) Unequally spaced data (t=1,2,3,4,5,8,9,10,11,12,15,...) Security Price are not available during non-trading days 2) Continuous time series (t can be any real number) Physical phenomenon (e.g. weight) We have {X(t), t R} instead of {X(t)} t=1,2,... 3) Aggregation Data observed : an ACCUMULATION of some quantities over a period of time Examples: Daily return = aggregation of tick by tick return Daily rainfall = aggregation of hourly rainfall Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 5 / 42
Some nonstandard features of X t (continue) 4) Replicated time series Data observed : repeated measurement of same quantity across different subjects e.g.: X (j) t total weekly spending for the j-th person at week t where t = 1, 2,.., n are repeated measurement of subject j X (j) t 1 and X (k) t 2 are independent for all t 1, t 2 if j k 5) Multiple time series X t is a vector rather than a scalar e.g. Returns of a portfolio at time t : X t = (X 1,t, X 2,t,..., X p,t ) X i,t : return of equity i at time t Need to consider the cross correlation between different series e.g. Cov(X 1,t, X 2,h ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 6 / 42
Importance of Time Series Example 1 - Using correlation to find a better C.I of µ Model : X t = µ + a t θa t 1 where a t N (0, 1) E(X t ) = µ + E(a t ) θe(a t 1 ) = µ There exists time dependence because θ k = 1 Cov(X t, X t k ) = 1 + θ 2 k = 0 0 otherwise Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 7 / 42
Importance of Time Series 95% Confidence interval for the mean µ X ± 2 Var(X) Proof:By C.L.T., X µ N (0, 1) Var(X) ( ) P 2 X µ 2 0.95 ( Var(X) ) P X 2 Var(X) µ X + 2 Var(X) 0.95 Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 8 / 42
Importance of Time Series It can be shown that Var(X) = 1 n [(1 θ)2 + 2θ n ] 95% C.I. is X ± 2 [ (1 θ) 2 + 2θ ] 1/2 n n Without dependence (θ = 0), 95% C.I. is X ± 2 n Ratio of length of C.I.s is: { [ 2 L(θ) = (1 θ) 2 + 2θ ] } 1/2 { } [ 2 / n = (1 θ) 2 + 2θ ] 1/2 n n n Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 9 / 42
Importance of Time Series Implication: θ L (θ), n = 50-1 2-0.5 1.34 0 1 0.5 0.45 1 0.14 If θ = 1, but we wrongly assumed independence (θ = 0), then our C.I. is too big If θ = 1, but we wrongly assumed independence (θ = 0), then our C.I. is too small Need to incorporate correlation structure to produce a correct C.I. Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 10 / 42
Agenda 1 Basic Description 2 Simple Descriptive Techniques 3 Examples 4 Summary Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 11 / 42
Simple Descriptive Techniques Decomposition of a time series X t = T t + S t + N t (Trend) (Seasonality) (Noise) T t + S t Macroscopic Component N t Microscopic Component Series Trend Seasonality Noise Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 12 / 42
Trends Examples Linear Trend : T t = α + βt Quadratic Trend : T t = α + βt + γt 2 Linear Trend Quadratic Trend Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 13 / 42
Estimation of trends without Seasonality 1) Least Square Method min. (X t T t ) 2 2) Filtering Y t = S m (X t ) 3) Differencing X t = X t X t 1 Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 14 / 42
1. Least Squares Method Least Squares Method: Idea : Find α, β in T t = α + βt such that n RSS = (X t T t ) 2 is minimized t=1 Drawbacks Only simple form of T t is allowed, otherwise the minimization is difficult Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 15 / 42
1. Least Squares Method Least Squares Method: Idea : Find α, β in T t = α + βt such that n RSS = (X t T t ) 2 is minimized t=1 Example: Given the data {1.2, 2.1, 2.9, 3.8}, estimate the trend in the form T t = α + βt. Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 16 / 42
2. Filtering Filtering Idea : Smooth the series using local data to estimate the trend Y t = S m (X t ) }{{} = s a r X t+r r= q }{{} smoothed series Weighted average of {X t q, X t q 1, X t+s } The weight {a r } are usually assumed to be symmetric (a r = a r ) and normalized ( a r = 1) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 17 / 42
2. Filtering Examples 1) Moving Average Filter Y t = 1 2q + 1 q X t+r r= q What is {Y t } if {X t } = {1.1, 2.2, 2.7, 4.1, 5.2, 5.8} and q = 1? If X t = α + βt, Y t = S m (X t ) = 1 2q + 1 α + βt q {[α + β (t + r)] + N t+r } r= q 2) Spencer 15-point filter (a 0, a 1,..., a 7 ) = 1 320 (74, 67, 46, 21, 3, 5, 6, 3) a r = a r Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 18 / 42
2. Filtering Properties of Spencer 15-point filter Does not distort a cubic trend: If X t = T t + N t, where T t = at 3 + bt 2 + ct + d, then S m (X t ) = 7 a rt t+r + 7 a rn t+r r= 7 r= 7 = at 3 + bt 2 + ct + d + 7 a rn t+r r= 7 Since 7 r= 7 a rn t+r 0 (smoothing), we have S m (X t ) at 3 + bt 2 + ct + d = T t We say: the cubic trend passes through the filter Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 19 / 42
2. Filtering General Theorem: A k th order polynomial passes through a filter T t (i.e., T t = s r= s a r T t+r = S m (T t ) for T t = c 0 + c 1 t + + c k t k ) if and only if s 1 r= s a r = 1 s 2 r= s r j a r = 0 for j = 1, 2,..., k Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 20 / 42
2. Filtering Low-pass filter: Filter out high-frequencies (volatile) signals Retains low-frequencies (smooth) signals Low-Pass e.g. S m (X t ) = Xt+r 2q+1 before Low-pass after Low-pass Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 21 / 42
2. Filtering High-pass filter: Filter out low-frequencies (smooth) signals Retains high-frequencies (volatile) signals High-Pass e.g. X t S m (X t ) before High-pass after High-pass Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 22 / 42
3. Differencing Differencing X t = X t X t 1 2 X t = ( X t ) Definition: Backshift operator (B): BX t = X t 1 B k X t = X t k, k = 1, 2,... Alternatively, X t = (1 B)X t k X t = (1 B) k X t, k = 1, 2,... Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 23 / 42
3. Differencing removes trend If X t = α + βt, then X t = X t X t 1 = α + βt [α + β(t 1)] = β (no Trend!) In general, If X t = T t + N t and T t = p j=0 a jt j, then p X t = p!a p + p N t (The trend T t is eliminated) (Note: If the trend is a j th degree polynomial, then the trend can be eliminated in differencing j times.) Example: What is { X t } if {X t } = {1.1, 2.2, 2.7, 4.1, 5.2, 5.8} and q = 1? Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 24 / 42
Seasonal Cycles Additive Seasonal Component X t = T t + S t + N t Multiplicative Seasonal Component X t = T t S t N t Seasonal part: period=d e.g. season: d=4, month:d=12 Requirements 1 S t+d = S t d 2 j=1 Sj = 0 (common effect is explained by Tt) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 25 / 42
Estimating/Removing Seasonal effect 1) Moving average method 2) Seasonal Differencing Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 26 / 42
1. Moving Average Method STEP 1: Estimate the trend T t by a moving average filter the moving average filter must be of length d the estimated trend is free from seasonal effect because d j=1 S j = 0 { ( 1 1 T t = d 2 X t q + X t q+1 +... + 1 2 t+q) X, d = 2q 1 qr= q d X t+r, d = 2q + 1 STEP 2: Estimate the seasonal component S j = t=j,d+j,...,kd+j (X t T t ) µ s = 1 dj=1 S d j S j = S j µ s n d n d : number of complete cycle STEP 3: Use any filter for the series X t S t, get an improved T t (May set T t = T t if satisfied with the filter in Step 1.) RESULT: X t = T t + S t + N t, (N t = X t T t S t ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 27 / 42
2. Seasonal Differencing Seasonal Differencing d X t = ( 1 B d) X t = X t X t d Seasonal differencing removes seasonal effects: If X t = S t + N t and period= d, then d X t = S t S t d + N t N t d = N t N t d. (Recall S t = S t d ) Drawback - Lose d data points data = (X 1, X 2,..., X n ) differenced data = (X d+1,..., X n ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 28 / 42
Agenda 1 Basic Description 2 Simple Descriptive Techniques 3 Examples 4 Summary Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 29 / 42
Example in R Data : Quarterly operating revenues of Washington power company 80-86 http://www.sta.cuhk.edu.hk/nhchan/tsbook2nd/dataset.html Step 0: Time Series Plot Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 30 / 42
Step 0: Time Series Plot Observations 1) Slightly increasing trend 2) Annual Cycle Lower in summer Higher in winter (heating?) R-Codes for time series plot x<-read.delim( C://washpower.dat,head=FALSE) x<-ts(x, frequency = 4, start = c(1980, 1)) ts.plot(x,main= Wasington Water Power Co ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 31 / 42
Decomposition X t = T t + S t + N t Step 1: Estimate the trend T t by a filter running over one complete season (d = 4) T 3 = 1 2 X 1 + X 2 + X 3 + X 4 + 2 1 X 5 4 T 4 = 1 2 X 2 + X 3 + X 4 + X 5 + 2 1 X 6 4 T 26 = 1 2 X 24 + X 25 + X 26 + X 27 + 1 2 X 28 4 Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 32 / 42
Decomposition: R-code for Step 1 x<-read.delim( C://washpower.dat,head=FALSE) x<-ts(x, frequency = 4, start = c(1980, 1)) n<-length(x) t<-rep(0,n-4) for ( k in 1:(n-4)) { t[k]=1/8*x[k]+1/4*x[k+1]+1/4*x[k+2]+1/4*x[k+3]+1/8*x[k+4] } t<-c(na,na,t) t<-ts(t,frequency=4,start=c(1980,1)) ts.plot(t,ylab= Trend ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 33 / 42
Decomposition X t = T t + S t + N t Step 2: Estimate seasonal effect from the trend-removed series D t D t = X t T t, D = 1 26 24 i=3 D i Estimate the seasonal part S i S 1 = [(D 5 D) + (D 9 D) + + (D 25 D)]/6 S 2 = [(D 6 D) + (D 10 D) + + (D 26 D)]/6 S 3 = [(D 3 D) + (D 7 D) + + (D 23 D)]/6 S 4 = [(D 4 D) + (D 8 D) + + (D 24 D)]/6 S i+4j = S i, all i, j Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 34 / 42
Decomposition:R-code for Step 2.2 x<-read.delim( C://washpower.dat,head=FALSE) (refer to R-code for Step 1) t<-ts(t,frequency=4,start=c(1980,1)) d<-rep(0,n-4) for (k in 1:(n-4)){d[k]= x[k+2]-t[k+2]} m<-mean(d) d<-c(na,na,d) s<-rep(0,28) for (k in 1:6){ s[1]= s[1]+1/6*(d[1+4*k]-m)} for (k in 1:6){ s[2]= s[2]+1/6*(d[2+4*k]-m)} for (k in 1:6){ s[3]= s[3]+1/6*(d[4*k-1]-m)} for (k in 1:6){ s[4]= s[4]+1/6*(d[4*k]-m)} for (k in 5:n){ s[k]= s[k-4]} s<-ts(s,frequency=4,start=c(1980,1)) ts.plot(s,ylab= Seasonality ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 35 / 42
Seasonal Graph Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 36 / 42
Decomposition X t = T t + S t + N t Step 3: Re-estimate the trend from deseasonalized data Q t = X t S t T 3 = 1 2 Q 1 + Q 2 + Q 3 + Q 4 + 2 1 Q 5 4 T 4 = 1 2 Q 2 + Q 3 + Q 4 + Q 5 + 2 1 Q 6 4 T 26 = Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 37 / 42
Decomposition: R-code for Step 3 x<-read.delim( C://washpower.dat,head=FALSE) (refer to R-code for Step 2.1) s<-ts(s,frequency=4,start=c(1980,1)) q<-rep(0,n) for (k in 1:n){ q[k]=x[k]-s[k]} t1<-c(na,na,rep(0,n-4)) for (k in 3: (n-2)){ t1[k]=1/8*q[k-2]+1/4*q[k-1]+1/4*q[k]+1/4*q[k+1]+1/8*q[k+2]} t1<-ts(t1,frequency=4,start=c(1980,1)) ts.plot(t1,ylab= Re-estimated Trend ) # par(mfrow=c(2,2)) ts.plot(x) ts.plot(t,ylab= Trend ) ts.plot(s,ylab= Seasonality ) ts.plot(t1,ylab= Re-estimated Trend ) Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 38 / 42
Putting Four Graphs Together Chun Note Yip Yau that (CUHK) the trend and STAT the 6104:Financial re-estimated Time Seriestrend are the same, since39 / 42
Decomposition X t = T t + S t + N t What to do after decomposition? Check the residual N t = X t T t S t to detect further structure Sophisticated models for the microscopic structure in N t will be discussed in later chapters Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 40 / 42
Agenda 1 Basic Description 2 Simple Descriptive Techniques 3 Examples 4 Summary Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 41 / 42
Summary of Chapter 1 1) Time Series Observations with time dependent structure Cov(X t, X t+k ) 0 2) Decomposition X t = T t + S t + N t (Trend) (Seasonality) (Noise) i) Removing Trend only Least Squares Method: Minimizes n (Xt Tt)2 t=1 Filters: S m(x t) = s r= q arxt+r Differencing X t = (1 B)X t = X t X t 1 ii) Removing Seasonality Seasonal Filtering: Step 1: Moving average filter with length d to obtain Tt Step 2: Estimate S t from X t Tt Step 3: Re-estimate T t from X t S t Seasonal Differencing d X t = (1 B d )X t = X t X t d Chun Yip Yau (CUHK) STAT 6104:Financial Time Series 42 / 42