Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Let X be a random variable representing a claim on a particular insurance pol

ID: 3270178 • Letter: 3

Question

3. Let X be a random variable representing a claim on a particular insurance policy. The following are 10 observations of X:

141 16 46 40 351 259 317 1511 107 567

(b) Use R commands to compute maximum likelihood estimates (even if you know how to do it symbolically; the intention here is to show you know how to do it using R alone) from these data using the following models: (i) gamma; (ii) log-normal; and (iii) Weibull distributions. For each distribution write down the pdf and clearly indicate the parameter estimates (e.g. basic information of these models, including their pdfs can be found on Wikipedia).

(c) Which model gives the best fit for these data? Answer by reporting and comparing the log-likelihood values for each estimated model and by producing QQ plots of the data quantiles versus the quantiles for the fitted models.

(d) Make a density histogram and superimpose a pdf for the best fitting model.

I need the R code, thanks.

Explanation / Answer

Below is the R code for log-normal model and you can create the same for any model by changing the formula of the function defined below. Rest of the section I am leaving upto you and I hope this below will help you to achieve the solution completely.

a = c(141,16, 46, 40, 351, 259, 317, 1511, 107, 567)
m <- mean(a)
s <- sd(a)

loglike = function(data, mu, sigma) {
loglike = 0
for(obs in data){
loglike = loglike +
log(1/(sqrt(2*pi)*sigma) *
exp(-1/2 * (obs - mu)^2/(sigma^2)))
}
return(loglike)
}

loglike(a,m,s)

point_loglike = function(data, mu, sigma) {
  
loglike = log(1/(sqrt(2*pi)*sigma) * exp(-1/2 * (data - mu)^2/(sigma^2)))
  
return(loglike)
}

values <- array()
  
for(i in 1:length(a)){
values[i] <- point_loglike(a[i],m,s)
}
v <- as.vector(values)

qqplot(v,a)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote