You are on page 1of 66

Computational Finance

AY 2022-2023
VI Trimester
Dr. Narend. S
Professor & Chairperson – Accounting &
Finance,
Thiagarajar School of Management

Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance,


1 TSM
Computational Finance – Course modules
 Module 1 : Univariate Time series analysis and forecasting
 Time series analysis - Preparing data for analysis, Univariate time series analysis, Autocorrelation function (ACF) ,
Partial autocorrelation function (PACF), Moving Average processes (MA), Auto Regressive processes (AR), ARMA
process, Building ARMA models, Forecasting ARMA models using EVIEWS, Exponential smoothing models,
ARIMA models, applications in financial decision making
 Module 2: Multivariate models
 Multiequation modelling- Simultaneous equation modelling. Vector Auto Regression (VAR), VAR with exogenous
variables, VAR estimation in E Views, Impulse Response and variance decomposition
 Module 3: Modelling long-run relationships
 Stationarity and unit root testing, cointegration, equilibrium or error correction models, testing for cointegration
using Johansen technique
 Module 4: Modelling volatility in time series
 Modelling time series volatility: Volatility - Historical volatility, Implied volatility models, ARCH processes,
GARCH Processes, Estimation of ARCH, GARCH models in EVIEWS, Extensions of GARCH models,
Multivariate GARCH models

 Recommended Books
 1. Ruey S. Tsay “Analysis of Financial Time Series”, (Wiley Series in Probability and Statistics) 2nd Edition,
Wiley India, Pvt. Ltd, New Delhi.
 2. Montgomery, D. C., Jennings, C. L., & Kulahci, M. (2015). Introduction to time series analysis and
forecasting. John Wiley & Sons.

 EVIEWS – Student version to download

2
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
CF – Course modules
 Module 4: Modelling volatility in time series
Modelling time series volatility: Volatility - Historical
volatility, Implied volatility models, ARCH processes,
GARCH Processes, Estimation of ARCH, GARCH
models in EVIEWS, Extensions of GARCH models,
Multivariate GARCH models

3
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Computational Finance – Course evaluation
S.NO Topics Weightage Deadlines
1 Assignments 10% TBC
2 First quiz 10% TBC
3 Case studies, class participation 10% TBC
4 Mid term 30% TBC
5 End Term 40% TBC

Assignment – Individual (Word doc. 10 to 15


pages – A4, Times New Roman 11, Plagiarism will be checked)
 Stationarity - Unit root testing
 Granger causality testing
 AR, MA, ARMA, ARIMA models in EVIEWS
 VAR or VECM modelling using EVIEWS
 ARCH, GARCH modelling in EVIEWS

4 Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data
Data Properties
Time series data Data on one or more variables over a period of time

Daily frequency Stock prices, weather reports, etc

Monthly CPI , unemployment rate


frequency

Quarterly GDP (Gross Domestic Product)


frequency

Annual frequency Annual budgets

Decennial Population census

5
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data

 Shows an upward trend


 Data is not stationary –
 Does not have a constant mean and constant variance
6
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data
Data Properties
Cross sectional Data on one or more variables collected at the same
data point of time. Eg: Number of eggs produced in 1990

7
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data
Data Properties
Cross sectional Data on one or more variables collected at the same
data point of time. Eg: Number of eggs produced in 1990

8
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data
Data Properties
Pooled data Combination of both time series and cross sectional
data
Panel data Special type of pooled data – same cross sectional
data

9
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Types of Data
Data Properties
Pooled data Combination of both time series and cross sectional
data
Panel data Special type of pooled data – same cross sectional
data

10
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Structural models – Multivariate in nature
 Eg: Linear regression analysis
 Stock returns = F ( GDP, Inflation, Unemployment…)
 Sometimes structural models are not viable
 All variables are not observable or measurable- Unemployment rate in
India
 Lower frequency –Eg: Stock prices are daily, macro economic variables
are quarterly (GDP)
 How to model ??? Can we model variables with different time frequencies
– Stocks (daily prices), GDP (quarterly), IIP (monthly)??
 Structural models are not suitable for out of sample forecasting
 Univariate models
 Based only on their past values and also based on their error term
• Time Series models -
 Also known as “ a-theoretical” models and not based on underlying theory
 ARMA and ARIMA (p,d,q) – important class of time series models
 AR- AutoRegressive & MA Moving Average

11
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Regression analysis assumptions
 The regression model

 Weekly consumption is dependent on weekly family


income

12
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Significance of error term
 1) Vagueness of theory
 Unsure of other variables in the above e.g. U I captures all other terms missing
2) Unavailability of data
 Some data may be unavailable .

Eg: Family wealth. Difficult to get the wealth details.


3) Core variables vs peripheral variables
Other variables like family size, age, sex, education, etc could also play a role.
Also interaction of these variables could play a role
For sake of brevity and cost purpose – they may be ignored and U I captures those
terms
4) Intrinsic randomness
Even after capturing all variables some intrinsic randomness may be missing Ui
captures that
5) Poor proxy variables
 Milton Firedman Permanent consumption is dependent on permanent income
 Proxy variables used - current consumption vs current income
 These proxies may not capture them accurately

13
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Significance of error term
 6) Principle of parsimony
 Regression is explained by 2 or 3 variables and other variables – unsure whether they
can have an effect – better to use lesser no. of variables
7) Wrong functional form
 Linear form and non-linear form – not chosen properly
 Ui will capture those errors

14
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Regression analysis assumptions
 1) The regression model is linear in the parameters

 2) X values are fixed in repeated sampling


15
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Regression analysis assumptions

 3) Zero mean value of disturbance


 E(ui )=0

16
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Regression analysis assumptions
 4) Homoscedasticity or equal variance of (ui )

17
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
 Regression analysis assumptions
 5) No autocorrelation between the disturbances

 6) zero or no covariance between

 7) No. of observations n must be greater than explanatory variables


 Cannot estimate the parameters from lesser no. of observations
 8) Variability in X values
 Cannot estimate the parameters
 9) Correctly specify the functional form to avoid specification error or bias

 10) There is no perfect multicollinearity among the explanatory variables

18
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time series models
• Exponential Smoothing
 Not based on ARIMA approach
 Uses a linear combination of previous values for modelling
and forecasting
 Gives more weight on recent observations than the past
values

19
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity of series
 Many financial and economic time series exhibit non
stationarity:
• Stock market indices, exchange rates, interest rates,
commodity prices
 Leads to spurious regressions
 What are the consequences of spurious regressions?

 Properties of Stationary Time Series

 Constant mean over time (i. e., no trend)

 Constant variance over time

 Correlation over time depends on relationship between Yt and


Y at some lag k, (Yt-k) doesn’t depend on any other variable.

20
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity of series
 Stationarity, is defined as a quality of a process in
which the statistical parameters (mean and
standard deviation) of the process do not change
with time. (Challis and Kitney,1991)

 A weakly stationary process has a constant mean,


constant variance and constant autovariance
structure
 A truly stationary (or strongly(strictly) stationary)
process has all higher-order moments constant
including the variance and mean. i.e the
distribution of values remain the same as time
progresses
21
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Nifty closing price vs Nifty closing returns

22
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Nifty closing price vs Nifty closing returns -
EVIEWS
Close
9,200

8,800

8,400

8,000

7,600

7,200

6,800
M10 M11 M12 M1 M2 M3 M4 M5 M6 M7 M8 M9
2015 2016

closret
.04

.03

.02

.01

.00

-.01

-.02

-.03

-.04
M10 M11 M12 M1 M2 M3 M4 M5 M6 M7 M8 M9
2015 2016

23
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
EVIEWS – Variable transformation
 Variable transformations
 Variables are transformed to make it stationary
 Generally
1) Natural log transformation
2) First differences
 Lagged variables
 Lag1 .. Lag1close = close(-1)
 Lag 2.. Lag2close = close(-2)

 Differenced Variables
 First difference – fdi = d(close)
 Second difference sdi = d(close,2)

 Returns Series
 Closeret = d(log(close)or ret1 = log(close/close(-1))

24
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity of series
 How to detect stationarity of series?
Visual inspection of time series
 Can evaluate the Autocorrelation Function (ACF)

 Can also conduct a formal test:


 Augmented Dickey-Fuller test (ADF test)
 Phillip Perron’s test (PP test)

25
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity
 A non stationary series is said to have a unit root.

 e.g. Yt= ρYt-1+ut

 If ρ=1 then series Yt has a unit root

 Null Hypothesis:

 Ho: Series has unit root and is non stationary

 HA: Series is stationary

 Here, if you reject the null, you have stationarity and thus, don’t need to
difference.

26
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity of series
 How to detect stationarity of series?
Visual inspection of time series
 Can evaluate the Autocorrelation Function (ACF)

27
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Stationarity of series
 How to detect stationarity of series?
Visual inspection of time series
 Can evaluate the Autocorrelation Function (ACF)

28
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Autocorrelation Function (ACF)
 The autocorrelation measures the correlation between
some value of a series (e.g., Y) and the value of that
series at some lag.
e.g., autocorrelation at a lag of 1 is the pairwise correlation
between Yt and Yt-1 for all n-1 pairs.

For all n-k pairs of observations


 The autocorrelation function (ACF) (Correlogram)
maps the ACF’s for various lags.

29
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Partial Autocorrelation Function (PACF)
 The Partial Auto Correlation measures the direct
correlation (for example say) between Y(t) and Y (t-2)
after removing the intermediary effect of Y(t-1)

30
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Graphical tests for autocorrelation in residuals
Positive autocorrelation in residuals

Scatter plot of residuals Residuals moving over time

31
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Graphical tests for autocorrelation in residuals
Negative autocorrelation in residuals

Scatter plot of residuals Residuals moving over time

32
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Graphical tests for autocorrelation in residuals
No autocorrelation in residuals

Scatter plot of residuals Residuals moving over time

33
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Detection of autocorrelation – Durbin Watson Test
DW test used to detect autocorrelation

Null and alternate

DW test

34
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Detection of autocorrelation – Durbin Watson Test
DW test used to detect autocorrelation

, DW =2  No autocorrelation
, DW =0  +ve autocorrelation
, DW =4  -ve autocorrelation

35
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Autocorrelation Function (ACF)
 Closing prices of Nifty series (prices)

 Replication in excel
36
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Autocorrelation Function (ACF)
Closing prices of Nifty series ( Returns)

37
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components
Components
Trend
Seasonal
Irregular
Cyclical

38
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components - Trend

Indicates long term behaviour of the time series

39
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components - Seasonal

Regular pattern – visible. Eg: Due to weather


Can be modelled using X13 – ARIMA SEATS

40
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components - Irregular

Random fluctuation

41
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components - Cyclical

Gradual up and down movements – Due to economic


factors

42
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Components -

43
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
Developed by G. P. E Box and G. M Jenkins, “Time
Series Analysis: Forecasting and Control”, 1976.

Popularly known as Box-Jenkins (BJ) methodology, but


technically known as ARIMA methodology.

A time series Yt is explained by past or lagged values of


Y itself and error terms.

ARIMA models are not derived from any economic


theory.

44
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
 Notations and concepts
 Confidence interval =
 T is the sample size

 Box & Pierce developed the Q statistic


Q =
 T= sample size
 M= max lag length
Modified Q statistic by Ljung & Box (1976)

45
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
 One can think of a time series as having structure related
to:

• long run trend

• Its’ past values

 AutoRegressive (AR) structure

• Its’ past error terms

 Moving Average (MA) structure

46
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
AR (p): Auto Regressive Process

y t    1 y t 1   2 y t 2     p y t  p  ut

MA (q) Moving Average Process

ARMA (q)
p q
yt    
i 1
i yt i  j 0
j ut  j

47
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
Original Stationary AR MA White
Series Series Structure Structure Noise

Yt Y*t Y*t = ƒ(Y*t-1,Y*t-2 ,..) Y*t=ƒ(et-1,et-2,.) ut

Modelling steps
1) Identification
2) Estimation
3) Diagnostic Checking
4) Forecasting

48
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
 1) Identification (Model Building)

 Plotting time series data


 Pattern of the ACF and PACF - Within +/- 1.96/sqrt.n
– significant (i.e. +/- 2 Standard error)

 2) Estimation

 By Least squares or
 Maximum Likelihood

49
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
3) Diagnostic Checking
How is model fit estimated for linear regressions???
For time series Information criteria (widely used)
AIC (Akaike Information Criteria)

SBC (Schwarz Bayesian Information Criteria)

50
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
Model validity tests
 Residuals plot – Correlogram
 Breusch Godfrey LM test F sig. > .05 – no serial
correlation in residuals
 Durbin Watson statistic for residuals = 2, no serial
correlation , d=0 – positive correlation, d=4 negative
correlation
 Test normality of residuals – Jarque Bera test, Shapiro
Wilks test, etc.

51
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process

AR(Autoregressive order) MA(Moving Average order)


Geometrically declining ACF ACF – No. of non-zero determines MA
order
PACF- no. of non zero determines AR Geometrically declining PACF
order

52
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process

AR(Autoregressive order) MA(Moving Average order)


Geometrically declining ACF ACF – No. of non-zero determines MA
order
PACF- no. of non zero determines AR Geometrically declining PACF
order

53
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process
AR(Autoregressive order) MA(Moving Average order)
Geometrically declining ACF ACF – No. of non-zero determines MA
order
PACF- no. of non zero determines AR Geometrically declining PACF
order

54
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process
AR(Autoregressive order) MA(Moving Average order)
Geometrically declining ACF ACF – No. of non-zero determines MA
order
PACF- no. of non zero determines AR Geometrically declining PACF
order

55
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process
AR(Autoregressive order) MA(Moving ARMA process
Average order)
Geometrically declining ACF ACF – No. of non- Decaying ACF
zero determines MA
order
PACF- no. of non zero determines AR Geometrically Decaying PACF
order declining PACF

56
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Characteristics of AR, MA process

Above details in the fig – Rarely seen


Hence, go for information criteria
AIC
SBIC
HQN

57
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Forecasting in Econometrics
 Forecasting – Determine the values that a series is likely to take.
 Why forecasting?
 Useful to make financial decisions
 More accurate the forecast more the utility
 Examples in finance where forecasting is useful
 Forecasting stock returns
 Forecasting the price of a house
 Forecasting the riskiness of portfolio
 Forecasting the volatility of bond returns
 Forecasting number of likely defaults on home loans

 Time series forecasting – Done using its previous values and/or previous
error terms
 Point forecast – predicts single value
 Interval forecasts – gives a range of values

58
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Forecasting
 In sample
 Out sample

In sample period Out of sample forecast

Jan 1990 Dec 1998 Jan 1999 Dec 1999

 One step forecast – Forecasting done only for the next step
 Multistep forecast – done for the next ‘s’ steps i.e 1,2,3,… s
steps

59
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Forecasting in Econometrics
 Some more concepts used in forecasting
 Rolling windows – The length of the period remains same
 Recursive windows – Length of the period changes due to addition

60
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Forecasting accuracy
 Forecasts produced for out of sample
Compared with actual values & diff. is aggregated in various
ways
Main types
 MSE (Mean Square Error)

 MAE (Mean Absolute Error)

 MAPE (Mean Absolute Percentage Error)

61
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Forecasting accuracy
 Forecasts error aggregation
 Example

62
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Forecasting
Forecasting errors measured by
 MEAN Square error

 Mean absolute error

 Adjusted MAPE =

T represents the total sample


T -1 represents the out of sample

63
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series Forecasting

ARMA and ARIMA Forecasting in EVIEWS


examples

64
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
Nifty prices

3000

2500

2000
Series1

1500

1000

500

0
1 20 39 58 77 96 115 134 153 172 191 210 229 248

65
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM
Time Series
 Nifty returns

0.02

0.015

0.01

0.005

0 Series1
1 21 41 61 81 101 121 141 161 181 201 221 241
-0.005

-0.01

-0.015

-0.02

66
Dr. Narend Subramanian, Prof & Chairperson Accounting & Finance, TSM

You might also like