代做MATH 377 Financial and Actuarial Modelling in R MOCK MIDTERM EXAM - II调试Haskell程序
- 首页 >> Matlab编程MATH 377
MOCK MIDTERM EXAM - II
Financial and Actuarial Modelling in R
1.
(a) Consider the vector made of length 8 generated by the following code: sample(0 : 9 , 8 , replace = T)
(i) Write an R program that counts the number of unique entries of this vector. [2 marks]
(ii) Write an R program to obtain the entries that are strictly below the mean of the vector and even. Then, compute the median of the sub- tracted data. Note: return 0 if a vector of length 0 is obtained. [3 marks]
(b) Consider the ToothGrowth (The Efect of Vitamin C on Tooth Growth in Guinea Pigs) data set in R:
(i) Create a boxplot for len for the records with supp equal to VC and dose equal to 1.0. [2 marks]
(ii) Find the sample mean of len per dose for the records with supp equal to OJ. [2 marks]
(c) Use a while loop to find the minimum integer value of n such that
(1.05)n ≥ 100 . [4 marks]
2. Let Y be exponentially distributed with a mean of 0.5. Consider X defined as
X = 0.5(exp(Y) − 1) .
(a) Write an R function to compute the density function of X . Evaluate your function at x = 1.5. [4 marks]
(b) Simulate a sample of size 1000 from X . [2 marks]
(c) Using the maximum likelihood estimation method, fit the following distribu- tions to the simulated data set:
(i) Gamma. [2 marks]
(ii) Pareto. [2 marks]
(iii) Weibull. [2 marks]
(d) Create QQ plots to assess the quality of the fits above visually. Which fitted distribution seems to describe the data better? Justify your answer. [3 marks]
(e) Confirm your choice using an information criteria. Justify your answer. [2 marks]