You are on page 1of 5

Assignment II

Out: 13 November 2018


In: 18 December 2018

Mathematics for Economics and Finance

Prof: Norman Schürhoff


TAs: Jakub Hajda, Jimmy Lerch

• The assignment contains 2 exercises and 1 bonus exercise.


• The maximum number of points to be obtained from the regular exercises is 40.
• Solving the bonus exercise can give you 10 additional points.
• The assignment must be turned in at the beginning of the class on 18 December 2018.

• All assignments turned in late will be not graded. Non-graded assignments result in zero grade.
• The assignment must be done in groups of three or four students. Only one copy of solution per group is
submitted. Please attach the printout of your Matlab code as well if asked.
• Note: If a value cannot be computed, please briefly explain why.

1
Exercise 1
This exercise will guide you through the theoretical and practical aspects of estimating statistical parameters.
Please carry out explicitly (that is, by hand) all analytical derivations and attach the printout of your Matlab
codes when you use it.

Part 1
In finance and insurance we are often interested in modelling extreme events, that are large in magnitude but
also very rare. Distributions that allow for modelling such outcomes are said to have ‘heavy tails.’ One such
distribution is characterized by the following pdf:
 η+1
η λ
f (X = x|η, λ) = , x ≥ λ, λ > 0, η > η0 .
λ x

Consider an i.i.d. sample of n random variables (X1 , X2 , . . . , Xn ), each following this distribution.
(a) Construct analytically estimators for η and λ using the method of moments (MM) and the method of
maximum likelihood (ML). Provide a condition on η0 such that the first two moments exist.

bM L think how the log-likelihood depends on λ and what the constraint on λ is.
Hint: to compute λ

Part 2
Now you will learn how to simulate any random variable with a given pdf by inverting its cdf. To do so, we will
apply the following theorem:

Theorem 0.1 (Probability integral transform)


If X is a continuous random variable with cumulative distribution function FX (t), then the random variable
Y = FX (t) has a uniform distribution on [0, 1]. Thus, if Y has uniform distribution on [0, 1], and if X has cdf
−1
FX (t), then the random variable FX (Y ) has the same distribution as X.

(a) Compute analytically the cdf of X, FX (t).

(b) Suppose we have a realization u of a uniformly distributed random variable U ∼ U(0, 1). Find the inverse
of FX (u).

Hint: Start from F (F −1 (u)) = u.

Thus, if you have a random number u that is a realization of a uniformly distributed random variable, you can
−1
immediately generate the corresponding x: x = FX (u).
(c) To make sure you got it right, simulate a sample of 105 realizations of x and plot its distribution.

Part 3
Now you will investigate numerically the properties of the two η estimators using simulation. To do so, apply the
following Monte Carlo (MC) algorithm in Matlab. Assume that the true value of η is 2.85 and that λ is fixed
at 1.
• Generate N random vectors xi , i = 1, . . . , N , each containing n realizations of the random variable x.
Simulate the data using the true parameter value with the algorithm derived in Part 2. Do not forget to
fix the seed to generate the same random numbers each time you run your code. For this purpose, use the
routine below (keep the same seed):

2
% Set the seed
RandomSeed = 12321;
forsim = RandStream.create(’mrg32k3a’,’Seed’,RandomSeed);

% Generate realizations of uniform random variables of size (n,N) using the seed
u = rand(forsim,n,N);

• Compute your estimates ηbiM M and ηbiM L for each i = 1, . . . , N .


MM
• Now you can compute the parameter estimate by averaging the sample-specific estimates, that is η¯b =
1
P N MM ¯bM L 1
PN ML
N η
i=1 i
b and η = N η
i=1 i
b . This estimate is called the ‘Monte Carlo estimate.’ Similarly you
can compute the standard errors of the estimator as the standard deviation of the sample-specific estimates
as well as any other moments.
Using this algorithm for N = 1000 samples and four cases n ∈ {5, 50, 500, 5000}, answer the following questions.
(a) Check if each estimator is unbiased by getting the Monte Carlo estimate of the parameter for each n and
computing explicitly biasη = E(η − ηb). Present your results. What do you observe?
(b) Plot the distribution of the MC estimates for each n for the two estimators of η. That is, each of the two
graphs should contain four lines, each corresponding to the distribution specific to a given n. How do the
distributions change? What do these results imply about the consistency of the MM and ML estimators?

(c) Compare the MM and ML estimators of η in terms of their relative efficiency (that is, the ratio of the Monte
Carlo estimates of their variances). Present your results. Do the results depend on n? Which estimator do
you prefer?
(d) Compute the Monte Carlo estimate of the mean-squared error of ηb (and both ML and MM) and each n.
Present your results. Comment on your results. Which estimator do you prefer?

(e) Compute analytically the standard error of ηbM L . Present your results. How does it compare to the numerical
ones for different n?

Exercise 2
Stephen has a hobby of building matchstick houses. His construction function is C(x, y) = A(xα + y β )γ , where
x is the number of matchboxes and y is the number of bottles of glue used. Stephen’s budget constraint is
W ≥ Rx + M y, where W is his budget, R is the price of a matchbox and M is the price of a bottle of glue. Let
G be the constraint set, that is, the set of all feasible construction bundles.
(a) Formulate the optimization problem.

(b) Is constraint qualification satisfied?


(c) Does C(x, y) achieve a maximum on G?
(d) Formulate the Kuhn-Tucker conditions.

(e) Solve the optimization problem for the following values of the parameters A = 1, α = 1, β = 0.5, γ =
1, R = 2, M = 4, W = 100. Is the solution unique?
(f) How does the solution and the value function depend on (R, M, W )? What are the properties of the value
function and the solution in terms of W ?
Now imagine that the match-making company starts its sales season and announces that every customer buying
25 matchboxes gets a special price offer of only R0 = 1 unit of money (instead of original 2) per box.

3
(g) Describe the new constraint set G0 and compare it with the initial set G. Provide an illustration.
(h) Using both Matlab and Excel, solve the initial and the new problems and compare the solutions. Provide
the printout of your Matlab code and send the Excel spreadsheet to jimmy.lerch@unil.ch.
(i) How does the solution and the value function depend on (R, R0 , M, W )? Does your result coincide with the
previous results? Support your statements with illustrations.

Bonus exercise 1
You have a dataset at your disposal (see the attached file on Moodle).
(a) Import the data to Matlab. Describe the data, that is provide summary statistics (at least mean, median,
std. deviation, Q1, Q3, min, max) as well as the histogram of the data and any other characteristics you
deem important.
Suppose now that you believe that the true distribution of the data is Y ∼ Γ(α, β), that is

β α y α−1 exp(−βy)
f (Y = y|α, β) = , y > 0, α > 0, β > 0.
Γ(α)

Γ(x) is called the Gamma function and defined as


Z ∞
Γ(x) = z x−1 exp(−z)dz.
0

Note that this integral cannot be solved explicitly so we usually just say Γ(x).

(b) Derive analytically the log-likelihood function and the first-order conditions. Explain if it is possible to
provide a closed-form solution for the MLEs using the first-order conditions.
(c) Estimate numerically the parameters of the distribution in Matlab. Do not use the built-in function mle,
but rather write your own function to get the ML estimates. This means that you should write a function
that takes as arguments the data and the two parameters and returns the log-likelihood, and then use one
of Matlab’s build-in optimizers, such as fminunc to find the maximum of your likelihood function. Don’t
forget to change the sign of your objective as this function computes the minimum. You will need to use
the function gamma(x) that gives you the value of the Gamma function at x. Present your results.
(d) Compute the standard errors of your estimates using the asymptotic distribution of ML in two ways:

1. By using the observed Fisher Information matrix from fminunc (save the Hessian that it produces).
2. By computing your own Fisher Information matrix, evaluated at the estimated parameter values, using
the analytical log-likelihood function.

Hint: when you are at the stage of plugging in your estimates, use the function psi(1,x) to compute
d2 /dx2 log(Γ(x)), you should not compute it further analytically, however, when you get to this point.
Present your results in each case.
(e) Assess the quality of the estimates and your statistical model for the data. E.g. make a plot of the estimated
vs empirical distribution, a QQ plot, compute the MSE, comment on the standard errors etc.

Now assume that the true parameters of this Gamma distribution are α = 7 and β = 0.8.
(f) Compute the true standard errors of the ML estimator using these parameter values (Note that you already
carried out this computation by hand and plugged in your estimates in (d)–2.). Present your results.

4
(g) Create three data sets by simulating from the Gamma distribution, that have n = 500, 5000, and 50000
observations. Estimate α and β by using ML and compute the numerical standard erros from point (d).
Present your results. Comment how the point estimates and standard errors compare to the true ones as n
increases.
Note that, without knowing the true parameters governing the distribution, we could have also done the same by
using a procedure called bootstrapping, that generates samples from the actual data with replacement.

You might also like