对数回归中估计系数的方向
Direction of Estimate coefficient in a Log Regression
我正在分析有序逻辑回归,我想知道,如何知道估计系数的方向?我的变量只有 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.
你的性别有两个级别,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
这里冷在Levels中排在第一位,所以它被设置为任何线性中的参考models.First我们验证冷与暖的效果
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 ***
这里我们看到温暖附加到 "temp" 并且我们知道,它具有正系数,因为与寒冷(参考)相比,温暖的评级更好。
因此,如果您将另一个组设置为参考,您将看到附加的另一个名称,并且系数是相反的(-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 ***
所以在拟合模型之前一定要检查参考是什么
我正在分析有序逻辑回归,我想知道,如何知道估计系数的方向?我的变量只有 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.
你的性别有两个级别,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
这里冷在Levels中排在第一位,所以它被设置为任何线性中的参考models.First我们验证冷与暖的效果
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 ***
这里我们看到温暖附加到 "temp" 并且我们知道,它具有正系数,因为与寒冷(参考)相比,温暖的评级更好。
因此,如果您将另一个组设置为参考,您将看到附加的另一个名称,并且系数是相反的(-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 ***
所以在拟合模型之前一定要检查参考是什么