R-MTH791P

QUEEN MARY, UNIVERSITY OF LONDON
MTH6991/MTH791U/MTH791P
Computational Statistics with R
Exercise Sheet 4 Spring 2022
Question 1 is due to be handed in for assessment along with two questions from the previous
exercise sheet. The link for submission will be in the week 6 section on QMPlus. The deadline
is 1pm on Thursday the 3rd March. Please include an R script file with the R code used, and
a separate file with all answers asked for (you can submit more than one file).
Late submissions will receive zero marks.
1. (Problem for handing in) 50 marks
This question uses a dataset on QMPlus. There is a different dataset for each student,
which can be found via the link “Exercise 4 datasets” in the week 5 section. For each
student, there should be a file called “exercise4 XYZ.txt”, where XYZ is your ID number
(you need to be logged in to QMPlus). If you cannot see a file, please send me an email.
The dataset contains one column, called x. Using R, generate three kernel density
estimates (KDE)

💡 Buy the answer for only $12 Get it now →

using bandwidths of h = 0.2, 1 and 2, and the Gaussian kernel. Plot
each of these KDEs. What is the effect of changing h on the appearance of the graphs
What is the main feature of the data that these plots show
What is the bandwidth that R calculates (still with the Gaussian kernel) if you do not
specify a bandwidth
Also generate and plot a KDE using a bandwidth of 1 and the rectangular kernel. Which
produces a smoother curve (for h = 1), the rectangular or Gaussian kernel
Include the graphs with your answers, but apart from that don’t copy any R output.
Within R, right-clicking on a graph gives the options of saving it to disk or copying it
(e.g. to paste into a Word document).
2. Without using R, just with pen and paper, calculate the histogram estimator f H(y) of
the probability density function (pdf) using the following data:
0.5, 4.9, 6.5, 4.4, 7.5, 6.9, 1.2, 6.7, 5.8, 4.7
Use bins (intervals) with boundaries at 0, 2, 4, 6, 8.
So you would need to fill in the in the following:
f H(y) =

💡 Buy the answer for only $12 Get it now →