【发布时间】:2017-12-17 17:22:36
【问题描述】:
这个问题是在对该主题进行了长期研究之后提出的。非常感谢您的回复。
我进行了一项研究,现在我的目标是测试 Treatment 对 ouctome 的影响,但我想检查种族。
n treatment: 83
n placebo: 76
No missings.
地点:
**ID -> Participant identification
Con_dummy -> Treatment or Control (Between subjects)
Hispanic -> Yes or no (Between subjects)
M41 and M_42 -> Dependent variables. M_41 was measured in 2016 and M_42 was measures in 2017.**
我使用以下代码将我的数据集转换为长格式:
d2_stack_long <- df_stack %>% group_by(cond_dummy) %>% select(ID, cond_dummy, hispanic, M_4I1TOT,M_4I2TOT) %>% gather(key="ID", value, M_4I1TOT,M_4I2TOT) %>% tbl_df() %>% setNames(c("ID","Condition","Hispanic", "Time","Result")) %>% mutate(Time = ifelse(Time == "M_4I1TOT", "Time 1", "Time 2")) %>% arrange(ID)
我有消息
警告消息:跨度量的属性不相同 变量;他们将被丢弃
但现在我有一个很长的数据集。我现在有双倍的行数,因为每个参与者都是在两个时间点测量的,但一切都保持不变
> d2_stack_long %>% group_by(Condition, Time) %>% summarise(mean(Result),n=n()) # A tibble: 4 x 4 # Groups: Condition [?] Condition Time `mean(Result)` n <chr> <chr> <dbl> <int> 1 Control Time 1 5.973684 76 2 Control Time 2 6.342105 76 3 Treatment Time 1 6.277108 83 4 Treatment Time 2 9.626506 83
现在,当我测试这个模型时,我在使用 R 和使用 JASP 时获得了两个不同的结果。
mod <- lm(data=d2_stack_long , Result ~ Time + Condition*Hispanic)
Anova(mod, type=3)
在问这个问题之前,我阅读了几篇帖子,但我发现有人评论math equation to ANOVA 或comparing results across packages,比如here。
带有示例的famous blog 已关闭。
谢谢。
【问题讨论】:
标签: r linear-regression anova