Question

Need help with R coding x <- matrix(rnorm(2000, 20, 5),nrow=100) xbar20 <- rowMeans(x) UL <- xbar20+qnorm(.90)*5/sqrt(20)...

Need help with R coding

x <- matrix(rnorm(2000, 20, 5),nrow=100)
xbar20 <- rowMeans(x)
UL <- xbar20+qnorm(.90)*5/sqrt(20)
LL <- xbar20-qnorm(.90)*5/sqrt(20)
cover<-sum(UL>20 & LL<20)/100

this code finds coverage for an 80% confidence interval

change code to use beta distribution with ( shape1=5,
shape2=1).

theoretical parameter values are: ? = 0.83, ? = 0.14

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

The R code for finding coverage for an 80% confidence interval change code to use beta distribution with ( shape1=5,
shape2=1) is

x <- matrix(rbeta(2000, shape1=5,shape2=1),nrow=100)
xbar20 <- rowMeans(x)
UL <- xbar20+qnorm(.90)*0.14/sqrt(20)
LL <- xbar20-qnorm(.90)*0.14/sqrt(20)
cover<-sum(UL>0.83 & LL<0.83)/100

Note : Output is changes every time you run the code so for fixing the output of the R code, one should use seed() function.

Add a comment
Know the answer?
Add Answer to:
Need help with R coding x <- matrix(rnorm(2000, 20, 5),nrow=100) xbar20 <- rowMeans(x) UL <- xbar20+qnorm(.90)*5/sqrt(20)...
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
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