简体   繁体   English

axis.title =在sjPlot包的sjp.lmer()中不起作用

[英]axis.title = is not working in sjp.lmer() in the sjPlot package

I'm doing some plotting of some mixed models I've been running and am pulling my hair out trying to make sjp.lmer() change the x and y axis labels of a fixed effect. 我正在绘制一些我一直在运行的混合模型,并试图将sjp.lmer()更改固定效果的x和y轴标签。 If I'm missing something simple, please let me know! 如果我缺少简单的东西,请告诉我!

This is my code: 这是我的代码:

library(sjPlot);library(lme4)

model = lmer(DV ~ IV + (1|groupingVariable), data = data, REML = F)

sjp.lmer(model, 
     type = "fe.slope", 
     vars = c("IV"),
     title = "Estimated effect of IV1 on DV", 
     geom.colors = c("black", "grey49"), 
     show.ci = T, 
     axis.title = c("IV Title", "DV Title"))

Model is a formal model estimated using glmer(). 模型是使用glmer()估算的形式模型。 The problem is that regardless of what I write, the x and y labels do not change. 问题是无论我写什么,x和y标签都不会改变。

I think the syntax is correct, because this code works: 我认为语法是正确的,因为此代码有效:

sjp.lmer(model, 
     type = "re", 
     sort.est = "sort.all", 
     facet.grid = F,
     axis.title = c("IV Title", "DV Title"))

This second being a plot of the random effects for the same model. 第二个是相同模型的随机效应图。 Is this a bug? 这是错误吗? Can you for some reason not specify axis labels for fixed effect models? 出于某种原因,您可以不为固定效果模型指定轴标签吗? Thank you! 谢谢!

Seems like a bug. 好像是个错误。 I've raised the issue on gitHub at: 我在gitHub上提出了这个问题:

https://github.com/sjPlot/devel/issues/212 https://github.com/sjPlot/devel/issues/212

As far as I can tell it's just an oversight ("misfeature"/bug). 据我所知,这只是一个疏忽(“错误功能” /错误)。 Looking at the code here : 这里看代码:

reglinplot <- reglinplot +
  labs(title = title,
       x = sjmisc::get_label(model_data[[p_v]], def.value = p_v),
       y = response)

it seems the labels are hard-coded. 标签似乎是硬编码的。 Furthermore, the argument list of sjp.reglin ( here ) doesn't have an axis.title argument ... posting an issue, as you have done, seems like the right way forward. 此外, sjp.reglin的参数列表( 在此处 )没有axis.title参数...正如您所做的那样,发布问题似乎是正确的方法。

However, it's not too hard to hack the plot a little bit if you know just a tiny bit about the ggplot2 package. 但是,如果您只对ggplot2软件包了解一点,那么稍微修改一下该图就不太困难。

Set up example: 设置示例:

library(sjPlot); library(lme4
mod <- lmer(Reaction~Days+(Days|Subject),sleepstudy)
p1 <- sjp.lmer(mod, 
     type = "fe.slope", 
     vars = "Days")  ## stripped-down (warning about colour palette)

Hack labels: 骇客标签:

library(ggplot2)
p1$plot.list[[1]] + labs(x="hello",y="goodbye")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM