Download Risk Analysis & Modelling

Document related concepts

Modern portfolio theory wikipedia , lookup

Transcript
Risk Analysis & Modelling
Lecture 1: Introduction
Course Website:
ram.edu-sys.net
Course Email:
[email protected]
What is Risk?
A definition of risk is the “Possibility of Loss”
When we observe risk we observe uncertainty about
a possible outcome in the future
Even if we are uncertain about the exact outcome,
we can often estimate a range of possibilities that
might occur
When some of these possible outcomes are less
favourable than others (incur a loss) we have Risk
We will be focusing on Quantitative Techniques that
can be used to describe and analyse the Risks face
by Insurance Companies
Risk And Future Outcomes
Best
Outcome
?
Current Position
Worst
Outcome
Time
Future Position
Types of Financial Risk
Financial institutions, such as Insurance
Companies, face many risks
For the purpose of study it is useful to
categorise the types of risks faced by these
institutions
Some examples of the types of risk we will
study are: Market Risk, Underwriting Risk,
Reserving Risk and Credit Risk.
We will focus on learning about these types
of Risks by using Computer Models
Market Risk
Market Risk arises from owning an asset
whose market value or price changes over
time
Market Risk can be directly observed
through movements in the market price of
the asset
An example of Market Risk would be the
possibility of the value of your portfolio
decreasing over the next year if you had
£100,000 invested in the FTSE-100
Initial Wealth
Market Asset Price
Market Asset Price
Market Asset Price
Market Risk Diagram
?
Future Wealth
Underwriting Risk
When an Insurance Company sells a policy it
Underwrites or Insures the policy holder against
a specified loss
The number of losses (or claims) and their size
are unknown when the policy is sold
These two uncertainties lead to Underwriting
Risk – the risk that the number and size of
claims will be greater than expected
Insurance Companies often model Underwriting
Risk using statistical distributions to describe the
number of losses (Frequency) and their size
(Severity)
Underwriting Risk on an Insurance
Policy
Large Claim
Insurance Policy
…………………
…………………
…………………
…………………
…………………
Average Claim
?
Small Claim
No Claim
Reserve Risk
Insurance Companies are not just uncertain about the
Frequency and Severity of claims - there is also
uncertainty about the timing of the payments of the
claims
For certain classes of Insurance (such as Liability
Insurance) there can be a delay of a number of years
between an accident or loss occurring and a final claim
payment being made
The insurance company needs to set aside capital to
pay these future claims in a Loss Reserve
The Reserve Risk is the possibility that this capital set
aside in the Loss Reserve will be insufficient to meet
the final claims (Ultimate Claims) eventually paid by
the Insurer – this is known as Under Reserving
Under Reserving is often cited as the primary cause of
Insolvency for Insurance Companies
Reserve Risk
Ultimate Claim
Loss Reserve
Less Than
Loss Reserve
Loss Reserve
Ultimate Claim
Equal To
Loss
Reserve
Loss Reserve
Ultimate Claim
Greater
?
Credit Risk
Credit Risk arises from a counter-party in an
agreement being unable or unwilling to meet
their financial obligations
For example, the Credit Risk on a bank loan is
the possibility that the borrower can no longer
pay the amount due. When the borrower
cannot pay a Default is said to have occurred.
Insurance Companies primarily experience
Credit Risk through their contracts with
reinsurance companies and the bonds they
hold in their investment portfolios
Credit Risk is harder to measure and quantify
than Market Risk since Credit Events are
infrequent.
Credit Risk Diagram
Creditor
Full
Repayment
Partial
Repayment
Debtor
No
Repayment
?
Other Types of Risk
In the literature you will find definitions for
100s of types of risk
Some other examples are Enterprise Risk,
Operational Risk, Political Risk, Strategic
Risk, Legal Risk and so on
Although many of these types of Risks are
important to Insurance Companies, we are
going to focus on Risks that we can Model
using quantitative techniques
And this course is about Modelling Risk
What is Modelling
A definition of Modelling is:
“To produce a representation or simulation of “
Risk Modelling is to Simulate Risk
The components or building blocks of our models will
be numerical and statistical techniques
A crucial part of the modelling process is to build a
simplified, abstraction of reality
Good models are often simple models which capture
important elements of the real world we wish to
examine and learn about
Bad models are often complex models which contain a
lot of irrelevant detail – complexity leads to error and
obfustication
Modelling Involves Simplification
Modelling Process:
What is Important, What
Can We Simplify?
Interpreting Model:
What Does It Mean?
Complicated Real
World Phenomena
Simplified Model of the
Real World
The Use of Computers In Risk
Modelling
Even though the models we will be building will be
simplified for the purpose of teaching they will
involve millions of calculations
Far too many calculations to make with a
calculator, pen and paper!
Risk Modelling is a practical science and this
course will show you how to build working risk
models not just talk about them!
Along with every concept we cover on the course
we will also learn the numerical and computing
techniques necessary to apply that concept in
practice
Computers and Modelling
When you buy a low end 2.8 Ghz computer with
two Cores you are purchasing a machine that
can make 5.6 billion calculations per second!
Gigahertz (Ghz) stands for billions of cycles per
second, and one cycle is roughly one calculation
So each Core can make approximately 2.8
billion calculations per second
If you were to perform 5.6 billion calculations on
a calculator at 1 calculation every 3 seconds
without rest it would take you over 500 years!
With this almost “unlimited” calculating power
the problem is often not the complexity of the
model but whether or not an individual has the
technical skills to describe the model to the
computer
Microsoft Excel
We will use Microsoft Excel to build and explore
the various Risk Models we will study
Excel is a spreadsheet software package and is
the primary tool used in the financial industry to
make calculations and build models
We will be using some of the advanced features
of Excel combined with VBA (Visual Basic for
Applications) programming techniques*
Although Excel is one of the simplest and fastest
tools with which to develop risk models it has
some limitations
VBA provides an ideal introduction to the world
of programming - which is extremely useful and
a lot easier than many people realise!
Spreadsheets and Matrices
What is a spreadsheet?
A spreadsheet can be thought of as a
giant table which can contain text,
numbers and formula.
The spreadsheet is made up of cells which
are identified by their column (represented
by a sequence of letters A,B,C,D….
,AA,AB..) and row (represented by a
number 1,2,3,4…)
The best way to learn about spreadsheets
is to play about with them….
Elements of a Spreadsheet
Numeric values
Column Identifiers
Formula; add A1 and A2
Row Identifiers
Copying and Pasting Numbers and
Formula
To avoid having to retype numbers and formula
we can copy and paste values
One important point to note is that when copying
and pasting formula in Excel the row and column
references for the input cells are shifted
This will turn out to be a very useful, time saving
feature in many of the models we will build
We can instruct Excel not to adjust the formula
by placing a ‘$’ sign in front of the elements of
the formula
Copy & Pasting Values
Formula and values copied and pasted 2 rows
to the right and 2 rows down, notice how the
formula adjusts
Matrices
Matrices are ordered blocks or tables of numbers
The numbers are organised into Rows and
Columns much like a spreadsheet
Many of the operations that can be performed on
numbers can be performed on matrices such as
addition, subtraction and multiplication
There are also some “special” matrix operations
such as inverse and transpose
Matrices are a very important practical tool for
performing large scale calculations
Matrices are also an important conceptual tools
that allows us to generalise calculations for
problems of different size
A 2 by 2 Matrix
Rows
Columns
1
2
1
8
4
2
9
1
(2,2) matrix
• This is a 2 by 2 matrix because it has 2 rows and 2 columns.
• The matrix contains a total of 4 elements.
• It is a Square matrix because it has the same number of rows and
columns
• The element at row 2 and column 1 is 9
Matrix Notation
When we wish to denote a matrix we will use a
bold capital letter:
A
A is a matrix
We denote the size or dimensions of the matrix by
giving the rows and columns of the matrix in
brackets:
A is (Rows, Columns)
When we wish to denote the element of a matrix
we will use a capital letter with two subscripts:
Ar,c
Where r is the row of the element and c is the
column of the element of matrix A
An Example of the Notation
A=
C1
C2
C3
R1
A1,1
A1,2
A1,3
R2
A2,1
A2,2
A2,3
R3
A3,1
A3,2
A3,3
A is (3,3)
A is a square matrix
Matrix Operations
We have seen that a Matrix is an ordered block of
numbers
Like numbers the meaning of a Matrix is defined by
the values they represent and additionally the order of
those values
Operations such as Addition, Subtraction and
Multiplication that can be performed on numbers can
also be performed on Matrices
Matrices and their operations are particularly useful
because they allow us to describe large blocks of
calculations simultaneously
The meaning of the operation depends on the
matrices they are applied to
Matrix Addition and Subtraction
Two Matrices A and B of dimensions (rA,cA)
and (rB,cB) can be added or subtracted if and
only if rA = rB and cA = cB (columns of A equal
columns B and rows A equal rows B)
C = A + B or C = A - B then C is the same
dimension as A and B: (rA ,cA) and (rB ,cB)
For addition, Ci,j= Ai,j + Bi,j the element at row
i column j for C is equal to the sum of the
elements at row i and column j in A and B.
The meaning of the addition of 2 Matrices
depends on the data that they store and the
order of that data.
Matrix Addition an Example
7
4
10
12
9
5
8
2
3
7+9
4+9 10+1
12+5 9+10 5+22
8+4
+
2+8 3+21
=
9
9
1
5
10
22
4
8
21
=
16
13
11
17
19
27
12
10
24
• We can add the 2 matrices because they are of the same dimension (3,3)
• The resulting matrix is of dimension (3,3)
Matrix Subtraction an
Example
17
12
12
9
8
12
17-9
12-20
12-15
9-13
8-(-12)
12-8
-
=
9
20
15
13
-12
8
=
8
-8
-3
-4
20
4
• We can subtract the 2 matrices because they are of the same dimension (3,2)
• The resulting matrix is of dimension (3,2)
Matrix Subtraction Review
Question
Subtract Matrix B from Matrix A ie (A-B)
12
A=
1
3
4
B=
7
3
Note that both A and B have a single column and are
therefore a special type of Matrix called a Vector
Matrix Subtraction Review
Question
Subtract Matrix B from Matrix A
12
1
3
-
7
3
8
12-4
4
=
1-7
3-3
=
-6
0
An Invalid Matrix Addition
7
4
10
12
9
5
8
2
3
7+9
4+9 12+?
12+5 9+10 5+?
8+?
+
2+?
3+?
=
9
9
5
10
=
16
13
?
17
19
?
?
?
?
• We cannot add the 2 matrices because they are of different dimensions
(3,3) and (2,2)
• The resulting matrix is invalid and has no meaning
Array Formula In Excel
All of the matrix operations we will be performing
in Excel will be a special class of formula called
“Array Formula”
Array Formula are different from normal Excel
formula in that they work on ranges or arrays
rather than individual cells
When entering an Array Formula an output range
is selected before the formula is typed. The
formula is entered by pressing Ctrl-Shift-Enter
Curly Brackets appear about the formula once
Ctrl-Shift-Enter is pressed
The Array Formula represents a “block” made up
of more than one cell.
Matrix Addition In Excel
Formula adds the 2 matrices “A3:C5” and “E3:G5” :“A3:C5+E3:G5”
notice the curly brackets that appear after the formula is entered with
Ctrl-Shift-Enter
Input Ranges
Output Range Selected
Matrix Subtraction In Excel
Formula subtracts the 2 matrices “A3:C5” and “E3:G5” :
“A3:C5-E3:G5” notice the curly brackets indicating an array formula
Input Ranges/Matrices
Output Range Selected
Matrix Multiplication
Matrix Multiplication is a more complex
operation and can involve many calculations.
Matrix Multiplication is one of the key
calculations we will use in our Risk Models
Two Matrices A and B of dimensions (rA,cA)
and (rB,cB) can multiplied if and only if cA = rB
C = A * B then C is of dimension (rA ,cB)
Ci,j= S Ai,k * Bk,j for k = 1 to N where N = cA =
rB
Matrix multiplication is not commutative A*B
doesn’t equal B*A
Matrix Multiplication an Example 1
B
A
5
3
2
*
(1,2)
=
4
(2,1)
C
C
5*2 + 3*4
(1,1)
=
22
(1,1)
• We can multiply these 2 matrices because the columns of A (2) is equal
to the rows of B (2)
• The resulting matrix C has a number of rows equal to 1 (since A has 1
rows) and columns equal to 1 (since B has 1 columns)
Matrix Multiplication an Example 1a
5
3
*
2
=
4
(1,2)
7
(3,1)
C
C
5*2 + 3*4 + ?*7
(1,1)
=
??
(1,1)
Matrix Multiplication an Example 2
A
B
5
3
(1,2)
*
2
4
4
8
=
(2,2)
C
5*2 + 3*4
(1,2)
5*4 + 3*8
=
22
44
Matrix Multiplication an Example
2
A
5
B
3
3
*
7
(2,2)
C
2
4
4
8
(2,2)
5*2 + 3*4
5*4 + 3*8
3*2 + 7*4
3*4 + 7*8
(2,2)
=
C
=
22
44
20
68
(2,2)
Matrix Multiplication an Example
3
B
A
9
6
*
1
0
0
1
=
(1,2)
(2,2)
C
9*1 + 6*0
C
9*0 + 6*1
(1,2)
=
9
6
(1,2)
• We can multiply these 2 matrices because the columns of A (2) is equal
to the rows of B (2)
• The resulting matrix C has a number of rows equal to 1 (since A has 1
rows) and columns equal to 2 (since B has 2 rows)
Matrix Multiplication Review
Question
Multiply these 2 matrices together:
2
9
6
*
1
1
2
=
(1,2)
(2,2)
•What is the size/dimension of the resulting matrix?
•What are its element(s)
Matrix Multiplication Review
Question
9
6
(1,2)
2
1
1
2
*
= 9*2+6*1 9*1+6*2
(2,2)
=
24
21
Matrix Multiplication In Excel
Formula multiplies matrices “A3:C5” by “E3:G5”:
“MMULT(A3:C5, E3:G5)” and outputs to the result to the selected
range I3:K5. MMULT is a special built in Excel Function.
Input Ranges/Matrices
Output Range Selected
The Transpose of a matrix
When a Matrix is Transposed its rows
and columns are interchanged
If A is of dimension (rb ,cb) then AT is of
dimension (cb ,rb) where ATj,i= Ai,j
Sometimes matrices need to be
transposed before they are multiplied or
added
Matrix Transposition an Example
A=
AT =
1
7
44
32
75
12
1
44
75
7
32
12
•The columns of matrix A become the rows of AT
•The matrix is rotated when it is transposed
Matrix Transpose Review
Question
• Transpose the following matrix:
-8
4
10
12
19
53
8
21
3
•What is the size/dimenion of the resulting matrix?
•What are its element(s)
Matrix Transpose Review
Question
-8
12
8
4
19
21
10
53
3
•What is the size/dimenion of the resulting matrix?
•What are its element(s)
Matrix Transpose In Excel
Formula transposes range “A3:B5” onto the selected output range
“D3:F4”: “Transpose(A3:B5)”. When selecting the output range
the rows/columns must be the correct shape.
Input Matrix/Range
Transposed Output Matrix/Range
Random Numbers in Excel
What are Random Numbers?
Randomness is a lack of order, cause, or
predictability
Random numbers are simply numbers that
do not have any order or pattern - they are
totally unpredictable
Computers are particularly good at
generating equally likely decimal random
numbers between 0 and 1
This type of random number is called a
Uniform Random Number
Rand function
If we want Excel to give us a uniform random
number we simply enter the formula “=rand()”
Every time you enter this formula (or press F9)
you will get a different random number between
0 and 1 - every number has an equal and very
small chance of occurring
You would have to keep F9 pressed for about 3
million years before you would see the same
number twice!
Rand is the basis of one of the most important
quantitative tools we will use on this course to
explore Risk – the Monte Carlo Simulation
Rand
Rand()
0.015345
0.247535
0.31243
0.517841 0.696173
0.89792
0.97532
Rand() randomly selects a decimal number between 0 and 1, all decimal numbers in
the range have an equal but very small probability of selection
Rand Function in Excel
To instruct Excel to generate a random number simply type =RAND()
in the cell you wish to place the random number
Random Number Between 0 and 1, this number will change every time
you enter the formula or press F9
Using Rand to Simulate
Uncertainty
Rand will allow us to simulate real world
uncertainties or risks inside the computer
and allow us to learn about their nature
Today, we will use Rand to simulate one of
the simplest random phenomenon – the
flipping of a coin
But how do we turn the output of rand()
into a heads or tails outcome?
Cutting up the Output from Rand
=Rand()
50% of Numbers
50% of Numbers
0.023342
0.723342
Less Than X
0.123342
Greater Than X
X?
0.623342
0.423342
0.923342
0.323342
0.223342
Tails Bucket
What is X?
0.823342
Heads Bucket
The IF Statement
The IF statement is one of the most important
statements in computer modelling or
programming
IF is how we teach the computer to make
decisions
It comes down to a simple statement:
IF X is true then do A otherwise do B
An example of this is IF the number is greater
than 0.5 display a 1 otherwise display a 0
The IF Function in Excel
IF is one of the more complicated
functions we will be using, it has the form:
=IF(Condition, Value if True, Value if
False)
An example of this would be
=IF(A1 > 0.5,1,0)
This would test if the value in A1 is greater
than 0.5, if this is then display a 1,
otherwise display 0
IF Function in Excel
The IF function in Excel has three parameters separated by commas,
this tests if A1 is greater than 0.5, if it is then display a 1 otherwise
display 0
Either a 1 or a 0 is displayed on the spreadsheet
depending on the value in cell A1
Coin Flipping Game
Imagine you have the opportunity to play a
game of chance in which a coin is flipped
10 times
If the coin is heads then you win £1.5, if it
is tails you lose £1
This is obviously a profitable game to play!
But there is a risk, and you want to know
how likely it is that you would lose more
than £5 if you play the game 10 times
Firstly lets simulate or model the game in
Excel….
Estimating the Risk by Simulation
Rather than using statistics we could use our
coin flipping simulation to estimate the
chance or probability of losing £5 or more
We could do this by running the simulation
100 times and counting the number of times
we lose £5 or more
This would give us an estimate of the risk or
probability of losing this amount
Although the answer we will get for the
probability or risk will vary each time we run
the simulation – why and how can we make
our answer more accurate?
Doing it the Hard Way…
We could have also calculated this
probability using mathematics and
statistics
Firstly we observe that we lose £5 or more
when we have 2 or less heads out of the
10 flips (2 heads and 8 tails would give £5, 1 head and 9 tails would give -£7.5,
and 0 heads and 10 tails would give -£10)
To calculate the probability of these 3
outcomes we would use the Binomial
Distribution
The formula for the Binomial Distribution is:
n!
. p k .(1  p) n  k
k!(n  k )!
In this case n is the number of flips (10), k is the number
of heads (0,1,2) and p is the probability of a head (0.5)
Applying this formula we find the probability of getting 0
heads is 0.00097, the probability of getting 1 head is
0.009766 and the probability of getting 2 heads is
0.043945
Summing these 3 probabilities we calculate the
probability of losing £5 or more is 0.054688 or 5.4688%
Our answer we derived from the Monte Carlo simulation
was a lot simpler to calculate but had a little bit of noise
in it – but a lot of the time a little bit of error doesn’t
matter as long as we get close enough to true answer!
Bernoulli Random Numbers & Life
Insurance
The random outcome of the flip of a coin is an example of a
Bernoulli Random Number (a random number which can
only take one of two possible values)
This type of random number is widely used in the modelling
of the Underwriting Risks for Life Insurance Companies
A Term Life Policy is a life insurance policy which usually
pays a fixed amount known as a Death Benefit to a named
beneficiary if the insured dies over the period covered
Just like the flip of a coin the insured either survives to the
end of the period covered or they die
We will now model the level of claims a Life Insurer might
incur on a portfolio (cohort) of 100 life policies each of which
has a death benefit of £10,000 and a death probability
(probability of the insured dying over the period) of 5%
Cutting up the Output from Rand
=Rand()
95% of Numbers
5% of Numbers
0.023342
0.723342
Less Than X
0.123342
Greater Than X
X?
0.623342
0.423342
0.923342
0.323342
0.223342
What is X?
0.823342
Still Alive Bucket
Dead Bucket
J
L
Simulating the Claim Payment on
One Life Policy
10000
YES
B1
?
Rand()
IF(B1>0.95,10000,0)
NO
0
Appendix: Custom Functions in
Excel
Excel allows the user to create custom functions
using VBA
These functions must be added to a Module –
which is just a special page where code for an
Excel workbook is written
To add a module to a workbook select the Visual
Basic option under the Developer Tab (if you do
not have the Developer Tab then check the
Excel Options -> Popular -> Show Developer
Tab in Ribbon) then select the Insert -> Module
menu option in the Visual Basic editor
Lets start with a simple function that adds two
numbers together
MyAdd Function
Public Function MyAdd(NumberA, NumberB)
MyAdd = NumberA + NumberB
End Function
Special VBA words are displayed in blue (keywords).
MyAdd, NumberA and NumberB are just words selected at
random.
MyAdd is the name of the function that is used to call the
function on the spreadsheet
NumberA and NumberB are used to reference the two
parameters passed into the function
To call this function from the spreadsheet we would type =
MyAdd(4,7)
In this case NumberA would be 4 and NumberB would be 7
If we wanted to add three numbers A, B and C:
Public Function Add3(A, B, C)
Add3= A + B + C
End Function
VBA also has an IF statement the following function will
display 1 the input number is greater than 2 else 0:
Public Function IsGreaterThanTwo(A)
If A > 2 Then
IsGreaterThanTwo = 1
Else
IsGreaterThanTwo = 0
End If
End Function
Appendix: Further Matrix
Operations Determinant
The determinant of a matrix is a number
which is associated with square matrices
It is useful in determining if a square
matrix is singular or not
The formula for the calculation of the
determinant in Excel is MDETEM
We will come across determinants when
we look at the Eigen Values of the
covariance matrix in a later lecture
Appendix: Further Matrix
Operations Identity Matrix
The identity matrix, often denoted by I, is a
special square matrix which when multiplied by
another square matrix A of the same dimensions
results in the same matrix A:
A.I = A
The identity matrix is a diagonal matrix with 1’s
along the principal diagonal and 0’s everywhere
else
There is no function to generate the identity
matrix in Excel (although you should be able to
make your own by the end of the course!)
Instead you can just type it in
Identity Matrix Example
A
5
I
4
3
*
7
(2,2)
A
1
0
0
1
(2,2)
5*1 + 3*0
5*0 + 4*1
3*1 + 7*0
3*0 + 7*1
(2,2)
=
A
=
5
4
3
7
(2,2)
Appendix: Further Matrix
Operations Inverse
If A is a square matrix with a non-zero
determinant then there exists another matrix A-1
known as the inverse such that:
A. A-1 = I
Where I is the identity matrix
The inverse matrix can be calculated in Excel
using the MINVERSE function
We will not be using the MINVERSE on this
course but we will be using other matrix
operations such as the Cholesky and Singular
Value Decompositions