如何从模型结构中删除数据的某些元素

发布于 2025-02-09 17:22:30 字数 1908 浏览 0 评论 0原文

以下是我的数据示例:

> dput(mydata1)
structure(list(subject = c("E1", "E1", "E1", "E1", "E1", "E1", 
"E1", "E1", "E1", "E1", "E1", "E1"), block = c(3, 3, 3, 4, 4, 
4, 5, 5, 5, 6, 6, 6), condition = c("EI", "EI", "I", "EI", "EI", 
"I", "EI", "EI", "I", "EI", "EI", "I"), RT = c(271, 370, 469, 
409, 560, 1506, 544, 544, 978, 452, 340, 645), Item_number = c(1, 
2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)), row.names = c(NA, -12L), class = c("tbl_df", 
"tbl", "data.frame"))

  > mydata1
# A tibble: 12 x 5
   subject block condition    RT Item_number
   <chr>   <dbl> <chr>     <dbl>       <dbl>
 1 E1          3 EI          271           1
 2 E1          3 EI          370           2
 3 E1          3 I           469           3
 4 E1          4 EI          409           1
 5 E1          4 EI          560           2
 6 E1          4 I          1506           3
 7 E1          5 EI          544           1
 8 E1          5 EI          544           2
 9 E1          5 I           978           3
10 E1          6 EI          452           1
11 E1          6 EI          340           2
12 E1          6 I           645           3 

我可以使用LME4运行混合效应模型。

library(lme4)
mydata1_model <- lmer(RT ~ block + (1|Item_number), REML = F,  data=mydata1,  na.action= na.exclude)
summary(mydata1_model)

在从模型结构中删除item_number = 3之后,我正在尝试重新运行此分析。我可以轻松地从数据集中删除它,但是由于我正在运行多个模型,出于我正在执行的任务目的,从模型结构中删除item_number 3是更有意义的。基本上,我试图查看与此item_number有或没有的模式是否相同。

1)我想知道是否有任何方法可以修改下面模型的内部结构以适应此更改:

mydata1_model <- lmer(RT ~ block + (1|Item_number), REML = F,  data=mydata1,  na.action= na.exclude)
  1. 是否可以删除多个元素,例如item_number 3和item_number 2?

请注意,在实际数据中,有很多主题,当然我需要在所有数据集中进行此更改工作。

预先感谢您的帮助,

Below is the sample of my data:

> dput(mydata1)
structure(list(subject = c("E1", "E1", "E1", "E1", "E1", "E1", 
"E1", "E1", "E1", "E1", "E1", "E1"), block = c(3, 3, 3, 4, 4, 
4, 5, 5, 5, 6, 6, 6), condition = c("EI", "EI", "I", "EI", "EI", 
"I", "EI", "EI", "I", "EI", "EI", "I"), RT = c(271, 370, 469, 
409, 560, 1506, 544, 544, 978, 452, 340, 645), Item_number = c(1, 
2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)), row.names = c(NA, -12L), class = c("tbl_df", 
"tbl", "data.frame"))

  > mydata1
# A tibble: 12 x 5
   subject block condition    RT Item_number
   <chr>   <dbl> <chr>     <dbl>       <dbl>
 1 E1          3 EI          271           1
 2 E1          3 EI          370           2
 3 E1          3 I           469           3
 4 E1          4 EI          409           1
 5 E1          4 EI          560           2
 6 E1          4 I          1506           3
 7 E1          5 EI          544           1
 8 E1          5 EI          544           2
 9 E1          5 I           978           3
10 E1          6 EI          452           1
11 E1          6 EI          340           2
12 E1          6 I           645           3 

I could run mixed-effects model using lme4.

library(lme4)
mydata1_model <- lmer(RT ~ block + (1|Item_number), REML = F,  data=mydata1,  na.action= na.exclude)
summary(mydata1_model)

I am trying to re-run this analysis after removing the Item_number = 3 from the model strucure. I could easily remove it from the dataset, however since I am running multiple models, for the purpose of the task I am doing, it would make more sense to remove Item_number 3 from the model structure. Basically, I am trying to see if the patterns would be the same with or without this Item_number.

1)I am wondering if there is any way I could modify the internal structure of the model below to accommodate this change:

mydata1_model <- lmer(RT ~ block + (1|Item_number), REML = F,  data=mydata1,  na.action= na.exclude)
  1. Would it be possible to remove more than one element, for example Item_number 3 and Item_number 2?

Please note that in the actual data, there are many subjects and of course I need this change work across all data set.

Thanks in advance for your help,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文