ProjectMOSAIC / oiLabs-mosaic2

Source files for OpenIntro Statistics labs using mosaic modeling approach and ggformula
Other
0 stars 0 forks source link

confidence intervals lab updates #15

Open rpruim opened 6 years ago

rpruim commented 6 years ago

mosaic::sample() handles a multi-column data frame just fine. No need to select just one variable.

rpruim commented 6 years ago

Do we want to show cnorm()?

cnorm(.95)
##          lower    upper
## [1,] -1.959964 1.959964
rpruim commented 6 years ago

If we use cnorm(), then creating an interval looks like this:

zstar <- cnorm(.95)
se <- sd(~ area, data = sample60) / sqrt(60)
sample_mean + zstar * se
##         lower    upper
## [1,] 1249.123 1482.044
rpruim commented 6 years ago

Not sure I'm a fan of this style:

with(samp_ci, plot_ci(lower, upper, m = mean(~ area, data = ames)))

Possible solutions:

# This can also be done in native ggformula -- just need to do some work to 
# to calculate which ones cover.
pop.mean <- mean(~ area, data = ames)
samp_ci <- samp_ci %>%
  mutate(covers = pop.mean >= lower & pop.mean <= upper)
gf_pointrange(mean + lower + upper ~ .index, data = samp_ci, color = ~covers)