Derek Corcoran
"04/04, 2018"
learnr
faithful
data("faithful")
t.test(x = faithful$waiting, mu = 60, alternative = "two.sided")
One Sample t-test
data: faithful$waiting
t = 13.22, df = 271, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 60
95 percent confidence interval:
69.27418 72.51994
sample estimates:
mean of x
70.89706
airquality
library(tidyverse)
SummMonth <- airquality %>% group_by(Month) %>% summarize(Mean = mean(Ozone, na.rm = TRUE), SD = sd(Ozone, na.rm = TRUE))
Month | Mean | SD |
---|---|---|
5 | 23.61538 | 22.22445 |
6 | 29.44444 | 18.20790 |
7 | 59.11538 | 31.63584 |
8 | 59.96154 | 39.68121 |
9 | 31.44828 | 24.14182 |
AirJuly <- airquality %>% filter(Month == 7)
AirAug <- airquality %>% filter(Month == 8)
t.test(AirJuly$Ozone, mu = 55, alternative = "greater")
One Sample t-test
data: AirJuly$Ozone
t = 0.66331, df = 25, p-value = 0.2566
alternative hypothesis: true mean is greater than 55
95 percent confidence interval:
48.51757 Inf
sample estimates:
mean of x
59.11538
t.test(AirAug$Ozone, mu = 55, alternative = "greater")
One Sample t-test
data: AirAug$Ozone
t = 0.63756, df = 25, p-value = 0.2648
alternative hypothesis: true mean is greater than 55
95 percent confidence interval:
46.66857 Inf
sample estimates:
mean of x
59.96154
¿En que meses se debiera aplicar el descuento?
mtcars
columna am designa si un vehiculo es automático (0) o manual (1) var.equal
t.test(mpg ~ am, data = mtcars, var.equal =TRUE)
Two Sample t-test
data: mpg by am
t = -4.1061, df = 30, p-value = 0.000285
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-10.84837 -3.64151
sample estimates:
mean in group 0 mean in group 1
17.14737 24.39231
BeerDark
en webcursos o en el siguiente link. BeerDark <- read_csv("https://archive.org/download/BeerDark/BeerDark.csv")
t.test(Amargor ~ Estilo, var.equal =TRUE, data = BeerDark)
Two Sample t-test
data: Amargor by Estilo
t = -21.233, df = 6409, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-16.70647 -13.88231
sample estimates:
mean in group Porter mean in group Stout
37.80220 53.09659
hist(faithful$waiting, xlab = "Minutos de espera entre erupciones")
qqnorm(faithful$waiting)
shapiro.test(faithful$waiting)
Shapiro-Wilk normality test
data: faithful$waiting
W = 0.92215, p-value = 1.015e-10
t.test
pero wilcox.test
data("faithful")
wilcox.test(x = faithful$waiting, mu = 60, alternative = "two.sided")
Wilcoxon signed rank test with continuity correction
data: faithful$waiting
V = 31048, p-value < 2.2e-16
alternative hypothesis: true location is not equal to 60
manuales <- mtcars %>% filter(am == 1)
hist(manuales$mpg, xlim = c(10,35), ylim = c(0,5))
autos <- mtcars %>% filter(am == 0)
hist(autos$mpg, xlim = c(10,35), ylim = c(0,5))
qqnorm(manuales$mpg)
ggplot(mtcars, aes(x = factor(am), y = mpg)) + geom_boxplot()
bartlett.test(mpg ~ am, data = mtcars)
Bartlett test of homogeneity of variances
data: mpg by am
Bartlett's K-squared = 3.2259, df = 1, p-value = 0.07248
wilcox.test(mpg ~ am, data = mtcars)
Wilcoxon rank sum test with continuity correction
data: mpg by am
W = 42, p-value = 0.001871
alternative hypothesis: true location shift is not equal to 0
Evalue basado en histograma, qqplot y test de shapiro si se debe reevaluar la hipótesis para los meses de julio y agosto y si es necesario haga una nueva prueba
Evalúe si es necesario revaluar la hipotesis de que el amargor es distinto entre ambos estilos de cerveza y si es necesario haga una nueva prueba