Lecture 3
BIOB11 - Experimental design and analysis for biologists
Department of Biology, Lund University
2025-03-31


# A tibble: 1 × 2
  lower_ci upper_ci
     <dbl>    <dbl>
1     2.62     3.01# A tibble: 1 × 2
  lower_ci upper_ci
     <dbl>    <dbl>
1    0.862     1.15CI: If we repeated our experiment many times and calculated a 95% CI each time, the 95% CI’s would include the “true” value 95% of the time.
Get observed statistics:
specify() response (and explanatory) variable(s)calculate() observed statisticGet CI:
specify() response (and explanatory) variable(s)generate() bootstrap samplescalculate() observed statistic in each sampleget_confidence_interval()iris_data <-
  iris |>
  filter(Species == "setosa")
iris_data |>
  specify(response = Petal.Width) |>
  calculate(stat = "mean")Response: Petal.Width (numeric)
# A tibble: 1 × 1
   stat
  <dbl>
1 0.246iris_data |>
  specify(response = Petal.Width) |>
  generate(reps = 10000, type = "bootstrap") |>
  calculate(stat = "mean") |>
  get_confidence_interval(type = "percentile")# A tibble: 1 × 2
  lower_ci upper_ci
     <dbl>    <dbl>
1    0.218    0.276iris_data <-
  iris |>
  filter(Species == "setosa" | Species == "versicolor")
iris_data |>
  specify(response = Petal.Width, explanatory = Species) |>
  calculate(stat = "diff in means", order = c("setosa", "versicolor"))Response: Petal.Width (numeric)
Explanatory: Species (factor)
# A tibble: 1 × 1
   stat
  <dbl>
1 -1.08iris_data |>
  specify(response = Petal.Width, explanatory = Species) |>
  generate(reps = 10000, type = "bootstrap") |>
  calculate(stat = "diff in means", order = c("setosa", "versicolor")) |>
  get_confidence_interval(type = "percentile")# A tibble: 1 × 2
  lower_ci upper_ci
     <dbl>    <dbl>
1    -1.14    -1.02iris_data <-
  iris |>
  filter(Species == "setosa")
iris_data |>
  specify(response = Petal.Width, explanatory = Petal.Length) |>
  calculate(stat = "correlation")Response: Petal.Width (numeric)
Explanatory: Petal.Length (numeric)
# A tibble: 1 × 1
   stat
  <dbl>
1 0.332iris_data |>
  specify(response = Petal.Width, explanatory = Petal.Length) |>
  generate(reps = 10000, type = "bootstrap") |>
  calculate(stat = "correlation") |>
  get_confidence_interval(type = "percentile")# A tibble: 1 × 2
  lower_ci upper_ci
     <dbl>    <dbl>
1   0.0842    0.535