简体   繁体   English

分割图重复测量方差分析,线性回归和R中的不同结果

[英]Split-plot Repeated measures anova, Linear regression and different Results in R

This question here came after a long research about the subject. 这个问题是在对该主题进行了长期研究之后提出的。 I'll appreciate your reply. 多谢您的回覆。

I conducted a research and now my goal is to test the effect of the Treatment on the ouctome , but I want to check the moderation effect of the Race . 我进行了一项研究,现在我的目标是测试“ 治疗 ”对本人基因组的作用 ,但我想检查“种族”调节作用

n treatment: 83 
n placebo: 76
No missings.

My original dataset is in Wide format. 我的原始数据集为宽格式。 宽幅

Where: 哪里:

**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.**

I transformed my dataset to a long format using this code: 我使用以下代码将数据集转换为长格式:

 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) 

I've got a message 我有个消息

Warning message: attributes are not identical across measure variables; 警告消息:度量值变量之间的属性不相同; they will be dropped 他们将被丢弃

But now I have a long dataset. 但是现在我的数据集很长。 I have the double numbers of rows now, because every participant was measured at two time point, but everything remains the same 我现在的行数是两倍,因为每个参与者都是在两个时间点进行衡量的,但是一切都保持不变

长格式

 > 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 

When, now, I test this model, I achieve two different results when using R and when using JASP. 现在,当我测试该模型时,使用R和使用JASP时会获得两个不同的结果。

mod <- lm(data=d2_stack_long , Result ~ Time + Condition*Hispanic)
Anova(mod, type=3)

I think I'm forgeting to adjust something and I'll appreciate your help. 我想我忘了调整一些东西,感谢您的帮助。 在此处输入图片说明

I read several posts before asking this question, but I just found people commenting about math equation to ANOVA or comparing results across packages like here . 在问这个问题之前,我读了几篇文章,但是我只是发现人们对ANOVA的数学方程式进行评论或者像这里的 包之间比较结果
A famous blog with examples is down. 著名的博客实例。

Thanks. 谢谢。

If someone wants the answer. 如果有人想要答案。 After a Long journey I got from this post . 经过漫长的旅程,我得到了这个职位 The sums of squares type in R is set to 1, whereas in JASP it is set to 3. R中的平方和类型设置为1,而在JASP中将其设置为3。

You can add an ERROR term in Regression models (Repeated measures), despite 99% of posts here. 可以在回归模型(重复测量)中添加一个ERROR术语,尽管此处有99%的帖子。

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

And if you want to go with aov funcion: 如果您想使用aov函数:

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

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM