Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #simulate population sizes, true means, and observed means
- library(tidyverse)
- library(truncnorm)
- #sim data
- d = tibble(
- n = runif(1e4, min = 2, max = 100) %>% round(),
- true_mean = rnorm(1e4, mean = 100, sd = 15),
- observed_mean = NA
- )
- #sample the means
- d$observed_mean = map2_dbl(d$n, d$true_mean, ~mean(rnorm(.x, mean = .y, sd = 15)))
- #plot
- ggplot(d, aes(true_mean, observed_mean, color = n)) +
- geom_point(alpha = .5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement