Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = seq(2,1000,by = 1)
- y.num = replicate(1000,0)
- y.lower = replicate(1000,0)
- y.upper = replicate(1000,0)
- #Getting the plot for n = 2 to 1000
- for (i in 2:length(samp.num))
- {
- rsamp= rnorm(i,mean,sd)
- rsamp.mean = mean(rsamp)
- rsamp.sd = sd(rsamp)
- rsamp.se = rsamp.sd/sqrt(i)
- y.num[i] = rsamp.mean
- y.lower[i] = rsamp.mean - 1.96*rsamp.se
- y.upper[i] = rsamp.mean + 1.96*rsamp.se
- }
- plot(num,y.num[-1],xlab = "sample size",ylab = "Sample mean and SE")
- lines(num,replicate(999,mean),col = "red")
- lines(num,y.lower[-1],col = "blue")
- lines(num,y.upper[-1],col = "green")
Advertisement
Add Comment
Please, Sign In to add comment