knitr::opts_chunk$set(echo = TRUE)
library(SDS100)

$\$

Does the AstraZeneca vaccine cause blood clots?

A study found that 79 people experienced clots after receiving a first vaccine dose. More than 20 million AstraZeneca vaccines doses had been administered across the UK by the end of March.

About four people in a million would normally be expected to develop this particular kind of blood clot - though the fact they are so rare makes the usual rate hard to estimate.

$\$

CI for a single proportion

The create a 95% confidence interval for the proportion of people who are expected to get a blood clot if they take the AstraZeneca vaccine. Recall, our formula for calculate the confidence interval is:

$$\hat{p} \pm z^* \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}$$

n <- 20 * 10^6

p_hat <-  79/n

SE <- sqrt(   (p_hat * (1 - p_hat))/n    )

z_star <- qnorm(.975)

p_hat - z_star * SE
p_hat + z_star * SE

Is it likely you will get a blood clot?

$\$

Confidence interval for a single proportion using the bootstrap

library(tictoc)


has_clot <- rep(TRUE, 79)
no_clot <- rep(FALSE, (20 * 10^6) - 79)

data_vec <- c(has_clot, no_clot)



boot_data <- sample(data_vec, replace = TRUE)

boot_proportion <- mean(boot_data)


library(tictoc)

tic()

boot_dist <- do_it(10) * {

  boot_data <- sample(data_vec, replace = TRUE)
  boot_proportion <- mean(boot_data)

}

toc()

$\$

Confidence interval for a single mean

How many birds to cats kill?

A study by Loyd et al (20213) in Biological Conservation, used KittyCams to record all activity of n = 55 domestic cats that hunt outdoors.

The video footage showed that the mean number of kills per week for these cats was 2.4 with a standard deviation of 1.51.

Find and interpret a 99% confidence interval for the mean number of kills per week by US household cats that hunt outdoors.

xbar <- 2.4
n <- 55
s = 1.51
t_star <- qt(.995, 54)

2.4 + c(-1, 1) * t_star * s/sqrt(n)

$\$

Hypothesis test for a single mean

It is recommended that adults sleep at least 8 hours a night

A Statistics professor asked 12 undergraduate students how much sleep they were getting and found the average was 6.2 hours with a standard deviation of 1.7 hours.

Assuming this is representative of all students in a Statistics class, does this provide evidence that students in the class are not getting enough sleep on average?

mu0 <- 8
xbar <- 6.2
n <- 12
s = 1.17
t_star <- qt(.975, 54)

(t_stat <- (xbar - mu0)/(s/sqrt(n)))

pt(t_stat, n-1)


emeyers/SDS100 documentation built on April 28, 2024, 5:07 p.m.