• 沒有找到結果。

Econ 7933: Financial Time Series: Introduction

N/A
N/A
Protected

Academic year: 2022

Share "Econ 7933: Financial Time Series: Introduction"

Copied!
39
0
0

加載中.... (立即查看全文)

全文

(1)

Econ 7933: Financial Time Series: Introduction

Sheng-Kai Chang (NTU)

Fall, 2015

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 1 / 39

(2)

Examples of Fnancial time series

Daily log returns of Apple stock: 2005 to 2014.

U.S. monthly unemployment rates

U.S. daily interesrate rate of 10-year Treasury Notes The VIX index

Exchange rate between US Dollar vs Euro

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 2 / 39

(3)

setwd("D:/R/FTS/Data") library(quantmod) library(downloader)

getSymbols("AAPL",from="2005-01-01",to="2014-12-31")

## [1] "AAPL"

chartSeries(AAPL,theme="white")

100 200 300 400 500 600 700

AAPL [2005−01−03/2014−12−31]

Last 110.379997

Volume (millions):

41,403,400

0 200 400 600 800

... 03 2005 ... 02 2007 ... 04 2010 ... 02 2012 ... 31 2014

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 3 / 39

(4)

chartSeries(AAPL$AAPL.Adjusted,theme="white")

0 20 40 60 80 100 120

$ AAPL AAPL.Adjusted

[2005−01−03/2014−12−31]

Last 108.99538

... 03 2005 ... 02 2007 ... 04 2010 ... 02 2012 ... 31 2014

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 4 / 39

(5)

AAPL.rtn=diff(log(AAPL$AAPL.Adjusted)) hist(AAPL.rtn)

Histogram of AAPL.rtn

AAPL.rtn

Frequency

−0.20 −0.15 −0.10 −0.05 0.00 0.05 0.10 0.15

02004006008001000

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 5 / 39

(6)

chartSeries(AAPL.rtn, theme="white")

−0.20

−0.15

−0.10

−0.05 0.00 0.05 0.10

AAPL.rtn [2005−01−04/2014−12−31]

Last −0.0192020203673824

... 04 2005 ... 02 2007 ... 04 2010 ... 02 2012 ... 31 2014

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 6 / 39

(7)

getSymbols("UNRATE",src="FRED")

## [1] "UNRATE"

chartSeries(UNRATE,theme="white")

4 6 8 10 UNRATE [1948−01−01/2015−08−01]

Last 5.1

... 1948 ... 1960 ... 1975 ... 1990 ... 2005

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 7 / 39

(8)

U.S. Government Bonds: Treasury Bills, Treasury Notes, Treasury Bonds Treasury bills (T-Bills) mature in one year or less. They do not pay interest prior to maturity and are sold at a discount of the face value (par value).

The commonly used maturities are 28 days (1 months), 91 days (3 months), 182 days (6 months), and 364 days (1 year).

Treasury Notes (T-Notes) matures in 1-10 years. They have a coupon payment every 6 months and face value of $1, 000

The 10-year T-Notes has become the security most frequently quoted when discussing U.S. government bond market.

Treasury Bonds (T-Bonds) have longer maturities ranging from 20 to 30 years. Thay have coupon payment every 6 months.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 8 / 39

(9)

Bond Yields and Prices

Current Yield= Annual interest paid in dollars

Market price of the bond × 100%

For zero-coupon bonds, Current Yield= (Purchase priceFace value )1/k− 1, where k is time to maturity in years.

EX: if an investor paid $90 for a bond with face value of $100 and the bond paid a coupon rate 5% per annum, then the current yield of the bond is (0.05 ∗ 100)/90 ∗ 100% = 5.56%.

The current yield does not consider the time value of money since it does not consider the present value of the coupon payments the investor will receive in the future.

A more commonly used measurement of bond investment is the Yield to Maturity (YTM).

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 9 / 39

(10)

Yield to Maturity (YTM)

YTM is the yield obtained by equating the bond price to the present value of all future payments.

Suppose that the bond holder will receive k payments between purchase and maturity. Let y and P be the YTM and price of the bond respectively. Then

P = C1

1 + y + C2

(1 + y )2 + ... + Ck+ F (1 + y )k

where F denotes the face value and Ci us the i th cash flow of coupon payment.

Suppose that the coupon rate is α per annum, the number of payments is m per year, and the time to maturity is n year. Then cash flow of coupon payment is F α/m and the number of payments is k = mn.

P = αF

m [ 1

1 + y + 1

(1 + y )2 + ... + 1

(1 + y )k] + F (1 + y )k

= αF

my[1 − 1

(1 + y )k] + F (1 + y )k

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 10 / 39

(11)

The table below shows some results between bond price and YTM assuming that F = $100 and coupon rate is 5% per annum payable semiannually, and time to maturity is 3 years.

Yield to Maturity (%) Semiannual Rat (% ) Bond price ($)

6 3.0 97.29

7 3.5 94.67

8 4.0 92.14

9 4.5 89.68

10 5.0 87.31

YTM is inversely proportional to the bond price.

In practice, we observe bond price, so that YTM can be calculated.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 11 / 39

(12)

getSymbols("^TNX",from="2007-01-01",to="2015-6-30")

## [1] "TNX"

chartSeries(TNX,theme="white")

2 3 4 5

TNX [2007−01−03/2015−06−30]

Last 2.335

Volume (100s):

0

−1.0

−0.5 0.0 0.5 1.0

... 03 2007 ... 02 2009 ... 03 2011 ... 02 2013 ... 02 2015

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 12 / 39

(13)

TNX.rtn=diff(log(TNX$TNX.Adjusted)) chartSeries(TNX.rtn,theme="white")

−0.15

−0.10

−0.05 0.00 0.05 0.10

TNX.rtn [2007−01−04/2015−06−30]

Last 0.00171453106724051

... 04 2007 ... 02 2009 ... 03 2011 ... 02 2013 ... 02 2015

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 13 / 39

(14)

getSymbols("^VIX",from="2007-01-01",to="2015-6-30")

## [1] "VIX"

chartSeries(VIX,theme="white")

20 40 60 80

VIX [2007−01−03/2015−06−30]

Last 18.23

Volume (100,000s):

0

0 5 10 15 20

... 03 2007 ... 02 2009 ... 03 2011 ... 02 2013 ... 02 2015

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 14 / 39

(15)

getSymbols("DEXUSEU",src="FRED")

## [1] "DEXUSEU"

chartSeries(DEXUSEU,theme="white")

0.8 1.0 1.2 1.4 1.6 DEXUSEU [1999−01−04/2015−09−11]

Last 1.1338

... 04 1999 ... 02 2003 ... 02 2007 ... 03 2011 ... 02 2015

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 15 / 39

(16)

Asset Returns:Let Pt be the price of an asset at time t, and assume no dividend.

One-period simple return Gross return: 1 + Rt= PPt

t−1

Simple return: Rt = PPt

t−1 − 1.

Multiperiod simple return Gross return: 1 + Rt(k) = PPt

t−k = PPt

t−1 ×PPt−1

t−2 × ... ×PPt−k+1

t−k

The k-period Simple net return: Rt(k) = PPt

t−k − 1.

Time interval is important, default is one year.

Annualized (average) return:

Annualized [Rt(k)] = [Qk−1

j =0(1 + Rt−j)]1/k− 1 Annualized [Rt(k)] ≈ k1Pk−1

j =0 Rt−j

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 16 / 39

(17)

Continuously compounding: Let C be the initial capital, r be the interest annum, and n be the number of years.

A = C × exp[r × n]

Present value: C = A × exp[−r × n]

Continuously compounding (log) return:

rt= ln(1 + Rt) = ln(PPt

t−1) = pt− pt−1 Multiperiod log return

rt(k) = ln(1 + Rt(k)) = ln[PPt

t−1 ×PPt−1

t−2 × · · · ×PPt−k+1

t−k ]

= rt+ rt−1+ · · · + rt−k+1

Portfolio return with N assets and weights w : Rp,t =PN

i =1wiRit

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 17 / 39

(18)

Dividend (Dt): Rt = PPt+Dt

t−1 − 1,rt = ln(Pt+ Dt) − ln(Pt−1)

Excess return: Zt = Rt− R0t, zt = rt− r0t, where r0t denoted the log return of a risk-free interest rate.

rt= ln(1 + Rt), Rt= ert − 1.

If the returns are in percentage, then rt = 100 × ln(1 +100Rt ), Rt= [exp(100rt ) − 1] × 100.

Aggregation of the returns

1 + Rt(k) = (1 + Rt)(1 + Rt−1) · · · (1 + Rt−k+1) rt(k) = rt+ rt−1+ · · · + rt−k+1

These two relations are important in practice, for example, obtain annual returns from monthly returns.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 18 / 39

(19)

Distributional properties of returns: What is the distribution of rit? Moment of a random variable X with density f (x ): r -th moment E (Xr) =R

−∞xrf (x )dx . First moment: mean of X .

r -th central moment: E ((X − µX)r) =R

−∞(x − µX)rf (x )dx Second central moment: variance of X .

Skewness (symmetry): S (x ) = E [(X −µσ3x)3

x ].

Kurtosis (fat-tails) K (x ) = E [(X −µσ4x)4

x ], K (x ) − 3 is excess kurtosis.

The mean and variance are related to long-term retrun and risk, respectively. Symmetry has important implications in holding short or long financial positions and in risk management. Moreover, high kurtosis implies heavy (or long) tails in distribution.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 19 / 39

(20)

Estimation: Data {x1, ..., xT}.

Sample mean: ˆµx = T1 PT t=1xt. Sample variance: ˆσ2x = T −11 PT

t=1(xt− ˆµx)2. Sample skewness: ˆS (x ) =(T −1)ˆ1 σ3

x

PT

t=1(xt− ˆµx)3. Sample kurtosis: ˆK (x ) = (T −1)ˆ1 σ4

x

PT

t=1(xt− ˆµx)4.

Assume that xt is normally distributed, ˆS (x ) ∼ N(0,T6) and K (x ) − 3 ∼ N(0,ˆ 24T).

Test for symmetry: S = √S(x )ˆ

6/T ∼ N(0, 1) under normality. Decision rule: Reject H0 of a symmetric distribution if |S| > Zα/2 or p-value is less than α.

Test for tail thickness: K= K (x )−3ˆ

24/T ∼ N(0, 1) under normality.

Decision rule: Reject H0 of a symmetric distribution if |K| > Zα/2 or p-value is less than α.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 20 / 39

(21)

A joint test (Jarque-Bera test): JB = (S)2+ (K)2 ∼ χ22 under normality. Decision rule: Reject H0 of normality if JB > χ22(α) or p-value is less than α.

Empirical distribution of asset returns tend to be skewed to the left with heavy tails and has a higher peak than normal distribution.

Normal and lognormal: Y is lognormal if X = ln(Y ) is normal.

If X ∼ N(µ, σ2), then Y = exp(X ) is lognormal with E (Y ) = exp(µ +σ22), V (Y ) = exp(2µ + σ2)[exp(σ2) − 1].

If Y is lognormal with mean µy and variance σ2y, then X = ln(Y ) is normal with E (X ) = ln[sµy

1+σ2y

µ2y

], V (Y ) = ln[1 + σ

2y

µ2y].

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 21 / 39

(22)

library(fBasics)

#da=read.table("d-ibm3dx7008.txt",header=T) # Load data with header into R da=read.table("m-ibm6708.txt",header=T) # Load data with header into R da[1,]

## date ibm sprtn

## 1 19670331 0.048837 0.03941

dim(da) # Check dimension of the data (row = sample size, col = variables)

## [1] 502 3

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 22 / 39

(23)

ibm=da[,2] # Select the simple returns of IBM stock stored in Column 2.

plot(ibm,type='l')# Plot the simple returns.

0 100 200 300 400 500

−0.2−0.10.00.10.20.3

Index

ibm

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 23 / 39

(24)

basicStats(ibm) # Compute the descriptive statistics of simple returns.

## ibm

## nobs 502.000000

## NAs 0.000000

## Minimum -0.261905

## Maximum 0.353799

## 1. Quartile -0.036942

## 3. Quartile 0.049636

## Mean 0.008865

## Median 0.005274

## Sum 4.450050

## SE Mean 0.003262

## LCL Mean 0.002456

## UCL Mean 0.015273

## Variance 0.005341

## Stdev 0.073085

## Skewness 0.263914

## Kurtosis 1.822178

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 24 / 39

(25)

libm=log(ibm+1) # Compute the IBM log returns

basicStats(libm) # Compute descriptive statistics of log returns.

## libm

## nobs 502.000000

## NAs 0.000000

## Minimum -0.303683

## Maximum 0.302915

## 1. Quartile -0.037641

## 3. Quartile 0.048443

## Mean 0.006208

## Median 0.005260

## Sum 3.116457

## SE Mean 0.003237

## LCL Mean -0.000151

## UCL Mean 0.012567

## Variance 0.005259

## Stdev 0.072517

## Skewness -0.135343

## Kurtosis 1.693092

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 25 / 39

(26)

t.test(ibm) # Perform t-test for mean being zero.

##

## One Sample t-test

##

## data: ibm

## t = 2.7176, df = 501, p-value = 0.006804

## alternative hypothesis: true mean is not equal to 0

## 95 percent confidence interval:

## 0.002455871 0.015273412

## sample estimates:

## mean of x

## 0.008864641

t.test(ibm,alternative=c("greater"))# Perform one-sided test.

##

## One Sample t-test

##

## data: ibm

## t = 2.7176, df = 501, p-value = 0.003402

## alternative hypothesis: true mean is greater than 0

## 95 percent confidence interval:

## 0.003489285 Inf

## sample estimates:

## mean of x

## 0.008864641

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 26 / 39

(27)

hist(ibm,nclass=40) # Obtain histogram of IBM simple returns.

Histogram of ibm

ibm

Frequency

−0.3 −0.2 −0.1 0.0 0.1 0.2 0.3

010203040506070

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 27 / 39

(28)

d1=density(libm) # Compute density function of ibm log returns plot(d1$x,d1$y,type='l') # Plot the sample density of log returns

mu=mean(libm); s1=sd(libm)# compute the sample mean and standard deviation of IBM log returns.

x=seq(-0.4,0.4,0.01)# create a sequence of real numbers from -0.4 to 0.4 with increment 0.01.

y=dnorm(x,mean=mu,sd=s1)# obtain normal density with mean mu and standard deviation s1.

lines(x,y,lty=2)# impose a dashed line on the density plot for comparison with normal density.

lines(x,y,col="red")#will plot a red curve.

−0.3 −0.2 −0.1 0.0 0.1 0.2 0.3

0123456

d1$x

d1$y

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 28 / 39

(29)

normalTest(libm,method='jb') # Perform normality test.

##

## Title:

## Jarque - Bera Normalality Test

##

## Test Results:

## STATISTIC:

## X-squared: 62.8363

## P VALUE:

## Asymptotic p Value: 2.265e-14

##

## Description:

## Thu Sep 17 21:08:52 2015 by user: Sheng-Kai

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 29 / 39

(30)

Dependence: Consider two random variables X and Y , correlation coefficient: ρ = Cov (X ,Y )

std (X )std (Y ).

Kendall’s tau: Let ( ˜X , ˜Y ) be an random copy of (X , Y ).

ρτ = P[(X − ˜X )(Y − ˜Y ) > 0] − P[(X − ˜X )(Y − ˜Y ) < 0] = E [sign[(X − ˜X )(Y − ˜Y )]].

Kendall’s tau quantifies the probability of concordant over discordant.

Here concordant means (X − ˜X )(Y − ˜Y ) > 0.

Spearman’s rho: rank correlation. Let Fx(x ) and Fy(y ) be the cumulative distribution of X and Y . ρS = ρ(Fx(X ), Fy(Y )).

Spearman’s rho is the correlation of probability-transformed variables.

It is the correlation coefficient of the ranks of the data.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 30 / 39

(31)

x= rnorm(1000) # Generate 1000 N(0,1) random numbers cor(x,x)

## [1] 1 cor(x,exp(x))

## [1] 0.7510654

cor(x,exp(x),method="kendall")

## [1] 1

cor(x,exp(x),method="spearman")

## [1] 1

ibm=da[,2]

sp=da[,3]

cor(ibm,sp)

## [1] 0.5949041

cor(ibm,sp,method="kendall")

## [1] 0.4223351

cor(ibm,sp,method="spearman")

## [1] 0.5897587

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 31 / 39

(32)

Basic concepts of Time Series Models Stationarity:

- Strict: distributions are time-invariant.

- Weak: first 2 moments (mean, variance and covariance) are time-invariant.

Sample mean and sample variance are used to estimate the mean and variance.

Lag-k autocovariance: let rt be log return, γk = Cov (rt, tt−k) = E [(rt− µ)(rt−k− µ)].

Autocorrelations: ρl = cov (rvar (rt,rt−l)

t) . Note that ρ0 = 1 and ρk = ρ−k for k 6= 0.

Existence of serial correlations implies that the return is predictable and indicating market inefficiency.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 32 / 39

(33)

Basic concepts of Time Series Models

Sample autocorrelation function (ACF): ˆρl =

PT −l

t=1(rt−¯r )(rt+l−¯r ) PT −l

t=1(rt−¯r )2 , where

¯

r is the sample mean and T is the sample size.

Test zero serial corellation (market efficiency) - Individual test: H0: ρ1 = 0 v.s. H1 : ρ1 6= 0 t = √ρˆ1

1/T =√

T ˆρ1, which is asymptotically N(0, 1).

Decision rule: Reject H0 if |t| > Zα/2 or p-value is less than α.

- Joint test (Ljung-Box statistics) :H0: ρ1 = · · · = ρm = 0 v.s.

H1: ρi 6= 0

Q(m) = T (T + 2)Pm l =1

ˆ ρ2l

T −l, which is asymptotically χ2m.

Decision rule: Reject H0 if Q(m) > χ2m(α) or p-value is less than α.

Significant sample ACF does not necessarily imply market inefficiency.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 33 / 39

(34)

library(timeSeries)

par(mfcol=c(2,1)) # Put two plots on a sinlge page. c(2,1) means two rows and one column.

ts.plot(ibm) ts.plot(sp)

Time

ibm

0 100 200 300 400 500

−0.20.00.2

Time

sp

0 100 200 300 400 500

−0.20.00.1

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 34 / 39

(35)

tdx=(2+c(1:502))/12+1967# create a calendar time index. The data start at March 1967 so that the index is from 3:505 par(mfcol=c(1,1))# return to one plot per page

plot(tdx,ibm,type='l',xlab='year',ylab='ibm',main="Monthly IBM returns")

1970 1980 1990 2000 2010

−0.2−0.10.00.10.20.3

Monthly IBM returns

year

ibm

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 35 / 39

(36)

acf(ibm,lag=20) # specify the number of ACF to compute

0 5 10 15 20

0.00.20.40.60.81.0

Lag

ACF

Series ibm

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 36 / 39

(37)

pacf(ibm,lag=20)

5 10 15 20

−0.050.000.050.10

Lag

Partial ACF

Series ibm

Box.test(ibm,lag=10,type="Ljung")# Compute Ljung-Box Q(m) statistics

##

## Box-Ljung test

##

## data: ibm

## X-squared = 6.9444, df = 10, p-value = 0.7307

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 37 / 39

(38)

Lag operator: Lrt= rt−1, L2rt = rt−2.

Available data at time t, Ft−1≡ {r1, r2, · · · , rt−1}.

The return rt is decomposed into two parts given information Ft−1: rt= µt+ at= E (rt|Ft−1) + σtt.

µt is conditional mean of rt. It is the function of elements of Ft−1, and it is predictable part of rt.

at is shock or innovation at time t, it is unpredictable part of rt.

t is an i .i .d . sequence with mean zero and variance 1.

σt is conditional standard deviation. (volatility)

Model for µt: mean equation; Model for σt2: volatility equation.

Two purposes for time series models:

- A model for µt.

- Understanding models for σt2. (properties, forcasting, etc.)

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 38 / 39

(39)

Linear time series

rt is linear if the predictable part is a linear function of Ft−1and ats are i .i .d . distributed.

That is, rt can be written as rt = µ +P

i =0ψiat−i, where µ is a constant, ψ0 = 1 and at is an i .i .d . sequence with mean zero and finite variance.

at is shock or innovation at time t and ψi are the impulse responses of rt.

Sheng-Kai Chang (NTU) Econ 7933: Financial Time Series Fall, 2015 39 / 39

參考文獻

相關文件

• An algorithm for such a problem whose running time is a polynomial of the input length and the value (not length) of the largest integer parameter is a..

• Consider an algorithm that runs C for time kT (n) and rejects the input if C does not stop within the time bound.. • By Markov’s inequality, this new algorithm runs in time kT (n)

• The maintaining of an equivalent portfolio does not depend on our correctly predicting future stock prices. • The portfolio’s value at the end of the current period is precisely

• Consider an algorithm that runs C for time kT (n) and rejects the input if C does not stop within the time bound.. • By Markov’s inequality, this new algorithm runs in time kT (n)

• Consider an algorithm that runs C for time kT (n) and rejects the input if C does not stop within the time bound.. • By Markov’s inequality, this new algorithm runs in time kT (n)

• Suppose, instead, we run the algorithm for the same running time mkT (n) once and rejects the input if it does not stop within the time bound.. • By Markov’s inequality, this

This theorem does not establish the existence of a consis- tent estimator sequence since, with the true value θ 0 unknown, the data do not tell us which root to choose so as to obtain

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it