LoslegenKostenlos loslegen

Bootstrapping the data

Using the infer package with type = "bootstrap", you can repeatedly sample from the dataset to estimate the sampling distribution and standard error of the slope coefficient. Using the sampling distribution will allow you to directly find a confidence interval for the underlying population slope.

Diese Übung ist Teil des Kurses

Inference for Linear Regression in R

Kurs anzeigen

Anleitung zur Übung

Use the infer steps to bootstrap the twins data 1000 times. You don't have to hypothesize() because now you're creating confidence intervals, not hypothesis testing!

  • Specify Foster versus Biological.
  • Generate 1000 replicates by bootstrapping.
  • Calculate the slope statistic.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Set the seed for reproducibility
set.seed(4747)

# Calculate 1000 bootstrapped slopes
boot_slope <- twins %>%
  # Specify Foster vs. Biological
  ___ %>%
  # Generate 1000 bootstrap replicates
  ___ %>%
  # Calculate the slope statistic
  ___

# See the result  
boot_slope
Code bearbeiten und ausführen