R:条件二进制逻辑回归 - 语法和调试 [英] R: conditional binary logistic regression - Syntax and debugging

查看:157
本文介绍了R:条件二进制逻辑回归 - 语法和调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我在这里与专家的谈话( Link1 Link2 ),我想我需要做一个条件二进制逻辑回归。我已经按照每个控件完全按照对应的处理方式排列数据,数据处于长格式。



我的设计在上面的两个链接加上这两个链接: Link3 Link4



编辑:稍后我发现排序并不重要,因为排序和未排序的数据导致在相同的输出。



我的语法如下。代码运行,但结果是如此奇怪。大多数SE是零,大多数P值是NaN。什么是错?

 库(Epi)

clogistic((DV〜(Demo1 + Demo2 + Demo3 + Demo4 + Demo5)^ 2),
strata = PatientID,data = Data4)

输出是:

 > clogistic((DV〜(Demo1 + Demo2 + Demo3 + Demo4 + Trt)^ 2),strata = PatientID,data = MixedModelData4)

调用:
clogistic(formula = Demo1 + Demo2 + Demo3 + Demo4 + Trt)^ 2),
strata = PatientID,data = MixedModelData4




coef exp(coef )se(coef)zp
Demo1 0.00e + 00 1.00e + 00 0 NaN NaN
Demo2 0.00e + 00 1.00e + 00 0 NaN NaN
Demo3 -3.27e-09 1.00e +00 56013 -5.83e-14 1
Demo4 0.00e + 00 1.00e + 00 0 NaN NaN
Trt -2.12e + 01 6.19e-10 14786 -1.43e-03 1
Demo1:Demo2 0.00e + 00 1.00e + 00 0 NaN NaN
Demo1:Demo3 0.00e + 00 1.00e + 00 0 NaN NaN
演示1:演示4 0.00e + 00 1.00e + 00 0 NaN NaN
演示1:Trt -4.34e-08 1.00e + 00 50351 -8.62e-13 1
演示2:演示3 0.00e + 00 1.00e + 00 0 NaN NaN
演示2:演示4 0.00e +00 1.00e + 00 0 NaN NaN
Demo2:T rt -1.19e-08 1.00e + 00 12937 -9.20e-13 1
演示3:演示4 0.00e + 00 1.00e + 00 0 NaN NaN
演示3:Trt 8.08e-09 1.00e + 00 19595 4.12e-13 1
演示4:Trt -1.62e-08 1.00e + 00 31612 -5.12e-13 1

似然比测试= 15.9f时为13.9,p = 0.536, n = 20
警告信息:
在clogistic((DV〜(Demo1 + Demo2 + Demo3 + Demo4 + Trt)^ 2),strata = PatientID,
迭代限制超过


解决方案

当系数或其标准错误爆炸时,通常表示病理资料情况。可能存在完全分离或严重的多重共线性(或两者)。您需要同时提供:

  str(MixedModelData4)


 
with(MixedModelData4,table(DV,Demo1,Demo3))
with(MixedModelData4,table(DV,Demo1,Demo3))
with(MixedModelData4,table(DV,Demo1, Demo4))
with(MixedModelData4,table(DV,Demo1,Demo5))

这仅仅是初学者。您的数据中可能存在其他三种组合之一的问题。


From my talks with experts here (Link1, Link2), I think I need to do a conditional binary logistic regression. I have sorted my data in a way that each control is exactly followed by the counterpart treatment case and the data is in long format.

My design is detailed in the above two links plus these two more links: Link3, Link4

edit: later I saw that sorting is not at all important because the sorted and non-sorted data resulted in the same output.

My syntax is the following. The code runs but the result is so strange. Most SEs are zero and most P values are NaN. What is wrong?

library(Epi)

clogistic((DV ~ (Demo1 +Demo2 +Demo3 +Demo4 +Demo5)^2), 
          strata = PatientID,  data = Data4)

The output is:

> clogistic((DV ~ (Demo1 +Demo2 +Demo3 +Demo4 +Trt)^2), strata = PatientID,  data = MixedModelData4)

Call: 
clogistic(formula = (DV ~ (Demo1 + Demo2 + Demo3 + Demo4 + Trt)^2), 
    strata = PatientID, data = MixedModelData4)




                 coef exp(coef) se(coef)         z   p
Demo1        0.00e+00  1.00e+00        0       NaN NaN
Demo2        0.00e+00  1.00e+00        0       NaN NaN
Demo3       -3.27e-09  1.00e+00    56013 -5.83e-14   1
Demo4        0.00e+00  1.00e+00        0       NaN NaN
Trt         -2.12e+01  6.19e-10    14786 -1.43e-03   1
Demo1:Demo2  0.00e+00  1.00e+00        0       NaN NaN
Demo1:Demo3  0.00e+00  1.00e+00        0       NaN NaN
Demo1:Demo4  0.00e+00  1.00e+00        0       NaN NaN
Demo1:Trt   -4.34e-08  1.00e+00    50351 -8.62e-13   1
Demo2:Demo3  0.00e+00  1.00e+00        0       NaN NaN
Demo2:Demo4  0.00e+00  1.00e+00        0       NaN NaN
Demo2:Trt   -1.19e-08  1.00e+00    12937 -9.20e-13   1
Demo3:Demo4  0.00e+00  1.00e+00        0       NaN NaN
Demo3:Trt    8.08e-09  1.00e+00    19595  4.12e-13   1
Demo4:Trt   -1.62e-08  1.00e+00    31612 -5.12e-13   1

Likelihood ratio test=13.9  on 15 df, p=0.536, n=20
Warning message:
In clogistic((DV ~ (Demo1 + Demo2 + Demo3 + Demo4 + Trt)^2), strata = PatientID,  :
  Iteration limit exceeded

解决方案

When coefficients or their standard errors "blow up" it usually indicates a pathological data situation. Complete separation or serious muli-collinearity (or both) may exist. You need to provide both:

 str(MixedModelData4) 

and:

with( MixedModelData4, table(DV,Demo1, Demo2) )
with( MixedModelData4, table(DV,Demo1, Demo3))
with( MixedModelData4, table(DV,Demo1, Demo3))
with( MixedModelData4, table(DV,Demo1, Demo4))
with( MixedModelData4, table(DV,Demo1, Demo5))

And that's just for starters. The problem could exist in one of the other three way combinations that are in your data.

这篇关于R:条件二进制逻辑回归 - 语法和调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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