#install.packages("BSDA")
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## Warning: package 'tibble' was built under R version 4.0.2
## Warning: package 'tidyr' was built under R version 4.0.2
## Warning: package 'dplyr' was built under R version 4.0.2
## Warning: package 'openintro' was built under R version 4.0.2
## Warning: package 'airports' was built under R version 4.0.2
## Warning: package 'cherryblossom' was built under R version 4.0.2
## Warning: package 'usdata' was built under R version 4.0.2
## Warning: package 'BSDA' was built under R version 4.0.3
## [1] "C:/Users/Jerome/Documents/201030_Math217_Week8_HW"
Problem 7.2.5
tsum.test(18.3, 17.8,33, 13.9,19.1, 51)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.075, df = 71.901, p-value = 0.286
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.759852 12.559852
## sample estimates:
## mean of x mean of y
## 18.3 13.9
Problem 7.5.5
tsum.test (972.1, 245.1, 12, 843.4, 251.2, 15)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.3408, df = 23.961, p-value = 0.1925
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -69.41849 326.81849
## sample estimates:
## mean of x mean of y
## 972.1 843.4
tsum.test (972.1, 245.1, 12, 843.4, 251.2, 15, conf.level = 0.9)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.3408, df = 23.961, p-value = 0.1925
## alternative hypothesis: true difference in means is not equal to 0
## 90 percent confidence interval:
## -35.52815 292.92815
## sample estimates:
## mean of x mean of y
## 972.1 843.4
Practice t-test
## Warning: package 'infer' was built under R version 4.0.2
a <- c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110)
b <- c(5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105)
mean(a)
## [1] 60
## [1] 33.16625
## [1] 55
## [1] 33.16625
t.test(a,b, alternative = "less")
##
## Welch Two Sample t-test
##
## data: a and b
## t = 0.35355, df = 20, p-value = 0.6363
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## -Inf 29.3912
## sample estimates:
## mean of x mean of y
## 60 55
data(yrbss)
class(yrbss$height)
## [1] "numeric"
## [1] "numeric"
t.test(yrbss$height,yrbss$weight, alternative = "greater")
##
## Welch Two Sample t-test
##
## data: yrbss$height and yrbss$weight
## t = -439.47, df = 12579, p-value = 1
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## -66.46311 Inf
## sample estimates:
## mean of x mean of y
## 1.691241 67.906503
Problem 7.5.10
tsum.test(31.96, 12.05, 25, 25.32, 13.78, 25, alternative = "less")
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.8137, df = 47.161, p-value = 0.962
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## NA 12.78263
## sample estimates:
## mean of x mean of y
## 31.96 25.32
tsum.test(31.96, 12.05, 25, 25.32, 13.78, 25, alternative = "greater")
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.8137, df = 47.161, p-value = 0.03805
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## 0.4973688 NA
## sample estimates:
## mean of x mean of y
## 31.96 25.32
tsum.test(31.96, 12.05, 25, 25.32, 13.78, 25)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 1.8137, df = 47.161, p-value = 0.0761
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7245135 14.0045135
## sample estimates:
## mean of x mean of y
## 31.96 25.32
Problem 7.6.7
tsum.test (0.354, 0.058, 530, 0.263, 0.051, 420)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = 25.698, df = 937.77, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.08405043 0.09794957
## sample estimates:
## mean of x mean of y
## 0.354 0.263
Problem 7.10.3
toluene <- c(3420, 2314, 1911, 2464, 2781, 2803)
control <- c(1820, 1843, 1397, 1803, 2539, 1990)
wilcox.test(toluene, control, alternative = "two.sided", conf.int = TRUE, conf.level= 0.95)
##
## Wilcoxon rank sum exact test
##
## data: toluene and control
## W = 32, p-value = 0.02597
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## 91 1406
## sample estimates:
## difference in location
## 726
wilcox.test(toluene, control, alternative = "greater", conf.int = TRUE, conf.level= 0.95)
##
## Wilcoxon rank sum exact test
##
## data: toluene and control
## W = 32, p-value = 0.01299
## alternative hypothesis: true location shift is greater than 0
## 95 percent confidence interval:
## 242 Inf
## sample estimates:
## difference in location
## 726
Problem 7.10.7
single <- c(3.3, 2.4, 2.5, 3.3, 2.4)
group <- c(3.9, 4.1, 4.8, 3.9, 3.4)
wilcox.test(single, group, alternative = "two.sided", conf.int = TRUE, conf.level= 0.95)
## Warning in wilcox.test.default(single, group, alternative = "two.sided", :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(single, group, alternative = "two.sided", :
## cannot compute exact confidence intervals with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: single and group
## W = 0, p-value = 0.01141
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## -2.2999860 -0.5999636
## sample estimates:
## difference in location
## -1.400047
LS0tDQp0aXRsZTogIkxhYiBOYW1lIg0KYXV0aG9yOiAiQXV0aG9yIE5hbWUiDQpkYXRlOiAiYHIgU3lzLkRhdGUoKWAiDQpvdXRwdXQ6IG9wZW5pbnRybzo6bGFiX3JlcG9ydA0KLS0tDQoNCmBgYHtyIGxvYWQtcGFja2FnZXMsIG1lc3NhZ2U9RkFMU0V9DQojaW5zdGFsbC5wYWNrYWdlcygiQlNEQSIpDQpsaWJyYXJ5KHRpZHl2ZXJzZSkNCmxpYnJhcnkob3BlbmludHJvKQ0KbGlicmFyeShCU0RBKQ0KZ2V0d2QoKQ0KYGBgDQoNCiMjIyBQcm9ibGVtIDcuMi41DQoNCmBgYHtyfQ0KdHN1bS50ZXN0KDE4LjMsIDE3LjgsMzMsIDEzLj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