MATH 377 Financial and Actuarial Modelling in R MOCK MIDTERM EXAM - IJava

Java Python MATH 377

MOCK MIDTERM EXAM - I

Financial and Actuarial Modelling in R

1.

(a)  Use the following code to generate a vector of length 5 with entries filled with integer numbers between 0 and 9:

sample(0 : 9 ,   5 ,   replace  = T)

(i)  Write an R program that returns TRUE if the elements of the vector are in increasing order.       [3 marks]

(ii)  Write an R program to compute the average of those entries that are above 2. Note: return 0 if none of the entries is above 2.         [2 marks]

(b)  Consider a vector of student grades with values 70, 80, 55, 67, 90, 92, 83, 74, 100, 87, 49, and a vector with the month of birth of the students with values ”Jan” , ”Nov” , ”Dec” , ”Feb” , ”Feb” , ”Nov” , ”Jun” , ”May” , ”Apr” , ”Jan” , ”Jul” .

(i)  Create a data frame with the above data.                                 [2 marks]

(ii)  Find the average grade for those students born in February.   [2 marks]

(c)  We know that for |x| < 1

Use the series representation above, up to a finite number of terms N = 100, to compute log(0.3).                        [3 marks]

2. Let Y be Gamma distributed with shape parameter 2 and scale parameter

1, that is, the density function of Y is given by

y2−1e−y ,    y > 0 .

Now, consider

X = 1/Y .

(a) Write an R function to compute the distribution function of X .

[3 marks]

(b) Simulate a sample of size 2500 from X .

[2 marks]

(c) Approximate E[(1/Y2 )] using your simulated sample in (b).

[2 marks]

3. Let  X  be  Lognormal  distributed with parameters µ  =  −2  and  σ  =  2. Recall  that  the  density  function  of  a  lognormal  distribution  with  parameters µ ∈ R and σ > 0 is given by

x > 0 .

(a)  Simulate a sample of size 1000 from X .                                               [2 marks]

(b)  With your simulated sample in (a), plot the loglikelihood function for param- eter values µ between -3 and -1, and σ between 1 and 3.                  [3 marks]

(c)  Using the maximum likelihood estimation method, fit the following distribu- tions to the simulated data set:

(i)  Lognormal.                                      [2 marks]

(ii)  Weibull.                                              [2 marks]

(d)  Which fitted distribution seems to describe the data better?   Justify your answer         

  • 18
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值