具有库“效果”的GLM图中的缩放轴被缩放。 [英] Scaling axis in a GLM plot with library "effects"

查看:93
本文介绍了具有库“效果”的GLM图中的缩放轴被缩放。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名生物学毕业生,试图使用R和库 effects绘制我的GLMM。

i'm a biology graduate trying to plot my GLMM using R and the library "effects".

我正在尝试使用此字符串绘制模型,

I'm trying to plot my model using this string, and it works perfectly.

library(effects) 
mod.cowles <- glmer((preshunt)~road+(1|area),family=binomial)
eff.cowles <- allEffects(mod.cowles) 
plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1)

我的问题是我需要轴具有相同的倾斜度,从0到0.5的值,并且具有相同的缩放比例。我正在尝试通过在脚本中添加它们来做到这一点

My problem is that i need the axis with the same lims, starting from 0 to 0.5 values and with the same scaling. I'm trying doing that by adding them in the script

mod.cowles <- glmer((preshunt)~road+(1|area),family=binomial)
eff.cowles <- allEffects(mod.cowles) 
plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1, xlim=c(0,0.5), ylim=c(0,0.5))

但是随后R只是决定给我一个空图,甚至没有正确的轴。

But then R just decide to give me an empty graph, not even with correct axis.

有人可以给我提示吗解决这个问题?

Can anybody give me a hint on how to solve this problem?

推荐答案

我写信给函数John Fox的作者,并得到答复说y上的值实际上是对数刻度( :facepalm :,这是逻辑回归!)。将原始值转换为logit并返回是相当简单的。

I wrote to the author of the function John Fox and got a reply that the values on y are actually on logit scale (:facepalm:, it's a logistic regression!). It's fairly trivial to convert "raw" values to logit and back.

以下是一个可重现的示例:

Here's a reproducible example:

library(effects) 
library(lme4)

mod.cowles <- glmer(volunteer ~ extraversion + (1|sex), 
                    family=binomial, data = Cowles) # doesn't converge
eff.cowles <- allEffects(mod.cowles) 

plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1, 
     xlim=c(0, 20), ylim = qlogis(c(0.1, 0.6))) # also log(c(.1, .6)/c(.6, .1))

您可以设置 ylim = qlogis(c(0.01,0.99)),您会得到下图。请注意,这是对数级,其中0和1是(-)Inf

You can set ylim = qlogis(c(0.01, 0.99)) and you'll get the below plot. Mind that this is on logit scale where 0 and 1 are (-)Inf.

qlogis(seq(0, 1, by = 0.1))
[1] -Inf -2.1972246 -1.3862944 -0.8472979 -0.4054651 0.0000000
    0.4054651 0.8472979 1.3862944 2.1972246 Inf

这篇关于具有库“效果”的GLM图中的缩放轴被缩放。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆