+ - 0:00:00
Notes for current slide
Notes for next slide

Quantifying uncertainty



Data Science in a Box

1 / 31

Recap and motivation

2 / 31

Data

  • Family income and gift aid data from a random sample of fifty students in the freshman class of Elmhurst College in Illinois, USA
  • Gift aid is financial aid that does not need to be paid back, as opposed to a loan

The data come from the openintro package: elmhurst.

3 / 31

Linear model

linear_reg() %>%
set_engine("lm") %>%
fit(gift_aid ~ family_income, data = elmhurst) %>%
tidy()
## # A tibble: 2 × 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 24.3 1.29 18.8 8.28e-24
## 2 family_income -0.0431 0.0108 -3.98 2.29e- 4

4 / 31

Interpreting the slope

## # A tibble: 2 × 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 24.3 1.29 18.8 8.28e-24
## 2 family_income -0.0431 0.0108 -3.98 2.29e- 4

5 / 31

Interpreting the slope

## # A tibble: 2 × 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 24.3 1.29 18.8 8.28e-24
## 2 family_income -0.0431 0.0108 -3.98 2.29e- 4

For each additional $1,000 of family income, we would expect students to receive a net difference of 1,000 * (-0.0431) = -$43.10 in aid on average, i.e. $43.10 less in gift aid, on average.

5 / 31

exactly $43.10 for all students at this school?!

6 / 31

Inference

7 / 31

Statistical inference

... is the process of using sample data to make conclusions about the underlying population the sample came from

8 / 31

Estimation

So far we have done lots of estimation (mean, median, slope, etc.), i.e.

  • used data from samples to calculate sample statistics
  • which can then be used as estimates for population parameters
9 / 31

If you want to catch a fish, do you prefer a spear or a net?


10 / 31

If you want to estimate a population parameter, do you prefer to report a range of values the parameter might be in, or a single value?


11 / 31

If you want to estimate a population parameter, do you prefer to report a range of values the parameter might be in, or a single value?


  • If we report a point estimate, we probably won’t hit the exact population parameter
  • If we report a range of plausible values we have a good shot at capturing the parameter
11 / 31

Confidence intervals

13 / 31

Confidence intervals

A plausible range of values for the population parameter is a confidence interval.

14 / 31

Confidence intervals

A plausible range of values for the population parameter is a confidence interval.

  • In order to construct a confidence interval we need to quantify the variability of our sample statistic
14 / 31

Confidence intervals

A plausible range of values for the population parameter is a confidence interval.

  • In order to construct a confidence interval we need to quantify the variability of our sample statistic
  • For example, if we want to construct a confidence interval for a population slope, we need to come up with a plausible range of values around our observed sample slope
14 / 31

Confidence intervals

A plausible range of values for the population parameter is a confidence interval.

  • In order to construct a confidence interval we need to quantify the variability of our sample statistic
  • For example, if we want to construct a confidence interval for a population slope, we need to come up with a plausible range of values around our observed sample slope
  • This range will depend on how precise and how accurate our sample mean is as an estimate of the population mean
14 / 31

Confidence intervals

A plausible range of values for the population parameter is a confidence interval.

  • In order to construct a confidence interval we need to quantify the variability of our sample statistic
  • For example, if we want to construct a confidence interval for a population slope, we need to come up with a plausible range of values around our observed sample slope
  • This range will depend on how precise and how accurate our sample mean is as an estimate of the population mean
  • Quantifying this requires a measurement of how much we would expect the sample population to vary from sample to sample
14 / 31

Suppose we split the class in half down the middle of the classroom and ask each student their heights. Then, we calculate the mean height of students on each side of the classroom. Would you expect these two means to be exactly equal, close but not equal, or wildly different?

15 / 31

Suppose we split the class in half down the middle of the classroom and ask each student their heights. Then, we calculate the mean height of students on each side of the classroom. Would you expect these two means to be exactly equal, close but not equal, or wildly different?


Suppose you randomly sample 50 students and 5 of them are left handed. If you were to take another random sample of 50 students, how many would you expect to be left handed? Would you be surprised if only 3 of them were left handed? Would you be surprised if 40 of them were left handed?

15 / 31

Quantifying the variability of slopes

We can quantify the variability of sample statistics using

  • simulation: via bootstrapping (now)

or

  • theory: via Central Limit Theorem (future stat courses!)
## # A tibble: 2 × 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 24.3 1.29 18.8 8.28e-24
## 2 family_income -0.0431 0.0108 -3.98 2.29e- 4
16 / 31

Bootstrapping

17 / 31

Bootstrapping

  • "pulling oneself up by one’s bootstraps": accomplishing an impossible task without any outside help
  • Impossible task: estimating a population parameter using data from only the given sample
  • Note: Notion of saying something about a population parameter using only information from an observed sample is the crux of statistical inference

🥾

18 / 31

Observed sample

19 / 31

Bootstrap population

Generated assuming there are more students like the ones in the observed sample...

20 / 31

Bootstrapping scheme

  1. Take a bootstrap sample - a random sample taken with replacement from the original sample, of the same size as the original sample
21 / 31

Bootstrapping scheme

  1. Take a bootstrap sample - a random sample taken with replacement from the original sample, of the same size as the original sample
  2. Calculate the bootstrap statistic - a statistic such as mean, median, proportion, slope, etc. computed on the bootstrap samples
21 / 31

Bootstrapping scheme

  1. Take a bootstrap sample - a random sample taken with replacement from the original sample, of the same size as the original sample
  2. Calculate the bootstrap statistic - a statistic such as mean, median, proportion, slope, etc. computed on the bootstrap samples
  3. Repeat steps (1) and (2) many times to create a bootstrap distribution - a distribution of bootstrap statistics
21 / 31

Bootstrapping scheme

  1. Take a bootstrap sample - a random sample taken with replacement from the original sample, of the same size as the original sample
  2. Calculate the bootstrap statistic - a statistic such as mean, median, proportion, slope, etc. computed on the bootstrap samples
  3. Repeat steps (1) and (2) many times to create a bootstrap distribution - a distribution of bootstrap statistics
  4. Calculate the bounds of the XX% confidence interval as the middle XX% of the bootstrap distribution
21 / 31

Bootstrap sample 1

elmhurtst_boot_1 <- elmhurst %>%
slice_sample(n = 50, replace = TRUE)

22 / 31

Bootstrap sample 2

elmhurtst_boot_2 <- elmhurst %>%
slice_sample(n = 50, replace = TRUE)

23 / 31

Bootstrap sample 3

elmhurtst_boot_3 <- elmhurst %>%
slice_sample(n = 50, replace = TRUE)

24 / 31

Bootstrap sample 4

elmhurtst_boot_4 <- elmhurst %>%
slice_sample(n = 50, replace = TRUE)

25 / 31

Bootstrap samples 1 - 4

26 / 31

we could keep going...

27 / 31

Many many samples...

28 / 31

Slopes of bootstrap samples

29 / 31

95% confidence interval

30 / 31

Interpreting the slope, take two

## # A tibble: 1 × 2
## lower_ci upper_ci
## <dbl> <dbl>
## 1 -0.0695 -0.0232

We are 95% confident that for each additional $1,000 of family income, we would expect students to receive $69.5 to $23.24 less in gift aid, on average.

31 / 31

Recap and motivation

2 / 31
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow