【问题标题】:How to adjust the x-axis range in an effect plot如何调整效果图中的 x 轴范围
【发布时间】:2016-09-16 13:49:37
【问题描述】:

我有我的拟合模型,想通过 R (v.3.3.1) 中的“效果”包绘制效果。到目前为止,一切正常。

     dipt.moi <- lmer(log_dipt ~ stemp + shum + swind + scc + ct + mt + (1|plot)

#Plotting:

        library(effects)
        plot(allEffects(dipt.moi)[1])

#or:

        plot(Effect(focal.predictors = "stemp", dipt.moi)

但是当我查看我的绘图时,我注意到 x 轴并未涵盖我数据的所有范围。它只是在边缘“切断”了一些数据。 奇怪的是,这并不适用于我所有的情节,只适用于一些情节,我无法在这里发现特定的模式。

effect plot

请注意,我在 stemp 上的实际数据范围是 -2.1 到 2.9

我试图调整:

plot(Effect(focal.predictors = "stemp", dipt.moi),xlevels=c(-2.1,2.9))

#and

dlist<-list(L$stemp)
plot(Effect(focal.predictors = "stemp", dipt.moi),xlevels=list(dlist))

情节已绘制,但不会有任何改变。

这个问题在其他论坛上也有人问过(https://stat.ethz.ch/pipermail/r-help/2014-February/366237.html),但我用 xlevels 命令(如上)、xlim 命令尝试过,但没有成功。

有人知道如何在这里调整 x 轴吗?也许这根本不可能?!

问候,卢卡斯。

【问题讨论】:

  • 您应该向reproducible example 提供示例数据和用于制作绘图的代码。这样可以更轻松地为您提供帮助。
  • 更新了,希望现在更容易理解。感谢您的提示。

标签: r plot statistics


【解决方案1】:

这不是plot() 的问题,而是由于allEffects() 从-2 计算到2。您可以使用参数xlevels 定义范围,但您无法正确给出。

library(effects); library(lme4)

dipt.moi <- lmer(log_dipt ~ stemp + shum + swind + scc + ct + mt + (1|plot))

dlist <- list(stemp = seq(-2.1, 2.9, 0.4))       # the example values
plot(allEffects(dipt.moi, xlevels = dlist)[1])

【讨论】:

  • 哇,我真的错过了。非常感谢。非常适合我。
猜你喜欢
  • 2014-02-27
  • 1970-01-01
  • 1970-01-01
  • 2016-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多