Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATH377: Financial and Actuarial Modelling in R

Tutorial 4

Exercise 1. For the Chi-Squared distribution (chisq):

a) Use 3 degrees of freedom to generate a sample of size 1000.

c) Write an R function to compute the log-likelihood function. Test your function with the simulated sample in a).

d) With your simulated sample in a), plot the log-likelihood function for parameter values between 1 and 4.

f) Compute the maximum-likelihood estimator for your sample.

h) Find the quantile matching estimator using the median (i.e., 50%).

 

Exercise 2. In this exercise, we will compare the fit of two discrete distributions. Recall that the density of a negative binomial random variable X with parameters α and p is given by

f(x) = P(X = x) = pα(1 − p)x ,    x = 1, 2, . . . ,

where Γ denotes the Gamma function.

a)  Create a sample of size 1000 from a Negative Binomial random variable with parameters α = 15 and p = 0.6.

b)  Create a histogram of your sample in a).  Hits: Use something like breaks  =  0:max(x) to show bins of size 1.

d)  Fit a negative binomial model to your sample in a) via maximum likelihood estimation.  Note: Check the help of nbinom and fitdist to see which arguments are being used.

e)  Using visual aids, asses which model describes the data better.  Hint: If you compare fitted density against histogram, use points() to plot the density evaluations.

 

Exercise 3. Consider the danish fire insurance data set danishuni. As in the lecture notes, take the losses above 1 million danish kroner and subtract 1 million to all data points to bring the data to the origin.

a) Fit a lognormal distribution to the data via MLE.

 

c) Compute the mean for both fitted distributions.

e) Which one of these two models seems to describe the data better? Remember, this data set is not easy to describe with a global model. Hence, neither of these two models may be a great overall choice.