This function uses 2 estimates and 2 margins of error to do significance testing. It optionally returns the input data frame with the calculations used for testing, or just the data frame with results attached.
moe_test(
.data,
est1,
moe1,
est2,
moe2,
cl = 0.9,
alpha = 0.05,
show_calc = TRUE
)A data frame
Estimate for first group
Margin of error for first group
Estimate for second group
Margin of error for second group
Confidence level used in calculating MOEs given; defaults to 0.9, per ACS data
Alpha used for significance testing; defaults to 0.05
Logical, whether to keep intermediary calculations (default) or only result of testing
A tibble/data frame with testing-related columns added
med_age <- data.frame(name = c("Hamden", "New Haven"),
men_est = c(37.2, 29.5), men_moe = c(1.9, 0.8),
women_est = c(37.8, 31.9), women_moe = c(1.9, 0.8))
med_age %>%
moe_test(men_est, men_moe, women_est, women_moe, alpha = 0.9, show_calc = TRUE)
#> name men_est men_moe women_est women_moe diff se1 se2
#> 1 Hamden 37.2 1.9 37.8 1.9 0.6 1.1551180 1.1551180
#> 2 New Haven 29.5 0.8 31.9 0.8 2.4 0.4863655 0.4863655
#> se z_score isSig_10
#> 1 1.6335835 0.3672907 TRUE
#> 2 0.6878246 3.4892615 TRUE