Below are summary statistics on fuel efficiency (in miles/gallon) from random samples of cars with manual and automatic transmissions manufactured in 2012. Do these data provide strong evidence of a difference between the average fuel efficiency of cars with manual and automatic transmissions in terms of their average city mileage?
# load data ---------------------------------------------------------
fuel_eff <- read.csv("https://mhc-stat140-2017.github.io/data/misc/fuel_eff.csv")
# select a small sample ---------------------------------------------
man_rows <- which(fuel_eff$transmission == "M")
aut_rows <- which(fuel_eff$transmission == "A")
set.seed(3583)
man_rows_samp <- sample(man_rows, 26)
aut_rows_samp <- sample(aut_rows, 26)
fuel_eff_samp <- fuel_eff[c(man_rows_samp,aut_rows_samp), ]
fuel_eff_samp$transmission <- droplevels(fuel_eff_samp$transmission)
levels(fuel_eff_samp$transmission) <- c("automatic", "manual")
ggplot() +
geom_density(mapping = aes(x = comb_mpg, color = transmission), data = fuel_eff_samp)
fuel_eff_man <- filter(fuel_eff_samp, transmission == "manual")
fuel_eff_aut <- filter(fuel_eff_samp, transmission == "automatic")
mean(fuel_eff_man$comb_mpg)
## [1] 22.85
sd(fuel_eff_man$comb_mpg)
## [1] 4.73
mean(fuel_eff_aut$comb_mpg)
## [1] 18.65
sd(fuel_eff_aut$comb_mpg)
## [1] 4.137
Are these data paired or unpaired?
SOLUTION:
SOLUTION:
SOLUTION:
SOLUTION:
You can use t.test()
function.
# call to t.test() here
SOLUTION:
SOLUTION:
The British Medical Journal published an article titled “Is Friday the 13th Bad for Your Health?” The article examined the number of people admitted to emergency rooms for vehicular accidents on 12 Friday evenings (6 each on the 6th and 13th). Here are the data:
friday13 <- read.csv("https://mhc-stat140-2017.github.io/data/sdm4/Friday_the_13th_Part_2.csv") %>%
mutate(difference = X13th - X6th)
head(friday13)
Is there a difference between rates of accidents on Friday the 13th and Friday the 6th?
SOLUTION:
Are these data paired or unpaired?
SOLUTION:
SOLUTION:
SOLUTION:
SOLUTION:
You can use t.test()
function.
SOLUTION:
# Your code goes here
SOLUTION:
SOLUTION: