Question

STATA Write code to simulate 5000 of these experiments (each with n = 50 flips of...

STATA

Write code to simulate 5000 of these experiments (each with n = 50 flips of the biased coin, taking p = 0.3). Calculate your estimate of p for each repetition and calculate your estimate of the variance of your estimate for each repetition. Compare the average of your 5000 variance estimates to the empirical variance of the 5000 estimates of p.

Homework Answers

Answer #1

solution:

R code:

x=matrix(0,nrow=5000,ncol=50)
p_hat=1:5000
var_hat=1:5000
for(i in 1:5000)
{
for(j in 1:50)
{
x[i,j]=rbinom(1,1,0.3)
}
p_hat[i]=mean(x[i,])
var_hat[i]=var(x[i,])
}
mean(var_hat) # average of 5000 variance estimates
var(p_hat) # empirical variance of 5000 estimates of p

Out put:

mean(var_hat)
[1] 0.210412
> var(p_hat)
[1] 0.004267701

Here we observe that average of 5000 variance estimates>empirical variance of 5000 estimates of p.

please give me thumb up

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly...
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly 4 times in 10 flips of a fair coin. One way to generate a flip of the coin is to create a vector in R with all of the possible outcomes and then randomly select one of those outcomes. The sample function takes a vector of elements (in this case heads or tails) and chooses a random sample of size elements. coin <- c("heads","tails")...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
Instructions: In 1974, Loftus and Palmer conducted a classic study demonstrating how the language used to...
Instructions: In 1974, Loftus and Palmer conducted a classic study demonstrating how the language used to ask a question can influence eyewitness memory. In the study, college students watched a film of an automobile accident and then were asked questions about what they saw. One group was asked, “About how fast were the cars going when they smashed into each other?” Another group was asked the same question except the verb was changed to “hit” instead of “smashed into.” The...
Below is a case on estimation and analysis of demand for Bottled Water. Read the case...
Below is a case on estimation and analysis of demand for Bottled Water. Read the case carefully and use the appropriate techniques given in the text book on demand estimation and analysis and make your decisions, judgments and evaluation based on the results. For solving any part of the case you have to give your explanations write the proper formula, and show the procedure of reaching to your answers. All your work should be typed and the data, printout of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT