• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

CS2 - Loss Distribution R Coding (Pareto Distribution)

S

skharki1

Member
Dear Team,

Hope you are doing well.

As per Core reading, it is mentioned that
The basic R packages do not include functions for the two‐parameter Pareto distribution. So, we are creating the below function in R.

rpareto <- function(n,a,l){
rp <- l*((1-runif(n))^(-1/a)-1)
rp
}
However, there is an inbuilt function in R for Pareto distribution, if we install the EnvStats package in R

dpareto(x, location, shape = 1)
ppareto(q, location, shape = 1)
qpareto(p, location, shape = 1)
rpareto(n, location, shape = 1)

Similarly, for Burr Distribution by installing the package actuar.

So, can we use the above-inbuilt function in R during the examination?
 
Last edited by a moderator:
Hi I would prefer creating a function myself.
For e.g. Burr
a=2;l=1000;g=0.75;
rburr <- function(n){(l*((1-runif(n))^(-1/a)-1))^(1/g)}
dburr <- function(x){x*((a*g*l^a)*x^(g-1))/((l+x^g)^(a+1))}
pburr <- function(q){1-(l/(l+q^g))^a}
qburr <- function(p){q <- (l*((1-p)^(-1/a)-1))^(1/g)q}
rburr(10,a,l,g)
 
Hello

You're right, there are many packages that have this functionality. However, not in the base installation of R and not in the packages that the IFoA have listed as required for the exam.

For a definitive answer about the exam you'll need to ask the IFoA. However, in any case, it may not be a good idea to use functionality outside of what the IFoA is expecting.

It's also worth pointing out that if, for example, the exam asks you to construct a custom function to generate a random sample from the Pareto distribution, then of course you'll need to write out a function.

More broadly, if you wish to do any practical application of R outside the exam, then using additional packages is a great way to gain access to lots of functionality. Of course, you have to be careful that you know what the functions are doing if you didn't write them yourself.

Andy
 
Back
Top