如何在 R 中分割和修改多重混合效应模型的点图

问题描述 投票:0回答:1

我在 R 4.3.1 中有以下脚本,这不是完整的脚本,而只是相关部分:

library(lme4)
library(lmerTest)
library(ggplot2)
library(lattice)
library(RColorBrewer)

MEDE.fin <- lmer(Relative_Value ~ Dilution + (Dilution|Paper) + (1|Paper:DataSet), data=DE_data)

dotplot(ranef(MEDE.fin), condVar = TRUE)

这给了我以下两张图: Not the important graph Important graph

第二张图显示了对截距和斜率的随机影响,但是我只想使用显示斜率的部分。我该如何解决这个问题? (如果您还可以告诉我如何更改图形布局的颜色,那就加分了)

我尝试运行此代码

(dotplot(ranef(MEDE.fin, condVar=TRUE))$Paper)$g[1]
,这是我在 stackoverflow 上找到的代码的变体,但它不起作用。

r lme4 lattice dot-plot
1个回答
0
投票

无法测试,因为我没有你的数据,但类似这样的东西应该可以工作:

dd <- as.data.frame(ranef(MEDE.fin), condVar = TRUE))
dd <- subset(dd, term == "Dilution")
library(ggplot2)
ggplot(dd, aes(y=grp,x=condval)) +
  geom_point() + facet_wrap(~term,scales="free_x") +
  geom_errorbarh(aes(xmin=condval -2*condsd,
                     xmax=condval +2*condsd), height=0)

不确定“更改图形布局的颜色”是什么意思。

© www.soinside.com 2019 - 2024. All rights reserved.