# 辅导MAST90051、辅导MATLAB设计程序

- 首页 >> Database作业 Mathematics of Risk Problem Sheet 6/2022

Assignment 1

Posted on LMS on Wedn. 31 August 2022 (announced via LMS on the same day).

Submission deadline: 23:59 AEST on Monday 19 September 2022.

Your solutions must be submitted via Canvas/Gradescope (see below). Late submissions

will receive no mark unless you have a valid reason for extension, in which case you should

contact the lecturer in advance.

Print your name, student ID, the subject name & code in the top right corner on

the first page of your solutions. Your solutions must be written on blank A4 size paper.

There is no need to typeset your solutions, but you may wish to do so. Material on different

sized paper will not be marked.

All problems should be attempted. Working and/or reasoning must be given to obtain

full credit. The form and neatness of work can be considered in marking.

Do not include tables of data sets in your solutions! Reasonable data summaries

would be enough. Please do not exceed 15 pages, OK?

If you typeset your solutions, produce a single PDF file with your submission. If you wrote

them, scan your submission to a single PDF file with a mobile phone1 or a scanner. Scan

from directly above to avoid any excessive keystone effect. Check that all pages are in cor-

rect order, are clearly readable and cropped to the A4 borders of the original page. Poorly

scanned submissions may be impossible to mark.

Even if you typed up your solutions and will be submitting the resulting PDF file, I would

still recommend you to do some scanning practice. This may prove to useful in the future.

Upload the PDF file via the Canvas Assignments menu and submit the PDF to the Grade-

scope tool by first selecting your PDF file and then clicking on Upload PDF. Gradescope will

then ask you to identify on which of the uploaded pages your answers to each question are

located.

1. Driven by the collected data and directed by her supervisor, an MSc student

assumed that the loss L for a financial product she was modelling is described

by a distribution with density f(x) = 18

5

(x+ 2)?4(x+ 1 + ln(x+ 2)), x ≥ ?1.

(a) Compute the distribution tail F (x), x ∈ R, for L. Plot the functions f(x)

and F (x) on the interval [?1, 5]. [2 marks]

(b) Compute the median, mean and variance of L. Here and in the other parts

of this question below, please provide numerical answers rounded to two

digits after the decimal point. [3 marks]

(c) Compute the values of VaRα(L) and ESα(L) and find the values of the ratios

ESα(L)/VaRα(L) for α = 0.95; 0.99; 0.995. Present your results in the form

of a nice table. Comment on your findings. [3 marks]

1You may wish to use CamScanner.

1

(d) Simulate n = 200 independent samples each consisting of 100 independent

realisations of the loss L with density f (so that you’ll have to simulate

2× 104 random numbers altogether). For each of the simulated n samples,

compute estimates for VaR0.95(L) and ES0.95(L). To evaluate the perfor-

mance of the estimators used, compute the sample mean and sample stan-

dard deviation for each of the two samples (of size n each) of the estimates

you obtained (for VaR and ES). Present your findings in the form of a nice

table and comment on them (in a few sentences). [5 marks]

Hints: It may happen that you will need to use numerical procedures to do at least some of the

tasks from this problem. Note that, when using real maths to solve real world problems, one

can rarely avoid using such procedures. You can use any suitable software package you wish.

For instance, Mathematica would be fine, but MATLAB, R or even MS Excel could also

be used. For a list of commercial software avilabe for downloading to our students, please visit

https://studentit.unimelb.edu.au/software

(d) In the context of this problem, the easiest way to simulate RVs from the required distribution

may be to use the “Inverse Function Method” (we did mention it in class). If you haven’t

seen/used it before, look it up on the WWW or elsewhere. It is very simple. Note that the

inverse to the distribution function (or its tail) may not be available in a closed form (which

is the most usual situation in applications). In that case, one can use a numerical equation

solver (e.g., FindRoot in Mathematica). Uniform random variates are supplied for free by

most maths/stats software packages.

It is very instructive to repeat the simulations for part (d) several times to see how variable

the results may be (despite the sample size n = 200 being relatively large).

2. Your lecturer heard that, on 2 January 2020, one of our former students (we

will call him Mr X) purchased ν1 = 10, 000 Swiss franks, ν2 = 100 BioNTech

SE shares (traded at the high-tech NASDAQ stock exchange, in US$), and also

ν3 = 1, 000 National Australia Bank shares (traded on the Australian Stock

Exchange, ASX, in AU$). Mr X kept the composition of this portfolio unchanged

until 30 December 2021.

Your lecturer kindly downloaded the stock (“adjusted close”) prices and currency

exchange rates daily data from the WWW2, “cleaned”3 the data (note that dif-

ferent countries may have different holidays, so there can be days where there

will be data available for some but not all assets etc) and put the relevant to this

question data in one Excel file, Data_for_asst_1_2022.xlsx. Please download

that file from LMS (you will find a link to it in “Week 06 problems” sub-module)

and use the data from that file when doing this question. We labelled the days

for which the prices are presented in the Excel file by t = 0, 1, 2, . . . , T = 494).

(a) What risk factors Zt = (Zt,1, . . . , Zt,d)

′ are appropriate for this portfolio?

Specify them. Map the risks by representing the day t = 0, 1, . . . , T portfolio

value Vt as a function of Zt and hence give representations for the loss values

2From https://au.finance.yahoo.com.

3You will be pleased to learn that, until recently, this dirty tedious work had always been done by

students. For those days for which there is data for one stock exchange but not for the other, we just

deleted the available data. That’s OK for the purposes of this exercise.

2

Lt+1 (in terms of the day t risk factors’ values and their next day changes X t+1 :=

Zt+1?Zt), the loss operator l[t](x) and the linearised loss operator l?[t](x) of the

portfolio. [6 marks]

(b) Calculate the maximum difference max1≤t≤T |Lt?L?t | between the true losses

and the linearised losses of the portfolio during the indicated time period. On

what day was it observed? What risk factors you think were mostly responsible

for that largest discrepancy? Explain. [2 marks]

(c) Compute the average relative discrepancy between the true and linearised

losses and the average absolute relative loss/gain of the portfolio, i.e. the values

1

T

T?1∑

t=0

|Lt+1 ? L?t+1|

Vt

and

1

T

T?1∑

t=0

|Lt+1|

Vt

.

Compare the former with the latter and comment on your findings. [2 marks]

(d) Calculate the numerical values of the coefficients appearing in the expression

for the linearised loss operator l?[t0] on day t0 := 490, i.e., 21 Dec 2021. [1 mark]

(e) Compute the method-of-moments estimates of the mean vector and covariance

matrix for the vector X t of the risk factor changes, basing on the whole data set

(from 02 Jan 2020 to 30 Dec 2021). [2 marks]

(f) Use the Variance–Covariance Method and your results from parts (d) and (e)

to calculate VaR0.95(Lt0+1) and ES0.95(Lt0+1). [This means you will be using

“future data” (relative to time t0), cf. (e). That’s OK, just do that.] [3 marks]

(g) Use the historical simulation method to produce a sample of simulated losses

L?u = l[t0](Xu), u = t0?n+ 1, t0?n+ 2, . . . , t0, for n = 400 and plot a histogram

for it. Use the sample to give a quantile estimator for VaR0.95(Lt0+1) and an

estimator for ES0.95(Lt0+1). Compare your estimates with the results of part (f)

and comment. [4 marks]

Hints: (g) Note that you should get L?t0+1 = Lt0+1 (just in case: to check if what you are doing

is correct). To estimate ES0.95 use an empirical quantile-based analog of that quantity (it was

given in lectures and, of course, is referred to in the text as well).

3. (a) Show that

Σ =

?? 4 ?2 1?2 5 2

1 2 2

??

is a covariance matrix. [1 mark]

(b) Compute (by hand!) the (lower triangular) Cholesky factor for the matrix Σ.

Show your work. [2 marks]

(c) Let X = (X1, X2, X3)

′ be a normal random vector with mean (1, 2, 3)′ and co-

variance matrix Σ. Compute and plot the densities of the subvectors [i] (X1, X2)

′,

3

[ii] (X1, X3)

′, and [iii] (X2, X3)′. In each of the three cases [i]–[iii], make a 3D sur-

face plot and a contour plot, both on the square [?3, 7]2. Briefly comment on

your findings. [3 marks]

(d) Make a 3D surface plot and a contour plot for the mixture density

0.8f(X1,X2)′(x1, x2) + 0.2f(X2,X3)′(x1 ? 1, x2 ? 1).

Looking at the plots, would you ever think they are of a simple normal mixture

with just two components? [1 mark]

Hint: (c) This is a simple technical task that can easily be done using, say, Mathematica.

One may wish to use any other suitable software package, of course. (d) Ditto.

Assignment 1

Posted on LMS on Wedn. 31 August 2022 (announced via LMS on the same day).

Submission deadline: 23:59 AEST on Monday 19 September 2022.

Your solutions must be submitted via Canvas/Gradescope (see below). Late submissions

will receive no mark unless you have a valid reason for extension, in which case you should

contact the lecturer in advance.

Print your name, student ID, the subject name & code in the top right corner on

the first page of your solutions. Your solutions must be written on blank A4 size paper.

There is no need to typeset your solutions, but you may wish to do so. Material on different

sized paper will not be marked.

All problems should be attempted. Working and/or reasoning must be given to obtain

full credit. The form and neatness of work can be considered in marking.

Do not include tables of data sets in your solutions! Reasonable data summaries

would be enough. Please do not exceed 15 pages, OK?

If you typeset your solutions, produce a single PDF file with your submission. If you wrote

them, scan your submission to a single PDF file with a mobile phone1 or a scanner. Scan

from directly above to avoid any excessive keystone effect. Check that all pages are in cor-

rect order, are clearly readable and cropped to the A4 borders of the original page. Poorly

scanned submissions may be impossible to mark.

Even if you typed up your solutions and will be submitting the resulting PDF file, I would

still recommend you to do some scanning practice. This may prove to useful in the future.

Upload the PDF file via the Canvas Assignments menu and submit the PDF to the Grade-

scope tool by first selecting your PDF file and then clicking on Upload PDF. Gradescope will

then ask you to identify on which of the uploaded pages your answers to each question are

located.

1. Driven by the collected data and directed by her supervisor, an MSc student

assumed that the loss L for a financial product she was modelling is described

by a distribution with density f(x) = 18

5

(x+ 2)?4(x+ 1 + ln(x+ 2)), x ≥ ?1.

(a) Compute the distribution tail F (x), x ∈ R, for L. Plot the functions f(x)

and F (x) on the interval [?1, 5]. [2 marks]

(b) Compute the median, mean and variance of L. Here and in the other parts

of this question below, please provide numerical answers rounded to two

digits after the decimal point. [3 marks]

(c) Compute the values of VaRα(L) and ESα(L) and find the values of the ratios

ESα(L)/VaRα(L) for α = 0.95; 0.99; 0.995. Present your results in the form

of a nice table. Comment on your findings. [3 marks]

1You may wish to use CamScanner.

1

(d) Simulate n = 200 independent samples each consisting of 100 independent

realisations of the loss L with density f (so that you’ll have to simulate

2× 104 random numbers altogether). For each of the simulated n samples,

compute estimates for VaR0.95(L) and ES0.95(L). To evaluate the perfor-

mance of the estimators used, compute the sample mean and sample stan-

dard deviation for each of the two samples (of size n each) of the estimates

you obtained (for VaR and ES). Present your findings in the form of a nice

table and comment on them (in a few sentences). [5 marks]

Hints: It may happen that you will need to use numerical procedures to do at least some of the

tasks from this problem. Note that, when using real maths to solve real world problems, one

can rarely avoid using such procedures. You can use any suitable software package you wish.

For instance, Mathematica would be fine, but MATLAB, R or even MS Excel could also

be used. For a list of commercial software avilabe for downloading to our students, please visit

https://studentit.unimelb.edu.au/software

(d) In the context of this problem, the easiest way to simulate RVs from the required distribution

may be to use the “Inverse Function Method” (we did mention it in class). If you haven’t

seen/used it before, look it up on the WWW or elsewhere. It is very simple. Note that the

inverse to the distribution function (or its tail) may not be available in a closed form (which

is the most usual situation in applications). In that case, one can use a numerical equation

solver (e.g., FindRoot in Mathematica). Uniform random variates are supplied for free by

most maths/stats software packages.

It is very instructive to repeat the simulations for part (d) several times to see how variable

the results may be (despite the sample size n = 200 being relatively large).

2. Your lecturer heard that, on 2 January 2020, one of our former students (we

will call him Mr X) purchased ν1 = 10, 000 Swiss franks, ν2 = 100 BioNTech

SE shares (traded at the high-tech NASDAQ stock exchange, in US$), and also

ν3 = 1, 000 National Australia Bank shares (traded on the Australian Stock

Exchange, ASX, in AU$). Mr X kept the composition of this portfolio unchanged

until 30 December 2021.

Your lecturer kindly downloaded the stock (“adjusted close”) prices and currency

exchange rates daily data from the WWW2, “cleaned”3 the data (note that dif-

ferent countries may have different holidays, so there can be days where there

will be data available for some but not all assets etc) and put the relevant to this

question data in one Excel file, Data_for_asst_1_2022.xlsx. Please download

that file from LMS (you will find a link to it in “Week 06 problems” sub-module)

and use the data from that file when doing this question. We labelled the days

for which the prices are presented in the Excel file by t = 0, 1, 2, . . . , T = 494).

(a) What risk factors Zt = (Zt,1, . . . , Zt,d)

′ are appropriate for this portfolio?

Specify them. Map the risks by representing the day t = 0, 1, . . . , T portfolio

value Vt as a function of Zt and hence give representations for the loss values

2From https://au.finance.yahoo.com.

3You will be pleased to learn that, until recently, this dirty tedious work had always been done by

students. For those days for which there is data for one stock exchange but not for the other, we just

deleted the available data. That’s OK for the purposes of this exercise.

2

Lt+1 (in terms of the day t risk factors’ values and their next day changes X t+1 :=

Zt+1?Zt), the loss operator l[t](x) and the linearised loss operator l?[t](x) of the

portfolio. [6 marks]

(b) Calculate the maximum difference max1≤t≤T |Lt?L?t | between the true losses

and the linearised losses of the portfolio during the indicated time period. On

what day was it observed? What risk factors you think were mostly responsible

for that largest discrepancy? Explain. [2 marks]

(c) Compute the average relative discrepancy between the true and linearised

losses and the average absolute relative loss/gain of the portfolio, i.e. the values

1

T

T?1∑

t=0

|Lt+1 ? L?t+1|

Vt

and

1

T

T?1∑

t=0

|Lt+1|

Vt

.

Compare the former with the latter and comment on your findings. [2 marks]

(d) Calculate the numerical values of the coefficients appearing in the expression

for the linearised loss operator l?[t0] on day t0 := 490, i.e., 21 Dec 2021. [1 mark]

(e) Compute the method-of-moments estimates of the mean vector and covariance

matrix for the vector X t of the risk factor changes, basing on the whole data set

(from 02 Jan 2020 to 30 Dec 2021). [2 marks]

(f) Use the Variance–Covariance Method and your results from parts (d) and (e)

to calculate VaR0.95(Lt0+1) and ES0.95(Lt0+1). [This means you will be using

“future data” (relative to time t0), cf. (e). That’s OK, just do that.] [3 marks]

(g) Use the historical simulation method to produce a sample of simulated losses

L?u = l[t0](Xu), u = t0?n+ 1, t0?n+ 2, . . . , t0, for n = 400 and plot a histogram

for it. Use the sample to give a quantile estimator for VaR0.95(Lt0+1) and an

estimator for ES0.95(Lt0+1). Compare your estimates with the results of part (f)

and comment. [4 marks]

Hints: (g) Note that you should get L?t0+1 = Lt0+1 (just in case: to check if what you are doing

is correct). To estimate ES0.95 use an empirical quantile-based analog of that quantity (it was

given in lectures and, of course, is referred to in the text as well).

3. (a) Show that

Σ =

?? 4 ?2 1?2 5 2

1 2 2

??

is a covariance matrix. [1 mark]

(b) Compute (by hand!) the (lower triangular) Cholesky factor for the matrix Σ.

Show your work. [2 marks]

(c) Let X = (X1, X2, X3)

′ be a normal random vector with mean (1, 2, 3)′ and co-

variance matrix Σ. Compute and plot the densities of the subvectors [i] (X1, X2)

′,

3

[ii] (X1, X3)

′, and [iii] (X2, X3)′. In each of the three cases [i]–[iii], make a 3D sur-

face plot and a contour plot, both on the square [?3, 7]2. Briefly comment on

your findings. [3 marks]

(d) Make a 3D surface plot and a contour plot for the mixture density

0.8f(X1,X2)′(x1, x2) + 0.2f(X2,X3)′(x1 ? 1, x2 ? 1).

Looking at the plots, would you ever think they are of a simple normal mixture

with just two components? [1 mark]

Hint: (c) This is a simple technical task that can easily be done using, say, Mathematica.

One may wish to use any other suitable software package, of course. (d) Ditto.