我正在尝试对线性混合模型进行成对比较。我通过以下代码安装了它们
models_list_1 <- out_long %>%
group_by(signals) %>%
do(fit = lmerTest::lmer(value ~ COND + (1|COND), data = .)) %>%
pull(fit) %>%
lapply(., function(x) summary(x)) %>%
setNames(sort(unique(out_long$signals)))
现在,如果我要使用 Tukey adjstemnt 为存储在此列表中的每个元素计算成对比较,我应该怎么做?
我试过以下代码
lapply(model_list_1[[i]], lsmeans, pairwise ~ COND + (1 |COND), adjust="tukey")
但我一直在获取以下错误
Error in (function (object, at, cov.reduce = mean, cov.keep = get_emm_option("cov.keep"), :
Can't handle an object of class “character”
Use help("models", package = "emmeans") for information on supported models.
在这里,我让我正在处理的数据集。
> dput(head(out_long, 50))
structure(list(ID = c("01", "01", "01", "04", "04", "04", "06",
"06", "06", "07", "07", "07", "08", "08", "08", "09", "09", "09",
"10", "10", "10", "11", "11", "11", "12", "12", "12", "13", "13",
"13", "15", "15", "15", "16", "16", "16", "17", "17", "17", "18",
"18", "18", "19", "19", "19", "21", "21", "21", "22", "22"),
GR = c("RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",
"RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",
"RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",
"RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",
"RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",
"RP"), SES = c("V", "V", "V", "V", "V", "V", "V", "V", "V",
"V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",
"V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",
"V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",
"V", "V", "V", "V", "V"), COND = c("NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",
"NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC"
), signals = c("P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",
"P3FCz", "P3FCz", "P3FCz"), value = c(-11.6312151716924,
-11.1438413285935, -3.99591470944713, -0.314155675382471,
0.238885648959708, 5.03749946898385, -0.213621915029167,
-2.96032491743069, -1.97168681693488, -2.83109425298642,
1.09291198163802, -6.692991645215, 4.23849942428043, 2.9898889629932,
3.5510699900835, 9.57481668808606, 5.4167795618285, 1.7067607715475,
-6.13036076093477, -2.82955734597919, -2.50672211111696,
0.528517585832501, 8.16418133488309, 1.88777321897925, -7.73588468896919,
-9.83058052401056, -6.97442700196932, 1.27327945355082, 2.11962397764132,
0.524299677616254, -1.83310726842883, 0.658810483381172,
-0.261373488428192, 4.37524298634374, 0.625555654900511,
3.19617639836154, 0.0405517582137798, -3.29357103412113,
-0.381435057304614, -5.73445509910268, -6.1129152355645,
-2.45744234877604, 2.95352732001065, 0.527721249096473, 1.91803490989119,
-3.46703346467546, -2.40438419043702, -5.35374408162217,
-7.27028665849262, -7.1532211375959)), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))
>
为了更清楚,例如第一个对象包含如下汇总统计信息:
models_list_1[[1]]
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: value ~ COND + (1 | COND)
Data: .
REML criterion at convergence: 408.5
Scaled residuals:
Min 1Q Median 3Q Max
-2.6477 -0.6313 0.0030 0.4443 3.6366
Random effects:
Groups Name Variance Std.Dev.
COND (Intercept) 1.013 1.007
Residual 14.896 3.860
Number of obs: 75, groups: COND, 3
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 2.4710 1.2686 72.0000 1.948 0.0553 .
CONDNEG-NOC 0.5535 1.7940 72.0000 0.309 0.7586
CONDNEU-NOC -1.7600 1.7940 72.0000 -0.981 0.3299
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) CONDNEG
CONDNEG-NOC -0.707
CONDNEU-NOC -0.707 0.500
optimizer (nloptwrap) convergence code: 0 (OK)
unable to evaluate scaled gradient
Hessian is numerically singular: parameters are not uniquely determined