Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question One: Bin Width Choice for Histogram/Kernel Density Estimator (8 marks) a. Generate a sample of 1,000 independent observations from a gamma distribution with scale
Question One: Bin Width Choice for Histogram/Kernel Density Estimator (8 marks) a. Generate a sample of 1,000 independent observations from a gamma distribution with scale 6 = 2 and shape k = 3, using the rgamma() function. Create a sample density histogram and overlay the true gamma density function. Use the default settings in the histO function for estimating the bin width [essentially the default is Sturgeis Rule). Does the bin width obtained using Sturgels Rule look right? b. On a single plot, include three subgraphs to show the estimated density histogram using the three bin width rules: 0 Sturge's Rule [include breaks="Sturges" argument in hist function) . Scott's Normal Reference Rule (include breaks="Scott" argument in hist function) 0 FreedmaniDiaconis Rule (include breaks="Freedman" argument in hi st function). On each plot overlay the true density function. In your opinion which bin width estimator looks the most reasonable? Note: The bin width bu; for each rule are roughly calculated in R as follows: . Sturge's Rule: bw : W. where n is the sample size. 2 . . Scott's Rule: bw : 3'5\" where a is the standard deviation of the data. \"ifs ? . . 2 5, .r, . . FreedmanDlacoms Rule: bw : W, where r375. (125 are the 75 % and 25 \"If: quantlle of the data. c. Construct a Kernel density estimator, at), assuming a rectangular kernel, from scratch {that is, without using inbuilt functions from R packages for constructing a Kernel density estimator). 0 To determine h, determine the binwidth used in the histogram from your preferred rule in b. and halve it. . The lower limit for a: will be 0 and upper limit mmax + h. 0 Compare the KDE to the underlying distribution. Copy the relevant R code into your assignment submission
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started