代做MTH 306 Credibility Theory 2023 - 2024 S2代做R编程
- 首页 >> Database作业MTH 306
Credibility Theory
2023 - 2024 S2
Task 1 (20 marks)
From introductory statistics, we know that the sampling distribution of a sample mean will be approximately normal with mean µ and standard error , where n is the sample size, if we have a random sample from a population with mean µ and standard deviation σ and the sample size is “large” (usually at least 30).
In this problem, we will build a simulation that will show when the sample size is large enough.
(a) Use inversion method with R to generate N = 500 samples with size n = 50 from an exponential distribution with pdf as follows,
(b) For each of the samples, calculate the sample mean, so that you now have a vector of 500 sample means.
(c) Plot a histogram of these 500 sample means. Make comments on the center and shape/dis-tribution of the histogram.
(d) Turn this simulation into a function that takes arguments “N” the number of simulated samples to make, and “n” the sample size of each simulated sample. Run this function for n = 10, 15, 30, 50 using a loop statement in R. Report your observations about the histograms of the sample means (the sampling distribution of the sample mean) as the sample size increases.
Note:
❼ You should first write any necessary derivations in your solution when applying inversion method.
❼ It is recommended to use RMarkdown to write your solution, otherwise, you shall attach the R code with your written solution.
❼ Use set.seed(306) in your R code.
Task 2 (20 marks)
The “DataQ2.csv” provides the measurements for the cylindrical compressive strength (in MPa) for 12 prestressed concrete beams:
(a) Read the data from csv to R. Generate k = 1, 000 bootstrap samples and compute the 1,000 means (go higher e.g. 10,000 or 100,000 if your computer is fine with it).
(b) What are the 2.5%, and 97.5% quantiles (so what is the 95% confidence interval for mean compressive strength without assuming any distribution)?
(c) Find the 95% confidence interval for mean compressive strength by the (parametric) bootstrap with the assumption that the observations are from a normal distribution. (Hint: parametric bootstrap means that you shall resampling from the assumed distribu-tion with parameters estimated from the observations; the classical bootstrap assumed uniform. distribution among the observations)
(c) Find the 95% confidence interval for mean compressive strength by the (parametric) bootstrap with the assumption that the observations are from a log-normal distribution. (Hint: To use the rlnorm function to simulate the log-normal distribution, we face the challenge that we need to specify the mean and standard deviation on the log-scale and not on the raw scale, so compute mean and standard deviation for log-transformed data for this R-function))