R 中的数值数据推断
Mine Cetinkaya-Rundel
Associate Professor of the Practice, Duke University
将比较年均 income 改为比较平均 hrly_rate:
hrly_rate = income / (hrs_work * 52)数据是否提供了美国公民与非公民平均小时工资存在差异的有力证据?
设 $\mu =$ 平均小时工资
$H_0: \mu_{citizen} = \mu_{non-citizen}$
$H_A: \mu_{citizen} \ne \mu_{non-citizen}$
acs12 %>%
filter(!is.na(hrly_rate)) %>%
group_by(citizen) %>%
summarise(x_bar = round(mean(hrly_rate), 2),
s = round(sd(hrly_rate), 2),
n = length(hrly_rate))
citizen x_bar s n
1 no 21.19 34.50 58
2 yes 18.52 24.73 901
t.test(hrly_rate ~ citizen, data = acs12, null = 0,
alternative = "two.sided")
null = 0alternative = "two.sided"t.test(hrly_rate ~ citizen, data = acs12, null = 0,
alternative = "two.sided")
Welch Two Sample t-test
data: hrly_rate by citizen
t = 0.58058, df = 60.827, p-value = 0.5637
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-6.53483 11.88170
sample estimates:
mean in group no mean in group yes
21.19494 18.52151

R 中的数值数据推断