Question: Problem 1. For the chi-squared goodness-of-fit statistic, we evaluate by simulation how accurate the large-sample approximation by the chi-squared distribution is. Our scope is modest,

 Problem 1. For the chi-squared goodness-of-fit statistic, we evaluate by simulation

Problem 1. For the chi-squared goodness-of-fit statistic, we evaluate by simulation how accurate the large-sample approximation by the chi-squared distribution is. Our scope is modest, however. consider the special situation where we observe a sample Xi, ,Xn taking values in {1, ,? and want to test for uniformity, meaning, test whether the underlying distribution is the uniform distribution on {1,..., k) A. Write an R function chisq.sim.hist(n, k, B). For each b 1,..., B, the function first simulates chi-squared statistic Db. It then produces a histogram of D?,..., DB and overlays the density B. Try this function in the setting where k-5, and n E {10, 20, 50, 100). Choose B-1e4. of the chi-squared distribution with k - 1 degrees of freedom. Produce a plot with 4 subplots, one for each of these settings. C. Write a function chisq.sim.critical (n, k, B) that returns the critical value that would be used for testing at the 5% level. This can be done with a simple modification of your function in Part A.] D. Use this function to compare the critical value obtained by simulation with the theoretical critical value-which is the 95% quantile of the chi-squared distribution with k-1 degrees of freedom-when k-5 andn E{10, 20,30,...,90, 100). Choose B-le4. Produce a plot. Problem 1. For the chi-squared goodness-of-fit statistic, we evaluate by simulation how accurate the large-sample approximation by the chi-squared distribution is. Our scope is modest, however. consider the special situation where we observe a sample Xi, ,Xn taking values in {1, ,? and want to test for uniformity, meaning, test whether the underlying distribution is the uniform distribution on {1,..., k) A. Write an R function chisq.sim.hist(n, k, B). For each b 1,..., B, the function first simulates chi-squared statistic Db. It then produces a histogram of D?,..., DB and overlays the density B. Try this function in the setting where k-5, and n E {10, 20, 50, 100). Choose B-1e4. of the chi-squared distribution with k - 1 degrees of freedom. Produce a plot with 4 subplots, one for each of these settings. C. Write a function chisq.sim.critical (n, k, B) that returns the critical value that would be used for testing at the 5% level. This can be done with a simple modification of your function in Part A.] D. Use this function to compare the critical value obtained by simulation with the theoretical critical value-which is the 95% quantile of the chi-squared distribution with k-1 degrees of freedom-when k-5 andn E{10, 20,30,...,90, 100). Choose B-le4. Produce a plot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!