R:sjp.glmer 将 x 轴边界、y 轴标签从百分比更改为小数以及置信带颜色

R: sjp.glmer changing x-axis lim, y-axis label from percentage to decimal, and confidence band colors

我在 R 中使用 sjPlot 包已经有一段时间了,我非常喜欢它。但是最近,我 运行 遇到了一些我自己也想不通的问题。

(1) 使用sjp.glmer(fe.prob),x轴labels/spacing似乎是由待绘制的固定因子导出的。我可以使用 'axis.lim' 更改 y 轴限制,但是,我很难更改 x 轴限制。

(2) 自上次更新(我认为是 10.1.17)以来,配色方案已略有更改。结果,我几乎看不到我的信心带。理论上我可以改变背景让它们更显眼。但是,我正在寻找的是改变置信带的实际颜色。我怀疑可以使用 sjp.setTheme 更改这个,但我不知道如何更改。

(3) 同样自上次更新以来(我认为),类型 "fe.prob" 的 sjp.glmer 的 y 轴被标记为百分比(1% 到 100%)而不是小数( 0 到 1)。有什么提示我可以将它切换回小数吗?

这是一个示例行:

sjp.glmer(Model, 
          type = "fe.prob",
          vars = "Var1", 
          show.scatter = FALSE, 
          geom.colors = "Black", 
          width = 7.9, height = 6.8, 
          facet.grid = FALSE, 
          show.ci = TRUE, 
          axis.lim = c(0,1)) 

下面也是我的 Sjp.SetTheme 设置。

我希望这能说明问题: Example Figure

感谢任何帮助。

最好的, S

sjp.setTheme(base = theme_grey(),
             geom.outline.color = "black",
             theme.font = 'Times',
             geom.outline.size = 1, 
             geom.label.size = 2,
             geom.label.color = "black",
             title.color = "black", 
             title.size = 1.0, 
             axis.title.size = 1.0,
             axis.title.color =  "black",
             axis.angle.x = 0,
             axis.textsize.x = 1.0,
             axis.textsize.y = 1.0,
             axis.textcolor = "black")

无法通过 sjp.glmer 直接修改您请求的问题 - 但是,您可以使用返回的 ggplot-object 进行进一步操作。

library(sjPlot)
library(lme4)
library(ggplot2)
library(sjmisc)

# create binary response
sleepstudy$Reaction.dicho <- dicho(sleepstudy$Reaction, dich.by = "median")
# fit model
fit <- glmer(Reaction.dicho ~ Days + (Days | Subject),
             data = sleepstudy, family = binomial("logit"))

p <- sjp.glmer(fit, type = "fe.prob", vars = "Days", 
               show.scatter = FALSE, geom.colors = "Black", 
               facet.grid = FALSE, show.ci = TRUE)

# get first plot of all created plots (in this case, just one plot)
# and change x-axis-limits and use another metric on y-scale
p$plot.list[[1]] + xlim(0, 4) + scale_y_continuous(limits = c(0, 1))

尽管如此,置信区间的透明度非常高,但我不太确定如何将 alpha-level 更改为 stat_smooth。我会寻找解决方案...