Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. USE an urn model function that takes the proportion of Democrats p and the sample size N as arguments and returns the sample average

1. USE an urn model function that takes the proportion of Democrats p and the sample size N as arguments and returns the sample average if Democrats are 1s and Republicans are 0s. Call the function take_sample. 2. Now assume p <- 0.45 and that your sample size is N = 100. Take a sample 10,000 times and save the vector of mean(X) - p into an object called errors. Hint: use the function you wrote for exercise 1 to write this in one line of code. 3. The vector errors contains, for each simulated sample, the difference between the actual p and our estimate X . We refer to this difference as the error. Compute the average and make a histogram of the errors generated in the Monte Carlo simulation and select which of the following best describes their distributions: mean(errors) hist(errors) A. The errors are all about 0.05. B. The error are all about -0.05. C. The errors are symmetrically distributed around 0. D. The errors range from -1 to 1. 16.5. EXERCISES 299 4. The error X p is a random variable. In practice, the error is not observed because we do not know p. Here we observe it because we constructed the simulation. What is the average size of the error if we define the size by taking the absolute value | X p | ? 5. The standard error is related to the typical size of the error we make when predicting. We say size because we just saw that the errors are centered around 0, so thus the averate error value 0. For mathematical reasons related to the Central Limit Theorem, we actually use the standard deviation of errors rather than the average of the absolute values to quantify the typical size. What is this standard deviation of the errors? 6. The theory we just learned tells us what this standard deviation is going to be because it is the standard error of X . What does theory tell us is the standard error of X for a sample size of 100. 7. In practice, we don't know p, so we construct an estimate of the theoretical prediction based by plugging in X for p. Compute this estimate. Set the seed at 1 with set.seed(1). 8. Note how close the standard error estimates obtained from the Monte Carlo simulation (exercise 5), the theoretical prediction (exercise 6), and the estimate of the theoretical prediction (exercise 7) are. The theory is working and it gives us a practical approach to knowing the typical error we will make if we predict p with X . Another advantage that the theoretical result provides is that it gives an idea of how large a sample size is required to obtain the precision we need. Earlier we learned that the largest standard errors occur for p = 0.5. Create a plot of the largest standard error for N ranging from 100 to 5,000. Based on this plot, how large does the sample size have to be to have a standard error of about 1%? A. 100 B. 500 C. 2,500 D. 4,000 9. For sample size N = 100, the central limit theorem tells us that the distribution of X is: A. practically equal to p. B. approximately normal with expected value p and standard error p(1 p)/N. C. approximately normal with expected value X and standard error X (1 X)/N. D. not a random variable. 10. Based on the answer from exercise 8, the error X p is: A. practically equal to 0. B. approximately normal with expected value 0 and standard error p(1 p)/N. C. approximately normal with expected value p and standard error p(1 p)/N. D. not a random variable. 11. To corroborate your answer to exercise 9, make a qq-plot of the errors you generated in exercise 2 to see if they follow a normal distribution. 12. If p = 0.45 and N = 100 as in exercise 2, use the CLT to estimate the probability that X > 0.5. You can assume you know p = 0.45 for this calculation. 13. Assume you are in a practical situation and you don't know p. Take a sample of size N = 100 and obtain a sample average of X = 0.51. What is the CLT approximation for the probability that your error is equal or larger than 0.01?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A Preface To Logic

Authors: Morris R Cohen

1st Edition

0486801853, 9780486801858

More Books

Students also viewed these Mathematics questions

Question

A greater tendency to create winwin situations.

Answered: 1 week ago