有序逻辑回归

Author

胡林辉

导入常用依赖包

参考资料

https://stats.oarc.ucla.edu/r/dae/ordinal-logistic-regression/

读取与整理数据

AKI day 0

用MASS包作有序逻辑回归(不显示)

没有P值。

用ordinal包做有序逻辑回归

formula: stage ~ Arg + Cit + GCA + GDS + GUA + HArg + HCit + MG
data:    aki0

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -29.68 79.36 7(0)  9.41e-11 1.1e+05

Coefficients:
      Estimate Std. Error z value Pr(>|z|)  
Arg   0.009573   0.103596   0.092   0.9264  
Cit   0.591116   0.300681   1.966   0.0493 *
GCA   0.013250   0.010294   1.287   0.1980  
GDS   0.328467   0.444549   0.739   0.4600  
GUA  -0.113267   0.060164  -1.883   0.0597 .
HArg -0.317587   0.870323  -0.365   0.7152  
HCit -0.495564   0.249700  -1.985   0.0472 *
MG    0.026382   0.033989   0.776   0.4376  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   2.0615     0.8083   2.550
Ⅱ|Ⅲ   3.4021     0.9479   3.589

有P值。

筛选显著变量重新做一遍

formula: stage ~ Cit + GCA + HCit
data:    aki0

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -33.14 76.28 6(0)  4.38e-11 6.9e+04

Coefficients:
      Estimate Std. Error z value Pr(>|z|)  
Cit   0.479765   0.228775   2.097   0.0360 *
GCA   0.003704   0.005587   0.663   0.5073  
HCit -0.369459   0.199369  -1.853   0.0639 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   2.4355     0.6553   3.717
Ⅱ|Ⅲ   3.6657     0.7964   4.603

再次筛选显著变量重新做一遍

formula: stage ~ Cit + HCit
data:    aki0

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -33.34 74.69 6(0)  3.79e-12 4.9e+02

Coefficients:
     Estimate Std. Error z value Pr(>|z|)  
Cit    0.4773     0.2320   2.058   0.0396 *
HCit  -0.3425     0.1972  -1.737   0.0824 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   2.3183     0.6200   3.739
Ⅱ|Ⅲ   3.5440     0.7664   4.624

显示正确率矩阵

AKI day 1

ordinal包有序逻辑回归

formula: stage ~ Arg + Cit + GCA + GDS + GUA + HArg + HCit + MG
data:    aki1

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -31.68 83.35 6(0)  2.18e-08 7.3e+05

Coefficients:
       Estimate Std. Error z value Pr(>|z|)
Arg   0.0733761  0.0512306   1.432    0.152
Cit  -0.3363920  0.3233330  -1.040    0.298
GCA  -0.0095074  0.0124167  -0.766    0.444
GDS   0.3265145  2.2952857   0.142    0.887
GUA  -0.0413328  0.0430812  -0.959    0.337
HArg -0.7178380  2.3637098  -0.304    0.761
HCit  0.1828431  0.2303772   0.794    0.427
MG   -0.0006241  0.0069986  -0.089    0.929

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ  -0.3047     0.8131  -0.375
Ⅱ|Ⅲ   0.9709     0.8811   1.102

全部无差异

AKI day 3

ordinal包有序逻辑回归

formula: stage ~ Arg + Cit + GCA + GDS + GUA + HArg + HCit + MG
data:    aki3

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -7.51  35.01 14(0) 1.65e-12 3.7e+07

Coefficients:
       Estimate Std. Error z value Pr(>|z|)  
Arg   -0.082542   0.176425  -0.468   0.6399  
Cit    0.008648   0.383517   0.023   0.9820  
GCA    0.216166   0.131023   1.650   0.0990 .
GDS  -61.536887  35.157237  -1.750   0.0801 .
GUA    0.181093   0.110352   1.641   0.1008  
HArg  -8.141856  36.830374  -0.221   0.8250  
HCit  -1.088291   0.630720  -1.725   0.0844 .
MG    -0.035254   0.026154  -1.348   0.1777  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   -3.552      2.318  -1.533
Ⅱ|Ⅲ    1.362      1.768   0.770
formula: stage ~ GCA + GDS + HCit
data:    aki3

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -11.88 33.75 10(0) 1.52e-07 4.1e+05

Coefficients:
      Estimate Std. Error z value Pr(>|z|)   
GCA    0.12360    0.04781   2.585  0.00974 **
GDS  -22.53363    9.18976  -2.452  0.01421 * 
HCit  -0.88639    0.44720  -1.982  0.04747 * 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ  -2.8360     1.3501  -2.101
Ⅱ|Ⅲ   0.6883     0.9327   0.738

显示正确率矩阵

AKI day 7

ordinal包有序逻辑回归

formula: stage ~ Arg + Cit + GCA + GDS + GUA + HArg + HCit + MG
data:    aki7

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -23.22 66.45 9(0)  6.95e-09 1.7e+06

Coefficients:
       Estimate Std. Error z value Pr(>|z|)  
Arg    0.015096   0.060664   0.249   0.8035  
Cit    0.061745   0.065294   0.946   0.3443  
GCA    0.004621   0.025855   0.179   0.8582  
GDS   -2.218179   1.266191  -1.752   0.0798 .
GUA   -0.010568   0.035557  -0.297   0.7663  
HArg -12.761318   7.036482  -1.814   0.0697 .
HCit  -0.058212   0.130217  -0.447   0.6548  
MG     0.050145   0.033690   1.488   0.1366  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   0.3169     1.0672   0.297
Ⅱ|Ⅲ   2.1198     1.1287   1.878
formula: stage ~ GDS + HArg
data:    aki7

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -26.98 61.97 8(0)  8.90e-13 8.6e+01

Coefficients:
     Estimate Std. Error z value Pr(>|z|)  
GDS    -2.153      1.160  -1.855   0.0635 .
HArg   -5.278      2.865  -1.842   0.0654 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ  -0.8461     0.6930  -1.221
Ⅱ|Ⅲ   0.6375     0.7125   0.895

显示正确率矩阵

AKI day 14

ordinal包有序逻辑回归

formula: stage ~ Arg + Cit + GCA + GDS + GUA + HArg + HCit + MG
data:    aki14

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -23.60 67.19 7(0)  2.95e-10 9.1e+05

Coefficients:
     Estimate Std. Error z value Pr(>|z|)  
Arg  -0.08404    0.12552  -0.669   0.5032  
Cit   0.19068    0.21090   0.904   0.3659  
GCA   0.02537    0.01836   1.382   0.1670  
GDS  -2.95291    1.62003  -1.823   0.0683 .
GUA   0.01590    0.01386   1.147   0.2513  
HArg -1.92412    2.97232  -0.647   0.5174  
HCit -0.16854    0.13360  -1.262   0.2071  
MG    0.01267    0.01567   0.808   0.4189  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   0.3546     1.1466   0.309
Ⅱ|Ⅲ   2.2360     1.2968   1.724
formula: stage ~ GDS
data:    aki14

 link  threshold nobs logLik AIC   niter max.grad cond.H 
 logit flexible  61   -33.28 72.57 6(0)  9.07e-12 2.0e+01

Coefficients:
    Estimate Std. Error z value Pr(>|z|)  
GDS   -1.766      0.891  -1.982   0.0475 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Threshold coefficients:
    Estimate Std. Error z value
Ⅰ|Ⅱ   0.3569     0.5897   0.605
Ⅱ|Ⅲ   1.5879     0.6761   2.349

显示正确率矩阵

组合图

TableGrob (2 x 2) "arrange": 4 grobs
  z     cells    name           grob
1 1 (1-1,1-1) arrange gtable[layout]
2 2 (1-1,2-2) arrange gtable[layout]
3 3 (2-2,1-1) arrange gtable[layout]
4 4 (2-2,2-2) arrange gtable[layout]

8种代谢物的变化趋势