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
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.
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 the code for a 90 and 95% confidence interval