Risk Analysis - PowerPoint PPT Presentation

About This Presentation
Title:

Risk Analysis

Description:

How difference equations can be used to model complicated patterns across time. A look at auto-correlation of volatility through ARCH, GARCH and EWMA models ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 42
Provided by: chr1103
Category:
Tags: analysis | risk

less

Transcript and Presenter's Notes

Title: Risk Analysis


1
Risk Analysis Modelling
  • Lecture 9 Auto-Correlated Risks

2
http//www.angelfire.com/linux/lecturenotes
3
What we will learn in this lecture
  • We will look at a new new measure of correlation
    auto-correlation
  • How difference equations can be used to model
    complicated patterns across time
  • A look at auto-correlation of volatility through
    ARCH, GARCH and EWMA models
  • The use of VBA to build up auto-correlated
    sequences

4
Auto-Covariance
  • Frequently we observe random sequences that have
    patterns across time
  • One such pattern is that a high value is likely
    to follow a high value, and a low value is more
    likely to follow a low value
  • These patterns across time can be measured and
    quantified using auto-covariance and
    auto-correlation
  • The measurement of auto-covariance is central to
    the idea of forecasting.

5
Auto Covariance Calculation
  • Imagine we have a sequence of returns on a stock
    r
  • The j th auto-covariance is measured by
  • The jth auto-correlation is simply

6
Auto-Correlation and Risk
  • When we have auto-correlated random variables we
    have to base our assessment of risk on the
    current sequence of events and not just on a
    single probability distribution
  • If we want to assess worse case scenarios in the
    future we must take into account the direct
    correlations between the future and the present
  • So far we have been dealing with unconditional
    risk what is likely to happen in the future
    regardless of current patterns
  • With auto-correlation we must take into account
    current patterns and use an estimate conditional
    on recent patterns or a Conditional Expectation

7
A simple model of an auto-correlated random
variable
  • Imagine we have a random variable whose
    observation at time T is
  • Where e is a sequence of normally distributed
    random variable with mean 0 (Gaussian White
    Noise)
  • This sequence will exhibit auto-covariance
    between Yt and Yt-1
  • It is called an MA(1) process (moving average one
    process)

8
Properties on MA(1)
For all j gt 1
Where s2 is the variance of the Gaussian White
Noise process e
9
Forecasting a MA(1) Process
  • If we want to try to forecast the value for Yt1
    we need to take into account the autocorrelation,
    the optimal forecast is obviously not the
    unconditional mean m!
  • We already know the value for et since we have
    observed the current period so the conditional
    expectation of Yt1 based on our observation of
    et is
  • Our best guess for et1 is 0
  • Note that the uncertainty of our forecast is
    dependant upon the variance of e, s2

10
MA(Q) process
  • We can model systems with longer sequences of
    autocorrelations by extending the sequence of the
    MA
  • By extending the number of lags of the white
    noise process for the MA we increase the length
    of the auto-correlations

11
The AR process
  • Another way of representing serially correlated
    random variables is Auto Regression
  • The AR process represents the next value in the
    sequence in terms of the previous value(s) and a
    white noise element.
  • For an AR(1) process the representation is
  • The AR(1) is an example of a first order
    difference equation
  • It can be shown that if 1ltalt1 then the AR(1) can
    be represented as a restricted MA(inf) series

12
Proof of MA(Inf) representation
  • By substitution
  • Repeating again
  • If a lt1 then an will get smaller as n becomes
    larger.

13
Stationarity
  • Our assumption that 1ltalt1 is vital to the
    stationarity of the AR time series
  • We could invert the AR into an MA because an will
    become small and we can ignore it for large n
  • If agt1 then we cannot ignore an for large n
  • It means that across time shocks or noise (e)
    will decay and the time series will return to a
    central tendancy
  • If a gt 1 then the effect of a shock or noise
    compounds over time, so a shock 10 years ago will
    have a bigger effect today than it did then!
  • Series which compound like this shoot off to
    infinity at the first opportunity and are not of
    interest
  • A special case is where a 1, in this case we
    have a random walk
  • This is why sometimes a random walk is called a
    unit root process

14
The problem with MA
  • The MA representation is powerful because it
    represents future values interms of white noise
    with mean 0, this is very useful for forecasting
  • The problem with the MA process is that we cannot
    directly observe the e we only observe the
    resulting serially correlated series (Yt)
  • Is it possible to represent the MA process in
    terms of Yt rather than in terms of the hidden e?
  • It turns out that we can use an AR (auto
    regressive process) and a MA process
    interchangeably
  • This transformation is closely linked to the
    covariance stationarity of the series

15
Invertability of a MA(1)
  • It can also be shown that an MA(1) process can be
    inverted to an AR(inf) process
  • Using this inversion we can calculate the hidden
    e terms for the MA process!
  • For an MA(1) process this inversion take the
    form, where 1ltalt1

16
Proof of AR(inf) representation
By substitution
By further substitution
17
General Inversions of AR(n) and MA(n)
  • The AR(1) and MA(1) inversions are fairly simple
  • To calculate AR(n) and MA(n) inversions we need
    to express them as Lag Polynomials
  • We then need to factor the real and complex roots
    of the lag polynomial
  • It can be thought of as factoring AR(n) into the
    product of a AR(1)s and MA(n) into the product of
    MA(1)s
  • Each of these factors can then be inverted using
    the AR(1) and MA(1) inversions we just looked at
  • It can be shown that there is an equivalence
    between finding the roots of a Lag Polynomial and
    finding the Eigen Values of a special matrix
    describing difference equations
  • We are not interested in this calculation!

18
Forecasting Volatility ARCH GARCH
  • There is a lot of empirical evidence to suggest
    that volatility is serially correlated
  • We can therefore forecast volatility more
    accurately than we can forecast returns
  • This is important because risk is dependant upon
    volatility
  • ARCH and GARCH are volatility forecast models
  • We want our estimates/forecasts of volatility to
    be as accurate as possible so our estimate of
    risk are accurate
  • We intuitively expect volatility to be
    auto-correlated

19
The ARCH model
  • ARCH stands for Auto Regressive Conditional
    Heteroskedasticity
  • A simple AR(1), ARCH(1) model is
  • Where ut or the noise follows a process
  • Where et is a white noise process bounded from
    bellow by d (ie we cut the normal distribution
    off at d)
  • We need to do this because is et lt d then ut2
    could be negative, which is obviously nonsense!

20
Back To Our Model of Returns
  • Our returns model can be thought of as an AR(0)
    or MA(0) process (which are identical)
  • Where m is the mean of returns and ut is a random
    normal noise with mean 0 and variance equal to
    the variance of returns that follows an ARCH
    process, we will use an ARCH(1)
  • Notice that since ut has a mean zero ut2 can be
    thought of as our forecast for variance (s2) of
    returns at time t

21
ARCH Observations
  • Using our AR(1) to MA(inf) inversion trick
  • If we take the long run expectation of s2 or the
    unconditional mean by assuming all e are 0
  • For this reason the ARCH process is sometimes
    written as

22
Forecasting Volatility With ARCH
  • We can forecast volatility by using our best
    estimate for the e, which we expect to be 0
  • Our forecasts of volatility decay toward the long
    run expectation for variance

23
ARCH Forecasts
Initial Volatility Above Long Run Expectation
Volatility Forecast
Forecast s2
As time progresses our ARCH forecast decays to
the Long Run
Long Run Centre of Variance
Time
24
GARCH Model
  • GARCH is Generalised ARCH
  • GARCH can be derived from an ARCH(inf)
  • The forecast volatility forecast made by GARCH is
    based on previous forecasts and previous
    observations
  • GARCH(1,1) would take the form
  • Where e is standard normal noise N(0,1)

25
Interpretation of GARCH
  • The correct interpretation of the GARCH model is
    that it adapts its forecast of volatility using
    its previous forecast error
  • ut2-st2 is the difference between our forecast of
    volatility and the observed volatility
  • We can see that GARCH adjusts its estimates not
    only on previous observations but also on
    previous forecast errors
  • GARCH automatically adjusts itself to take into
    account its previous errors! GARCH is self
    correcting!

26
Estimating ARCH and GARCH
  • We could estimate ARCH and GARCH in Excel
  • We will not be doing this but the process would
    be to use a maximum likelihood methodology
  • We would get solve to maximise the likelihood of
    observing the specified process by changing the
    parameters of the ARCH or GARCH model
  • For GARCH(1,1) solver would maximise the
    Log-Likelihood by altering a, b and k
  • It would find the values for a, b and k that
    maximised the likelihood of observing the process
    for the dataset we provide
  • The likelihood method is central to fitting Time
    Series in general

27
EWMA Model
  • The Exponentially Weighted Moving Average model
    is simply a weighted moving average between the
    current innovation ut and our previous forecast
    for volatility
  • It behaves like ARCH but is simpler
  • JP Morgan uses EWMA with l 0.94 for daily
    volatility VAR forecasts

28
Part 2 Visual Basic For Applications
29
What is a computer program?
  • A computer program is an ordered list of
    instructions given to the computer
  • The programming language defines the structure
    that this list of instructions take
  • Different programming languages have different
    structures
  • VBA is the programming language used by Excel and
    Microsoft office

30
The basic building blocks
  • We will divide our program into two logical
    blocks operations and variables
  • Variables are spaces in the computers memory
    where we store data
  • We declare variables using the programming
    language and give them a unique name
  • Statements are used to do things to variables and
    give the computer instructions
  • The computer executes statements in the order
    they are typed in

31
Variables
  • A variable is like a box with a name on it
  • We use this name to identify and to perform
    operations on the variable
  • We can give a variable any name we want, we could
    call it MyVariable or ForecastVolatility
  • Variable names cannot contain spaces
  • We will deal with 3 types of variables Integers
    (boxes used to store whole numbers 1,2,3), Double
    (boxes used to store decimal numbers 3.1416), and
    String (boxes used to store text such as The
    Quick Fox)

32
Creating a variable
  • Say we want to create a box or variable that can
    store a decimal number or Double, in VBA we would
    write
  • Dim DailyReturn as Double
  • Dim is short for Dimension
  • If we wanted to create a variable containing an
    Integer we would say
  • Dim NumberOfStudents as Integer
  • If we wanted to create a variable containing a
    some text we would say
  • Dim StudentName as String
  • It is upto us how many variables we declare and
    the names we give them!

33
Statements
  • A statement is a command the programmer gives to
    the computer to do something
  • A statement must take up a single line
  • An example of a statement is
  • NumberOfStudents 10
  • This would assign the number 10 to our integer
    variable NumberOfStudents
  • Another statement would be
  • NumberOfStudents NumberOfStudents 2
  • This would double the integer number currently
    stored in NumberOfStudents

34
A Subroutine
  • We will think of a Subroutine as a mini computer
    program
  • A subroutine has a name
  • A subroutine consists of a series of variables
    and statements that perform a task we as
    programmers want to explain to the computer
  • A sub routine is a named list of instructions we
    give the computer
  • Once we have created the subroutine we can tell
    the computer to run the instructions by saying
  • Call CalculateRisk
  • Where CalculateRisk is the name of the subroutine

35
Declaring A Subroutine
  • A Subroutine is declared as follows
  • Sub CalculateRisk()
  • (INSTRUCTIONS AND
  • VARIABLES GO HERE!)
  • ..
  • End Sub
  • The CalculateRisk is the name we give the list of
    instructions and variables
  • The computer goes through the list sequentially
    until it sees the End Sub statement and then
    stops
  • End Sub is the end of the list of commands

36
A Simple Subroutine
Sub CalculateRisk() Dim Volatility as Double
Dim VAR as Double Volatility 0.03 VAR
1.96 Volatility Cells(1,1) VAR End Sub
This subroutine first declares two variables
Volatility and VAR it assigns 0.03 to Volatility
then sets VAR to 1.96 Volatility. Finally it
outputs the value stored in VAR to cell A1 or
Cells(1,1) of the current spread sheet
37
More Complicated
  • Lets say we want to let the user of our program
    type in the volatility. We use the InputBox
    Function built into VBA

Sub CalculateInputRisk() Dim Volatility as
Double Dim VAR as Double Dim UserInput as
String UserInput InputBox(Input Today
Volatility) Volatility CDbl(UserInput) VAR
1.96 Volatility Cells(1,1) VAR End Sub
38
The If statement
  • The If statement is a very powerful programming
    concept
  • It allows us to tell the program to do different
    things depending on the value of a variable
  • The simple if statement takes the form
  • If VAR gt 0.5 then call MsgBox(This is too
    Risky)
  • This if statement can be written
  • If VAR gt 0.5 then
  • call MsgBox(This is too Risky!)
  • End If
  • This second type of statement is called a block
    if
  • More than one statement can be put between the
    If VAR gt 0.5 then and End If
  • For example
  • If VAR gt 0.5 then
  • call MsgBox(This is too Risky!)
  • cells(2,1) Risky!
  • End If
  • This will display a MsgBox and then output the
    text Risky! to cells(2,1), or row2 column1
    (A2)

39
The Do While Loop
  • Often in a program we want to repeat a task a
    number of times
  • One form of loop is the Do While Loop
  • Bellow is an example of a subroutine that will
    fill cells in column A with all the numbers
    between 1 and 100

Sub FillCellsUp() Dim Counter as Integer
Counter 1 Do While Counter lt 100
Cells(Counter, 1) Counter Counter Counter
1 Loop End Sub
40
A Function
  • A function has a name and describes a sequence of
    statements which perform operations on some input
    variables and produces an output variable or
    answer
  • An example of a function which averages 2 double
    variables and returns a double is

Function Average(NumOne as Double, NumTwo as
Double) as Double Average (NumOne NumTwo) /
2 End Function
  • NumOne and NumTwo are the inputs and the Answer
    is returned by set the function name equal to a
    value
  • Functions are very useful because they let us
    split up bigger programs into small sections!

41
Our First Useful Program!
  • We will generate a serially correlated sequence
    of returns using an MA(1) process
  • We will use a helper function I have created
    called BoxMuller which returns a random number
    sampled from a standard normal distribution
  • We will use a loop to calculate a sequence of 100
    variables from this sequence
  • It will take abit of thought to understand all
    the statements but once we can we are on the way
    to becoming programmers!
Write a Comment
User Comments (0)
About PowerShow.com