【问题标题】:Split-plot Repeated measures anova, Linear regression and different Results in R裂区重复测量方差分析、线性回归和 R 中的不同结果
【发布时间】:2017-12-17 17:22:36
【问题描述】:

这个问题是在对该主题进行了长期研究之后提出的。非常感谢您的回复。

我进行了一项研究,现在我的目标是测试 Treatmentouctome 的影响,但我想检查种族。

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 ANOVAcomparing results across packages,比如here
带有示例的famous blog 已关闭。

谢谢。

【问题讨论】:

    标签: r linear-regression anova


    【解决方案1】:

    如果有人想要答案。经过漫长的旅程,我从这个post 得到了。 R 中的平方和类型设置为 1,而 JASP 中设置为 3。

    可以在回归模型(重复测量)中添加 ERROR 项,尽管此处有 99% 的帖子。

    options(contrasts=c("contr.helmert", "contr.poly"))
    anova(lm(Result ~ Time*Condition*Hispanic*ID, data=d2_pals_total))
    

    如果你想使用 aov 函数:

    summary(aov(data=d2_pals_total, Result ~ Time*Condition*Hispanic +
          Error(ID)))
    

    谢谢

    【讨论】:

      猜你喜欢
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多