很抱歉,如果这是重复的帖子,我看过一些类似的帖子,但没有找到我想要的确切解决方案。
我将glmer模型拟合为以下形式的一些反应时间数据:
Range("1:1").Select
Selection.Find(What:="eventdate", After:=ActiveCell, LookIn:=xlFormulas2, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
Range(Selection.Offset(1, 0), Selection.Offset(1048570, 0).End(xlUp)).Select
Set rng = Selection
For Each eventdateCell In rng
eventdateCell.NumberFormat = "@"
eventdateCell.Value = WorksheetFunction.Text(eventdateCell.Value, "yyyy-mm-dd")
Next eventdateCell
其中:m19 <- glmer(response ~ trial_z*stim + cond + (1 + stim | subj_idx),
na.action = na.exclude,
data = gng, family = "binomial",
control = glmerControl(optCtrl = list(maxfun = 50000)))
是标准执行/不执行任务上的二进制(正确响应,错误响应)。
我想使用response
函数绘制固定效果的比值,但似乎无法使事情看起来很正确。
我想为模型中的固定效果绘制这些几率:
sjplot::plot_model
如下所示:
library(broom.mixed)
tidy(m19,conf.int=TRUE,exponentiate=TRUE,effects="fixed")
以下sjplot调用将产生以下绘图对象:
# A tibble: 7 x 8
effect term estimate std.error statistic p.value conf.low conf.high
<chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 fixed (Intercept) 414. 123. 20.2 6.98e-91 231. 742.
2 fixed trial_z 0.697 0.0751 -3.35 7.97e- 4 0.564 0.860
3 fixed stimNoGo 0.00925 0.00257 -16.9 6.80e-64 0.00537 0.0159
4 fixed condThreeGo 1.48 0.151 3.82 1.32e- 4 1.21 1.80
5 fixed condFiveGo 1.69 0.174 5.07 4.08e- 7 1.38 2.06
6 fixed condSevenGo 1.51 0.151 4.07 4.73e- 5 1.24 1.83
7 fixed trial_z:stimNoGo 1.30 0.149 2.28 2.25e- 2 1.04 1.63
所以我尝试在调用中编辑axis.limits:
gg <- plot_model(m19, type="std", show.p=TRUE, ci.lvl=.95, dot.size=5,
line.size=2, vline.color = "black", axis.lim=c(.001, 2.25)) +
theme_bw(base_size=24) +
theme(panel.grid.major.y=element_blank()) +
ggtitle("") +
ylab("Odds Ratio")
plot(gg)
有点恼人的是,将第二个串联的axis.lim元素碰撞到1到10之间的任何值都会产生我的尝试1,但是随后超过10的任何东西都会将图中的限制限制为100(不确定为什么是这样)>
因此,我尝试根据其他帖子来事后编辑轴:
gg2 <- plot_model(m19, type="std", show.p=TRUE, ci.lvl=.95, dot.size=5,
line.size=2, vline.color = "black", axis.lim=c(.001, 11)) +
theme_bw(base_size=24) +
theme(panel.grid.major.y=element_blank()) +
ggtitle("") +
ylab("Odds Ratio")
plot(gg2)
我的问题:
我想要的情节有点像尝试2和尝试3的组合。
在2中,我喜欢在1之上和之下的缩放比例不同,并且1(相等几率)具有特殊表示法,表明与1重叠的CI表示无效效果。如果我想要的不在gg + ylim(.001, 2.25)
的能力范围内,那么我会停留在如何使轴位于该1标记右侧以更像尝试3中的刻度的方式上,从而消除了关于和反对,并在所有y值上将比例尺设置为统一(而且,一开始这肯定令人困惑,因为我要管理用户在x轴上看到的内容。我假设某个地方有一个plot_model()
调用在功能中...)。
如果我可以进一步说明lmk。感谢您的输入!
答案 0 :(得分:0)
我认为这可能有效:
gg + scale_y_log10(limits = c(0.001, 2.25))
示例:
library(sjPlot)
library(ggplot2)
model <- glm(vs ~ mpg + cyl, data = mtcars, family = "binomial")
p <- plot_model(model)
p + scale_y_log10(limits = c(0.001, 2.5))
#> Scale for 'y' is already present. Adding another scale for 'y', which will
#> replace the existing scale.
由reprex package(v0.3.0)于2020-06-27创建