Question
write the code in stata or R or SAS
3, (Extra Credit): Write code to simulate 5000 of these experiments (each with n = 50 flips of the biased coin, taking p 0.3)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
write the code in stata or R or SAS 3, (Extra Credit): Write code to simulate...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUIZ 2.3 EXAMPLE 2.25 Please help me build the MATLAB code Use MATLAB to build a...

    QUIZ 2.3 EXAMPLE 2.25 Please help me build the MATLAB code Use MATLAB to build a simulation of Quiz 2.3. Simulate the transmission of 10000 packets, each containing 100 bits. Count the number of packets that contain no error, one, two, three- bit errors, calculate their probabilities. Also calculate the probability of a packet is decoded correctly. Compare your numbers from MATLAB with your theoretical calculation. (Hint: look at Example 2.25.) Data packets containing 100 bits are transmitted over a...

  • Stat 255 Project 3 due Wednesday, April 22 Write R code to solve the following problems, Make sur...

    I am just wanting the first question answered. Stat 255 Project 3 due Wednesday, April 22 Write R code to solve the following problems, Make sure to include descriptions and explanation in your cod Save them in a file named project3-yourname.R and email them to ysarolousi.edu be date. A model for stock prices Let S, be the closing price of a stock at the end of day j, where j model for the evolution of the future daily closing prices:...

  • ARE MY ANSWERS CORRECT? 25 questions 1. what an A/R aging analysis is, its purpose, and...

    ARE MY ANSWERS CORRECT? 25 questions 1. what an A/R aging analysis is, its purpose, and how it is created. Used to estimate amount needed in Allowance for Bad Debts Account (a contra account) A/R Days Outstanding 0-30           31-60               61-90               Over 90 Under each term list all A/Rs that are not paid by date Use historical experience to estimate the percentage of A/R for each date period to determine allowance for Bad Debts What the three major cost components are...

  • As you know from Project 4, McCormick & Company is considering building a new factory in...

    As you know from Project 4, McCormick & Company is considering building a new factory in Largo, Maryland. McCormick & Company decided to offer $4,424,000 to obtain the land for this project. The new factory will require an initial investment of $350 million to build the new plant and purchase equipment. You have been asked to continue your work from project 4 with a full analysis of the proposed factory, including the start-up costs, the projected net cash flows from...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this p...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT