code in R
2. Suppose that Y|A has an exponential distribution with mean A, and A has an inverse gamma distribution with parameters a = 3 and 6 = 10. We proved in class that the Y ~ Pareto(a = 3,0 = 10). Perform a Monte Carlo simulation to show that simulating from the continuous mix- ture structure is no different statistically than simulating from the Pareto distribution. i.e. simulate two samples of size 10000 each, once by using the continuous mixture structure and another time by using the Pareto distribution. Compare the two simu- lated samples by comparing their empirical cdf graphically. This will be done by following the below steps in R. (a) Install and load the package actuar. Use the functions install package and library. This package allows us to use actuarial related functions. In this assignment, we will use Pareto distribution related function that are available in actuar. (b) Define the needed paramaters. () Set a seed equal to your ID number. (d) Let lambda be a sample simulated from fa (e) Let Yi be a sample simulated from fria by using the values of lambda that are simulated in the previous step. (f) Let Y2 be a sample simulated from fy. (8) Compare the empirical cdf of Y1 and Y2 by plotting both empirical edfs on the same plot. Use different colors for each curve and include a legend that explains your graph. Choose the appropriate widths for the lines. (h) What do you conclude? 2. Suppose that Y|A has an exponential distribution with mean A, and A has an inverse gamma distribution with parameters a = 3 and 6 = 10. We proved in class that the Y ~ Pareto(a = 3,0 = 10). Perform a Monte Carlo simulation to show that simulating from the continuous mix- ture structure is no different statistically than simulating from the Pareto distribution. i.e. simulate two samples of size 10000 each, once by using the continuous mixture structure and another time by using the Pareto distribution. Compare the two simu- lated samples by comparing their empirical cdf graphically. This will be done by following the below steps in R. (a) Install and load the package actuar. Use the functions install package and library. This package allows us to use actuarial related functions. In this assignment, we will use Pareto distribution related function that are available in actuar. (b) Define the needed paramaters. () Set a seed equal to your ID number. (d) Let lambda be a sample simulated from fa (e) Let Yi be a sample simulated from fria by using the values of lambda that are simulated in the previous step. (f) Let Y2 be a sample simulated from fy. (8) Compare the empirical cdf of Y1 and Y2 by plotting both empirical edfs on the same plot. Use different colors for each curve and include a legend that explains your graph. Choose the appropriate widths for the lines. (h) What do you conclude