Topic 18 Sampling Distributions and the Normal Distribution
Learning Goals
- Describe the information contained in sampling distributions
- Use normal distribution models of sampling distributions to make probability statements about sample estimates
Exercises
A template RMarkdown document that you can start from is available here.
We’ll continue working with data from the Add Health study to understand how the risk of adulthood cigarette smoking is related to adolescent marijuana smoking.
library(readr)
library(dplyr)
library(ggplot2)
read_csv("https://www.dropbox.com/s/h09nq0nwgx8eioz/addhealth.csv?dl=1") addhealth <-
Let’s pretend that the 1541 people in this dataset represent the full broader population of interest. When we fit the logistic regression model below, the coeffients represent the true population values of these quantities:
glm(smoke ~ exposure, data = addhealth, family = "binomial")
population_mod <-summary(population_mod)
We would not normally have access to this full population, so let’s draw a random sample of 500 people from it to obtain our study’s data:
set.seed(155)
addhealth %>% sample_n(size = 500, replace = FALSE) addhealth_sample <-
We can fit the same model of interest in our “sample”:
glm(smoke ~ exposure, data = addhealth_sample, family = "binomial")
sample_mod <-summary(sample_mod)
Exercise: Based on the model output, how would you expect the sampling distributions of the intercept and the exposure
coefficient to compare?
Exercise: With the luxury of having the “full population”, we can set out to obtain the sampling distribution.
- Modify our traditional code for bootstrapping to obtain 1000 different samples of size 500 from the full population.
- Make plots that show the distribution of the intercept and
exposure
coefficient estimates across samples. Does your expectation from the previous hold up? - How close are the standard deviations of the estimates to the standard errors from our sample’s model? (You can use the
sd()
function andrepeated_samples[["name_of_coefficient"]]
will pull out a specific coefficient.)
set.seed(155)
replicate(1000, {
repeated_samples <-
}) repeated_samples %>% t() %>% as.data.frame()
repeated_samples <-head(repeated_samples)
# Plots
# For the intercept
ggplot(repeated_samples, aes(x = `(Intercept)`)) + ???
# For the exposure coefficient
Exercise: Repeat the above process for samples of size 1000 from the population. How do the distributions compare?
Exercise: It turns out that sampling distributions for regression coefficients are often normally-distributed with mean equal to the true population value and standard deviation equal to the standard error for that coefficient.
Based on the model output from population_mod
and sample_mod
, provide a answer for the following based on samples of size 500:
- 68% of samples will generate estimates between what two values?
- 95% of samples will generate estimates between what two values?
- 99.7% of samples will generate estimates between what two values?