R Chi-squared由多个群体分层

时间:2016-02-14 14:57:37

标签: r statistics chi-squared

我使用3个因子变量和一个百分比变量得到以下df:

  df <- data.frame(
    group = rep(c("Case", "Control"), each=16),
    timing = rep(c("T0", "T1", "T2", "T3"), each=4, times=2),
    food.type = rep (c("Very healthy", "Healthy", "Unhealthy", "Very bad"), times = 8),
    intake.percentage = runif(32, min=1, max=25)
)

我如何进行测试(chi平方)以评估每种食物的组(病例;对照)之间每次(T0-T3)的统计学差异?

为方便起见,可以帮助您理解的情节:

ggplot(df, aes(x = timing,y = intake.percentage, group=group)) +

geom_line(aes(colour=group)) +
geom_point(aes(colour=group, shape=group), size=3) +
theme_light(16) +

facet_grid(facets = .~food.type, scales = 'free')

enter image description here

1 个答案:

答案 0 :(得分:1)

对于它的编程部分(用于编程问题的Stackoverflow,Cross Validated用于统计问题),假设您为每个场景进行了100次试验:

lnkName