我正在尝试运行“关于比例差异的假设检验”的代码,但“推理链”无法运行>>>错误:Syunik(变量)不是解释变量的水平。
RuternMigration <- read.csv ("ruternmigration.csv", header=TRUE)
RuternMigration
str(RuternMigration)
RuternMigration[, 'returnmigration'] <- as.factor(mtcars[, 'returnmigration'])
str(RuternMigration)
p_hats <- RuternMigration %>%
group_by(region) %>%
summarize(prop_favor = mean(returnmigration == "Yes")) %>%
pull()
# Compute difference in proportions
d_hat <- diff(p_hats)
null <- RuternMigration %>%
specify(returnmigration ~ region, success = "Yes") %>%
hypothesize(null = "independence") %>%
generate(reps = 500, type = "permute") %>%
calculate(stat = "diff in props", order = c("Syunik", "Aragatsotn"))
错误:Syunik不是解释变量的级别。