library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/WhiteBlackHispanic.csv")
mydata$DV <- mydata$Minutes
mydata$IV <- mydata$Precinct
group_by(mydata, IV) %>%
summarise(
count = n(),
mean = mean(DV, na.rm = TRUE),
sd = sd(DV, na.rm = TRUE),
min = min(DV, na.rm = TRUE),
max = max(DV, na.rm = TRUE))
## # A tibble: 3 × 6
## IV count mean sd min max
## <chr> <int> <dbl> <dbl> <dbl> <dbl>
## 1 Precinct 18 149 13.7 4.47 0.7 23.4
## 2 Precinct 3 164 15.2 8.32 -4.7 36
## 3 Precinct 8 132 9.15 4.48 -2.9 18.3
options(scipen = 999)
oneway.test(mydata$DV ~ mydata$IV,
var.equal = FALSE)
##
## One-way analysis of means (not assuming equal variances)
##
## data: mydata$DV and mydata$IV
## F = 49.407, num df = 2.00, denom df = 288.58, p-value <
## 0.00000000000000022
anova_1 <- aov(mydata$DV ~ mydata$IV)
TukeyHSD(anova_1)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = mydata$DV ~ mydata$IV)
##
## $`mydata$IV`
## diff lwr upr p adj
## Precinct 3-Precinct 18 1.530009 -0.1137634 3.173781 0.0741826
## Precinct 8-Precinct 18 -4.535235 -6.2712665 -2.799203 0.0000000
## Precinct 8-Precinct 3 -6.065244 -7.7635718 -4.366916 0.0000000
Summary: The difference between precinct 3 response times and precinct 18 is not statistically significant because the p value is greater than 0.05. this means we can neither accept nor reject our null hypothesis, but we can reject the alternative hypothesis. Between precincts 8 and 18, as well as 8 and 3 is in fact statistically significant and we can reject the null hypothesis in favor of the alternative hypothesis.
library(tidyverse)
mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/RichPoor.csv")
mydata$DV <- mydata$Minutes
mydata$IV <- mydata$Precinct
group_by(mydata, IV) %>%
summarise(
count = n(),
mean = mean(DV, na.rm = TRUE),
sd = sd(DV, na.rm = TRUE),
min = min(DV, na.rm = TRUE),
max = max(DV, na.rm = TRUE))
## # A tibble: 2 × 6
## IV count mean sd min max
## <chr> <int> <dbl> <dbl> <dbl> <dbl>
## 1 Precinct 12 159 14.3 7.05 -4.6 34.6
## 2 Precinct 8 132 9.15 4.48 -2.9 18.3
options(scipen = 999)
t.test(mydata$DV ~ mydata$IV,
var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: mydata$DV by mydata$IV
## t = 7.5258, df = 271.55, p-value = 0.0000000000007732
## alternative hypothesis: true difference in means between group Precinct 12 and group Precinct 8 is not equal to 0
## 95 percent confidence interval:
## 3.787442 6.471049
## sample estimates:
## mean in group Precinct 12 mean in group Precinct 8
## 14.27925 9.15000
Summary: The statistical difference between precincts 12 and 8 is significant meaning we can reject the null hypothesis in favor of the alternative. the p-value is 0.0000000000007732 which is less than 0.05.
library(tidyverse)
mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/Weekly18and23.csv")
mydata$V1 <- mydata$Minutes_2018
mydata$V2 <- mydata$Minutes_2023
mydata$PairDifferences <- mydata$V2 - mydata$V1
mydata %>%
select(PairDifferences) %>%
summarise(
count = n(),
mean = mean(PairDifferences, na.rm = TRUE),
sd = sd(PairDifferences, na.rm = TRUE),
min = min(PairDifferences, na.rm = TRUE),
max = max(PairDifferences, na.rm = TRUE))
## count mean sd min max
## 1 52 4.75 9.017206 -15.3 26.8
mydata %>%
select(V1, V2) %>%
summarise_all(list(Mean = mean, SD = sd))
## V1_Mean V2_Mean V1_SD V2_SD
## 1 8.763462 13.51346 5.951867 5.998203
options(scipen = 999)
t.test(mydata$V2, mydata$V1,
paired = TRUE)
##
## Paired t-test
##
## data: mydata$V2 and mydata$V1
## t = 3.7986, df = 51, p-value = 0.0003888
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 2.239594 7.260406
## sample estimates:
## mean difference
## 4.75
Summary: in a paired t test the response times from 2018-2023 showed significant difference with a mean difference of 4.75 minutes. the p value is less than 0.05 meaning we can reject the null.