IEMS 303 Homework 2

For the exercises below turn in a single RScript file. Use comments to indicate each exercise or part of exercise; see the example below. Make sure results are clearly labeled. For grading we will execute the file.

# Solution to Exercise 17, Part (z) set.seed(1)

X <- rnorm(100)

hist(X)

**Background**

The *Kumaraswamy distribution *is useful for modeling random outcomes on the interval (0,1), such as the fraction of borrowers who default on their loans. Unfortunately it is not in R. It has two parameters a > 0 and b > 0, and has density, cdf and quantile functions

The *lognormal distribution *(literally, the natural log of the data are normally distributed) is widely used to model financial returns. It is in R as [d,p,q,r]lnorm. Look at the help page for this distribution. R has chosen to parameterize it using meanlog and sdlog, which are *not *the mean and standard deviation. However, for this assignment just use the parameters we provide, which are meanlog = 4.598022 and sdlog = 0.1195713. These values give an actual mean and standard deviation of 100 and 12, respectively.

**Exercise 1**

Use R to compute the following quantities

**Exercise 1(a)**

Suppose that X has a negative binomial distribution with desired number of successes size = 3 and success probability prob = 0.37. Compute Pr{X = 10} and Pr{X ≤ 10}. Reminder: The negative binomial distribution is the distribution of the number of trials until size successes are achieved.

**Exercise 1(b)**

Suppose X has a normal distribution the mean 6 and standard deviation 3. Compute Pr{−2 ≤ X ≤ 7} and the 0.85 quantile of this distribution (that is, the value x0.85 such that Pr{X ≤ x0.85} = 0.85).

**Exercise 1(c)**

Suppose X has a Student t distribution with 17 degrees of freedom. Compute the Pr{X > 1.645}.

**Exercise 2**

**Exercise 2(a)**

Plot on the same graph the densities of the Kumaraswamy distribution for parameters (a,b) = (1, 1), (2, 1.5), (4, 2), using at least 100 values of x. Hint: plot the last set of parameters first.

**Exercise 2(b)**

For the set of parameters (a, b) = (2, 1.5), generate 10,000 random values from this distribution and plot a histogram to see if it is similar to your density. Use set.seed(12345). Be sure to save the 10,000 values you generated for the next part of the exercise.

**Exercise 2(c)**

Using the data you generated in 1(b), estimate the Pr{X > 0.5} and E[X|X > 0.5] (the mean (average) value of this random variable, given that the value is larger than 0.5).

**Exercise 3**

In finance the “value at risk” (VaR) is the 5th percentile (0.05 quantile) of the investment return distribution. Suppose our investment costs $90 and its value after one year is described by a random variable X with lognormal distribution having mean $100 and standard deviation $12 (thus the return is X − 90 and the expected value of return is $100 - $90 = $10).

**Exercise 3(a)**

Compute the VaR from this investment. Do not use simulation. Hint: The 5th percentile of the return is the 5th percentile of the value minus the cost. Note: even though the 5th percentile of return is typically negative, the VaR is often reported as positive. Here we will just leave it negative.

**Exercise 3(b)**

Many financial engineers prefer the conditional value at risk (CVaR), which is expected value of (average) return, given the return is less than or equal to the VaR. Use simulation with 10,000 replications to estimate the CVaR for this investment. Use set.seed(12345). Hint: You need to simulate 10,000 returns, and use the VaR computed from the previous exercise.

**Exercise 4**

The Mega-Millions multi-state lottery selects five numbers from the set {1, 2, . . . , 70} without replacement, and one number from the set {1, 2, . . . , 25} (the “mega-ball”). The lottery uses a physical device (numbered balls in a basket) to select the numbers, but it could also be done by using simulation. Use R to generate three random lottery selections (five numbers from the first group, one from the last). Use set.seed(12345) before you start.