R> residuals curve((0.168 + 0.007 * x)^(20/3), from = 0, to = 400, add = TRUE)(b) Now, apply the power transformation y 3/20 to the pressure data values. Plot thesetransformed values against temperature. Is a linear or nonlinear relationship evidentnow? Use the abline() function to pass a straight line through the points. (See theprevious part of the exercise to obtain an intercept and a slope for this line.)(c) Add a suitable title to the graph.(d) Re-do the above plots, but use the mfrow mechanism to display them in a 2 × 1 layouton the graphics page. Repeat once again using a 1 × 2 layout.54. Write a function to “correctly” graph the amount of money that the insurance companywould have in the auto insurance simulation model in the following style:●−5 0 5 10 15● ●● ●●●●● ● ●●● ●●●● ● ● ● ● ●●●●● ●●● ● ● ●●●●● ●●● ●●● ● ●●●●●●● ●● ●●● ●● ●● ●●●●● ● ●●●● ●●● ●● ●● −5 0 5 10 15●●●●● ●● ●●●●● ●●●●●● ● ●● ● ●● ● ● ●●● ●●●●● ●●● ●● ●●0.0 0.2 0.4 0.6 0.8 1.00.00 0.05 0.10 0.15 0.2055. Create a sample of size N = 128 from the standard normal distribution and from theexponential distribution with parameter 1, and use Q-Q plots to assess the normality of thedata. Describe and explain the differences of the results.56. (a) Generate a sample of size N = 1024 from the exponential distribution with parameter(rate) λ = 0.2. Call x the vector containing the sample values.10
(b) Plot on the same graph, the exact (theoretical) density of the distribution of x, and ahistogram of x. It is recommended to try several values for the number of bins, and toreport only the result found most satisfactory.(c) Plot on the same graph, the same density as before, together with a kernel densityestimate of the the distribution of x. Again, it is recommended to try several values ofthe bandwith, and to report only the result found most satisfactory.(d) Compare the two plots and explain the reasons for the differences. Say which estimateof the density you prefer, and explain why.57. The goal of this problem is to design and use a home-grown random number generator forthe exponential distribution.(a) Compute the cdf F λ (x) = P(X ≤ x) of a random variable X with an exponentialdistribution with parameter λ > 0.(b) Compute its inverse F −1λand write an R function myrexp which takes the parameters N,and LAMBDA, and which returns a numeric vector of length N containing N samplesof random variates from the exponential distribution with parameter LAMBDA.(c) Use your function myrexp to generate a sample of size N = 1024 from the exponentialdistribution with mean 1.5, use the function rexp to generate a sample of the same sizefrom the same distribution, and produce a Q-Q plot of the two samples.Are you satisfied with the performance of your simulation function myrexp? Explain.π 58. This problem deals with the analysis of the daily S&P 500 closing values.(a) Load the data using quantmod.(b) Create a vector DSPRET containing the daily raw returns. Compute the mean andthe variance of this daily raw return vector, produce its eda.shape plot, and discuss thefeatures of this plot which you find remarkable.(c) Fit a Generalized Pareto Distribution (GPD for short) to the daily raw returns, givedetailed plots of the fit in the two tails, and discuss your results.(d) Generate a sample of size 10000 from the GPD fitted above. Call this sample SDSPRET,produce a Q-Q plot of DSPRET against SDSPRET, and comment.(e) Compute the VaR (expressed in units of the current price) for a horizon of one day, atthe level α = 0.005 in each of the following cases:• assuming that the daily raw return is normally distributed;• using the GPD distribution fitted to the data in the previous question;• compare the results (think of a portfolio containing a VERY LARGE number of contracts).π 59. Redo the above problem after replacing the vector DSP with a vector SDSP containing onlythe first 6000 entries of DSP. Compare the results, and especially the VaR’s. Explain thedifferences.π 60. This problem is based on the data matrix UTILITIES. Each row corresponds to a given day.The first column gives the log of the weekly return on an index based on Southern Electricstock value and capitalization, (we’ll call that variable X), and the second column gives, onthe same day, the same quantity for Duke Energy (we’ll call that variable Y ), another largeutility company.(a) Compute the means and the standard deviations of X and Y , and compute their correlationcoefficients.11