【问题标题】:Direction of Estimate coefficient in a Log Regression对数回归中估计系数的方向
【发布时间】:2020-03-05 03:43:25
【问题描述】:

我正在分析序数逻辑回归,我想知道,如何知道估计系数的方向?我的变量只有 0、1 代表女性、男性,0、1、2、4 代表不同的姿势。所以我的问题是,我怎么知道,如果估计描述的是从 0 到 1 的变化,还是从 1 到 0 的变化,是指性别?

输出给 PicSex 添加了一个 1,这是一个标志,表明这个有一个 1->0 的方向吗?请参阅代码。

感谢您的帮助


Cumulative Link Mixed Model fitted with the Laplace approximation

formula: Int ~ PicSex + Posture + (1 | PicID)
data:    x

Random effects:
 Groups Name        Variance Std.Dev.
 PicID  (Intercept) 0.0541   0.2326  
Number of groups:  PicID 16 

Coefficients:
        Estimate Std. Error z value Pr(>|z|)    
PicSex1   0.3743     0.1833   2.042   0.0411 *  
Posture  -1.1232     0.1866  -6.018 1.77e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


P.S.
Thank you here are my head results (I relabeled PicSex to Sex)

> head(Posture)
[1] 1 1 1 1 1 1
Levels: 0 1
> head(Sex)
[1] 0 0 0 0 0 0
Levels: 0 1

So the level order is the same, but on Sex it still added  a 1 but on posture not. Still very confused about the directions.



【问题讨论】:

  • 您是否获得了用于获取此公式的代码,例如glm(...) 或同等学历?如果您知道您的链接功能应该很清楚,但测试它的一种简单方法是使用具有predict 功能的模型对象对新的姿势值进行预测,并观察预测是增加还是减少
  • 如果我理解正确的话,PicSex1 是性的固定效应,并且是分类的。因此,您的模型的总体截距是 R 识别为第一个的性别级别(因此,如果您将性别编码为 F 或 M,F 将是参考,因为它在字母表中是第一个)。 PicID 的 RE 以“0”为中心,但实际上它是您拟合性别截距后截距项周围的方差。我会,作为一个健全的检查,只是做levels(PicSex),虽然使用predict函数的建议也很棒。
  • 我使用了以下代码:“var.with.red

标签: r statistics logistic-regression mixed-models


【解决方案1】:

你的性别有两个级别,0 或 1。所以 PicSex1 表示 PicSex 为 1 与 PicSex 为 0 的效果。我在下面使用 wine 数据集展示了一个示例:

library(ordinal)
DATA = wine
> head(DATA$temp)
[1] cold cold cold cold warm warm
Levels: cold warm

这里冷在关卡中是第一位的,所以它被设置为任何线性模型中的参考。首先我们验证冷与暖的效果

do.call(cbind,tapply(DATA$rating,DATA$temp,table))
#warm has a higher average rating

拟合模型

# we fit the a model, temp is fixed effect
summary(clmm(rating ~ temp + contact+(1|judge), data = DATA))
Cumulative Link Mixed Model fitted with the Laplace approximation

formula: rating ~ temp + contact + (1 | judge)
data:    DATA

 link  threshold nobs logLik AIC    niter    max.grad cond.H 
 logit flexible  72   -81.57 177.13 332(999) 1.03e-05 2.8e+01

Random effects:
 Groups Name        Variance Std.Dev.
 judge  (Intercept) 1.279    1.131   
Number of groups:  judge 9 

Coefficients:
           Estimate Std. Error z value Pr(>|z|)    
tempwarm     3.0630     0.5954   5.145 2.68e-07 ***
contactyes   1.8349     0.5125   3.580 0.000344 ***

在这里,我们看到暖与“温度”相关联,我们知道,它具有正系数,因为与冷(参考)相比,暖的评级更好。

因此,如果您将另一个组设置为参考,您将看到附加的另一个名称,并且系数反转(-3.. 与前面示例中的 +3.. 相比)

# we set warm as reference now
DATA$temp = relevel(DATA$temp,ref="warm")

summary(clmm(rating ~ temp + contact+(1|judge), data = DATA))
Cumulative Link Mixed Model fitted with the Laplace approximation

formula: rating ~ temp + contact + (1 | judge)
data:    DATA

 link  threshold nobs logLik AIC    niter    max.grad cond.H 
 logit flexible  72   -81.57 177.13 269(810) 1.14e-04 1.8e+01

Random effects:
 Groups Name        Variance Std.Dev.
 judge  (Intercept) 1.28     1.131   
Number of groups:  judge 9 

Coefficients:
           Estimate Std. Error z value Pr(>|z|)    
tempcold    -3.0630     0.5954  -5.145 2.68e-07 ***
contactyes   1.8349     0.5125   3.580 0.000344 ***

所以在拟合模型之前总是检查参考是什么

【讨论】:

  • 谢谢,这是我的头部结果(我将 PicSex 重新标记为性别)> 头部(姿势)[1] 1 1 1 1 1 1 级别:0 1 > 头部(性别)[1] 0 0 0 0 0 0 Levels: 0 1 所以级别顺序是一样的,但是在 Sex 上它仍然加了 1 但在姿势上没有。
  • 奇怪,如果你用我的例子,你可以看到因素。我认为您的数据有些奇怪。
  • 我将数据转换为像 Sex = factor(x$PicSex) 这样的因子。会不会是错误的来源?
  • 如果 x$PicSex 是数字应该没问题。嘿菲利克斯,如果没有可重复的例子,我真的无法判断。
  • 谢谢,我得到了解决方案。:姿势太长,R在我将Var name Posture缩短为Pos后添加了open或close。 @StupidWolf
猜你喜欢
  • 1970-01-01
  • 2014-01-02
  • 2011-11-12
  • 2020-03-13
  • 2016-09-21
  • 2016-11-30
  • 2019-04-29
  • 2013-02-12
  • 1970-01-01
相关资源
最近更新 更多