1
$\begingroup$

I'm currently trying to carry out a simulation study for Bernoulli Data to show that the sample proportion, ˆp, is also approximately normally distributed when the sample size is large.

From an exercise I'm told that the Bernoulli Data is generated by:

rbinom(n=50, size=1, prob=0.5)

as we're using a sample size as 50 and the true proportion to be 0.5.

We were given the code for a Simulation Study using Exponential Data but we have to change the code by using the code for Bernoulli Data above and not use the Exponential Data code, the sample code is as follows:

n = 10 # sample size
set.seed(142981)
simreps = 1000 # simulation replicates
# (just needs to be a big number)
xbar = rep(0, simreps)
for(i in 1:simreps){
xbar[i] = mean(rexp(n, rate=0.001))
}
hist(xbar, xlim=c(0,3000))
qqnorm(xbar, ylim=c(0,3000));qqline(xbar)

But the issue that arises is when I add in the code which is:

set.seed(142981)
simreps = 1000 # simulation replicates
# (just needs to be a big number)
xbar = rep(0, simreps)
for(i in 1:simreps){
xbar[i] = mean(rbinom(n=50, size=1, prob=0.5))
}
hist(xbar)
qqnorm(xbar);qqline(xbar)

I get a histogram result that has the values on it like this enter image description here

but for the Q-Q Plot, the result looks like this, which does not seem correct. I don't know what went wrong, any help at all would be greatly appreciated.

$\endgroup$
  • $\begingroup$ I thought the Q-Q Plot would result in something like this. This is the sample question I'm working off of. Which instructs me to use the code from the Simulation Study for the Exponential Data as posted at the top of the Question but to change it for Bernoulli data. $\endgroup$ – JamesR Nov 26 '15 at 1:58
  • $\begingroup$ The staircase pattern can be attributed to the discreteness of binomial distribution. There is nothing wrong here. $\endgroup$ – rightskewed Nov 26 '15 at 3:29
  • $\begingroup$ See SAS's table for interpretation $\endgroup$ – rightskewed Nov 26 '15 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.