本文介绍了删除缺失的数据值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我删除了原始帖子,以便能够发布更大版本的数据集.实际上总共有418行.

I deleted an original post so that I was able to post a larger version of the data set. There are actually 418 rows total.

以下是我正在进行的生存分析的数据.第一列是ID号,其他列标记为V2-V20.有许多丢失的数据用."表示.

Here is the data for a survival analysis I am conducting. The first column is ID number and the other columns are labelled V2 - V20. There are many missing data which are indicated by a ".".

我使用 coxph()函数获得以下信息:

I use the coxph() function to obtain the following:

#Saves survival time in vector "time".
time = surv.df[, "V2"]

#Saves information about censoring status in vector "status" in Cox's regression; death code should always be set to 1.
state = 1 - surv.df[, "V3"]

#Conduct Cox's regression analysis.
library(survival)
surv.cox = coxph(Surv(time, state == 1) ~ V4 + V5 + V6 + V7 + V8 + V9 + V10 + V11 + V12 + V13 + V14 + V15 + V16 + V17 + V18 + V19 + V20, data = surv.df)

Error in fitter(X, Y, istrat, offset, init, control, weights = weights,  :
  NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning messages:
1: In fitter(X, Y, istrat, offset, init, control, weights = weights,  :
  Ran out of iterations and did not converge
2: In fitter(X, Y, istrat, offset, init, control, weights = weights,  :
  one or more coefficients may be infinite

我假设问题出在值的缺失.我尝试使用以下方法粗略地清理数据:

I am assuming the problem is with the missing values. I've tried cleaning the data very crudely using:

#Allows us to use the select() function.
library(tidyverse)

#Find the missing value in each column.
surv.df[! is.na(surv.df)]

#Select the data column needed in an automatic data frame.
s1 = select(surv.df, V2)
s1[! is.na(s1)]

s2 = select(surv.df, V3)
s2[! is.na(s2)]

s3 = select(surv.df, V4)
s3[! is.na(s3)]
s3 = s3[-c(313:418), ]

等但是,我收效甚微.我想我的第一个问题将是,甚至有可能分析这么多缺失值的数据(由于字符限制,其中许多在我无法发布的行中)?如何删除所有缺失的值?一旦缺少值.",是否可以分析数据?被删除?

etc. However, I have had little success. I guess my first question is going to be, how is it even possible to analyze data with this many missing values (a lot of them are in the rows I was unable to post due to character limit)? How do I remove all the missing values? Is the data analyzable once the missing values `.' are removed?

  1  400 2 1 21464 1 1 1 1 1.0 14.5  261 2.60 156  1718.0 137.95 172 190 12.2 4
  2 4500 0 1 20617 1 0 1 1 0.0  1.1  302 4.14  54  7394.8 113.52  88 221 10.6 3
  3 1012 2 1 25594 0 0 0 0 0.5  1.4  176 3.48 210   516.0  96.10  55 151 12.0 4
  4 1925 2 1 19994 1 0 1 1 0.5  1.8  244 2.54  64  6121.8  60.63  92 183 10.3 4
  5 1504 1 2 13918 1 0 1 1 0.0  3.4  279 3.53 143   671.0 113.15  72 136 10.9 3
  6 2503 2 2 24201 1 0 1 0 0.0  0.8  248 3.98  50   944.0  93.00  63   . 11.0 3
  7 1832 0 2 20284 1 0 1 0 0.0  1.0  322 4.09  52   824.0  60.45 213 204  9.7 3
  8 2466 2 2 19379 1 0 0 0 0.0  0.3  280 4.00  52  4651.2  28.38 189 373 11.0 3
  9 2400 2 1 15526 1 0 0 1 0.0  3.2  562 3.08  79  2276.0 144.15  88 251 11.0 2
 10   51 2 2 25772 1 1 0 1 1.0 12.6  200 2.74 140   918.0 147.25 143 302 11.5 4
 11 3762 2 2 19619 1 0 1 1 0.0  1.4  259 4.16  46  1104.0  79.05  79 258 12.0 4
 12  304 2 2 21600 1 0 0 1 0.0  3.6  236 3.52  94   591.0  82.15  95  71 13.6 4
 13 3577 0 2 16688 1 0 0 0 0.0  0.7  281 3.85  40  1181.0  88.35 130 244 10.6 3
 14 1217 2 2 20535 0 1 1 0 1.0  0.8    . 2.27  43   728.0  71.00   . 156 11.0 4
 15 3584 2 1 23612 1 0 0 0 0.0  0.8  231 3.87 173  9009.8 127.71  96 295 11.0 3
 16 3672 0 2 14772 1 0 0 0 0.0  0.7  204 3.66  28   685.0  72.85  58 198 10.8 3
 17  769 2 2 19060 1 0 1 0 0.0  2.7  274 3.15 159  1533.0 117.80 128 224 10.5 4
 18  131 2 1 19698 1 0 1 1 1.0 11.4  178 2.80 588   961.0 280.55 200 283 12.4 4
 19 4232 0 1 18102 1 0 1 0 0.5  0.7  235 3.56  39  1881.0  93.00 123 209 11.0 3
 20 1356 2 2 21898 1 0 1 0 0.0  5.1  374 3.51 140  1919.0 122.45 135 322 13.0 4
 21 3445 0 2 23445 0 0 1 1 0.0  0.6  252 3.83  41   843.0  65.10  83 336 11.4 4
 22  673 2 1 20555 1 0 0 1 0.0  3.4  271 3.63 464  1376.0 120.90  55 173 11.6 4
 23  264 2 2 20442 1 1 1 1 1.0 17.4  395 2.94 558  6064.8 227.04 191 214 11.7 4
 24 4079 2 1 16261 0 0 1 0 0.0  2.1  456 4.00 124  5719.0 221.88 230  70  9.9 2
 25 4127 0 2 16463 1 0 0 0 0.0  0.7  298 4.10  40   661.0 106.95  66 324 11.3 2
 26 1444 2 2 19002 1 0 1 1 0.0  5.2 1128 3.68  53  3228.0 165.85 166 421  9.9 3
 27   77 2 2 19884 1 1 1 1 0.5 21.6  175 3.31 221  3697.4 101.91 168  80 12.0 4
 28  549 2 2 16417 1 1 1 1 1.0 17.2  222 3.23 209  1975.0 189.10 195 144 13.0 4
 29 4509 0 2 23331 1 0 0 0 0.0  0.7  370 3.78  24  5833.0  73.53  86 390 10.6 2
 30  321 2 2 15116 1 0 1 1 0.0  3.6  260 2.54 172  7277.0 121.26 158 124 11.0 4
 31 3839 2 2 15177 1 0 1 0 0.0  4.7  296 3.44 114  9933.2 206.40 101 195 10.3 2
 32 4523 0 2 19722 1 0 1 0 0.0  1.8  262 3.34 101  7277.0  82.56 158 286 10.6 4
 33 3170 2 2 18731 1 0 0 0 0.0  0.8  210 3.19  82  1592.0 218.55 113 180 12.0 3
 34 3933 0 1 19015 1 0 0 0 0.0  0.8  364 3.70  37  1840.0 170.50  64 273 10.5 2
 35 2847 2 2 17758 1 0 0 0 0.0  1.2  314 3.20 201 12258.8  72.24 151 431 10.6 3
 36 3611 0 2 20604 1 0 0 0 0.0  0.3  172 3.39  18   558.0  71.30  96 311 10.6 2
 37  223 2 1 22546 1 1 1 0 1.0  7.1  334 3.01 150  6931.2 180.60 118 102 12.0 4
 38 3244 2 2 13378 1 0 1 1 0.0  3.3  383 3.53 102  1234.0 137.95  87 234 11.0 4
 39 2297 2 1 20232 1 0 1 0 0.0  0.7  282 3.00  52  9066.8  72.24 111 563 10.6 4
 40 4467 0 1 17046 1 0 0 0 0.0  1.3    . 3.34 105 11046.6 104.49   . 358 11.0 4
 41 1350 2 1 12285 1 0 1 0 0.0  6.8    . 3.26  96  1215.0 151.90   . 226 11.7 4
 42 4453 0 2 12307 1 0 1 1 0.0  2.1    . 3.54 122  8778.0  56.76   . 344 11.0 4
 43 4556 0 1 17850 1 0 0 0 0.0  1.1  361 3.64  36  5430.2  67.08  89 203 10.6 2
 44 3428 2 2 13727 1 0 1 1 1.0  3.3  299 3.55 131  1029.0 119.35  50 199 11.7 3
 45 4025 0 2 15265 1 0 0 0 0.0  0.6    . 3.93  19  1826.0  71.30   . 474 10.9 2
 46 2256 2 1 16728 1 0 1 0 0.0  5.7  482 2.84 161 11552.0 136.74 165 518 12.7 3
 47 2576 0 2 17323 1 0 0 0 0.0  0.5  316 3.65  68  1716.0 187.55  71 356  9.8 3
 48 4427 0 2 17947 0 0 0 0 0.0  1.9  259 3.70 281 10396.8 188.34 178 214 11.0 3
 49  708 2 2 22336 1 0 1 0 0.0  0.8    . 3.82  58   678.0  97.65   . 233 11.0 4
 50 2598 2 1 19544 1 0 1 0 0.0  1.1  257 3.36  43  1080.0 106.95  73 128 10.6 4
 51 3853 2 2 19025 1 0 0 0 0.0  0.8  276 3.60  54  4332.0  99.33 143 273 10.6 2
 52 2386 2 1 18460 0 0 0 0 0.0  6.0  614 3.70 158  5084.4 206.40  93 362 10.6 1
 53 1000 2 1 24621 1 0 1 0 0.0  2.6    . 3.10  94  6456.2  56.76   . 214 11.0 4
 54 1434 2 1 14317 1 1 1 1 1.0  1.3  288 3.40 262  5487.2  73.53 125 254 11.0 4
 55 1360 2 1 24020 0 0 0 0 0.0  1.8  416 3.94 121 10165.0  79.98 219 213 11.0 3
 56 1847 2 2 12279 1 0 1 1 0.0  1.1  498 3.80  88 13862.4  95.46 319 365 10.6 2
 57 3282 2 1 19567 1 0 1 0 0.5  2.3  260 3.18 231 11320.2 105.78  94 216 12.4 3
 58 4459 0 1 16279 0 0 0 0 0.0  0.7  242 4.08  73  5890.0  56.76 118   . 10.6 1
 59 2224 2 1 14754 1 0 1 1 0.0  0.8  329 3.50  49  7622.8 126.42 124 321 10.6 3
 60 4365 0 1 21324 1 0 0 0 0.0  0.9  604 3.40  82   876.0  71.30  58 228 10.3 3
 61 4256 0 2 16034 0 0 0 0 0.0  0.6  216 3.94  28   601.0  60.45 188 211 13.0 1
 62 3090 2 2 22173 1 1 0 0 0.0  1.3  302 2.75  58  1523.0  43.40 112 329 13.2 4
 63  859 2 2 17031 1 0 0 1 1.0 22.5  932 3.12  95  5396.0 244.90 133 165 11.6 3
 64 1487 2 2 22977 1 0 1 0 0.0  2.1  373 3.50  52  1009.0 150.35 188 178 11.0 3
 65 3992 0 1 14684 1 0 0 0 0.0  1.2  256 3.60  74   724.0 141.05 108 430 10.0 1
 66 4191 2 1 16967 0 0 1 0 0.0  1.4  427 3.70 105  1909.0 182.90 171 123 11.0 3
 67 2769 2 2 18733 1 0 0 0 0.0  1.1  466 3.91  84  1787.0 328.60 185 261 10.0 3
 68 4039 0 1 11912 1 0 0 0 0.0  0.7  174 4.09  58   642.0  71.30  46 203 10.6 3
 69 1170 2 1 18021 1 0 1 1 0.5 20.0  652 3.46 159  3292.0 215.45 184 227 12.4 3
 70 3458 0 1 20600 1 0 0 0 0.0  0.6    . 4.64  20   666.0  54.25   . 265 10.6 2
 71 4196 0 2 17841 1 0 1 0 0.0  1.2  258 3.57  79  2201.0 120.90  76 410 11.5 4
 72 4184 0 2 11868 1 0 0 0 0.0  0.5  320 3.54  51  1243.0 122.45  80 225 10.0 3
 73 4190 0 2 14060 1 0 0 0 0.0  0.7  132 3.60  17   423.0  49.60  56 265 11.0 1
 74 1827 2 1 18964 1 0 1 1 0.0  8.4  558 3.99 280   967.0  89.90 309 278 11.0 4
 75 1191 2 1 15895 1 1 1 1 0.5 17.1  674 2.53 207  2078.0 182.90 598 268 11.5 4
 76   71 2 1 18972 1 0 1 1 0.5 12.2  394 3.08 111  2132.0 155.00 243 165 11.6 4
 77  326 2 2 18199 1 0 1 1 0.5  6.6  244 3.41 199  1819.0 170.50  91 132 12.1 3
 78 1690 2 1 17512 1 0 1 0 0.0  6.3  436 3.02  75  2176.0 170.50 104 236 10.6 4
 79 3707 0 1 16990 1 0 1 0 0.0  0.8  315 4.24  13  1637.0 170.50  70 426 10.9 3
 80  890 2 2 24622 0 0 1 0 0.0  7.2  247 3.72 269  1303.0 176.70  91 360 11.2 4
 81 2540 2 1 23107 1 0 1 1 0.0 14.4  448 3.65  34  1218.0  60.45 318 385 11.7 4
 82 3574 2 1 24585 1 0 0 0 0.0  4.5  472 4.09 154  1580.0 117.80 272 412 11.1 3
 83 4050 0 1 20459 1 0 1 0 0.5  1.3  250 3.50  48  1138.0  71.30 100  81 12.9 4
 84 4032 0 2 20392 1 0 0 0 0.0  0.4  263 3.76  29  1345.0 137.95  74 181 11.2 3
 85 3358 2 2 17246 1 0 1 0 0.0  2.1  262 3.48  58  2045.0  89.90  84 225 11.5 4
 86 1657 2 1 19270 1 0 1 1 0.0  5.0 1600 3.21  75  2656.0  82.15 174 181 10.9 3
 87  198 2 1 13616 1 0 0 0 0.0  1.1  345 4.40  75  1860.0 218.55  72 447 10.7 3
 88 2452 0 2 15119 1 0 0 0 0.5  0.6  296 4.06  37  1032.0  80.60  83 442 12.0 3
 89 1741 2 1 19155 1 0 1 0 0.0  2.0  408 3.65  50  1083.0 110.05  98 200 11.4 2
 90 2689 2 1 12227 0 0 0 0 0.0  1.6  660 4.22  94  1857.0 151.90 155 337 11.0 2
 91  460 2 2 16658 1 0 1 1 0.5  5.0  325 3.47 110  2460.0 246.45  56 430 11.9 4
 92  388 2 1 28018 1 1 0 0 1.0  1.4  206 3.13  36  1626.0  86.80  70 145 12.2 4
 93 3913 0 1 13344 1 0 0 0 0.0  1.3  353 3.67  73  2039.0 232.50  68 380 11.1 2
 94  750 2 1 19693 1 0 1 1 0.0  3.2  201 3.11 178  1212.0 159.65  69 188 11.8 4
 95  130 2 2 16944 1 1 1 1 1.0 17.4    . 2.64 182   559.0 119.35   . 401 11.7 2
 96 3850 0 1 17841 1 0 0 0 0.0  1.0    . 3.70  33  1258.0  99.20   . 338 10.4 3
 97  611 2 2 26259 0 0 1 0 0.5  2.0  420 3.26  62  3196.0  77.50  91 344 11.4 3
 98 3823 0 1 10550 1 0 0 0 0.0  1.0  239 3.77  77  1877.0  97.65 101 312 10.2 1
 99 3820 0 2 17703 0 0 0 0 0.0  1.8  460 3.35 148  1472.0 108.50 118 172 10.2 2
100  552 2 2 18799 0 0 1 0 0.0  2.3  178 3.00 145   746.0 178.25 122 119 12.0 4
101 3581 0 2 16418 1 0 0 0 0.0  0.9  400 3.60  31  1689.0 164.30 166 327 10.4 3
102 3099 0 1 20662 1 0 0 0 0.0  0.9  248 3.97 172   646.0  62.00  84 128 10.1 1
103  110 2 2 17884 1 1 1 1 1.0  2.5  188 3.67  57  1273.0 119.35 102 110 11.1 4
104 3086 2 1 15712 1 0 0 0 0.0  1.1  303 3.64  20  2108.0 128.65  53 349 11.1 2
105 3092 1 2 12433 1 0 1 0 0.0  1.1  464 4.20  38  1644.0 151.90 102 348 10.3 3
106 3222 2 1 25023 1 1 1 0 0.0  2.1    . 3.90  50  1087.0 103.85   . 137 10.6 2
107 3388 0 2 22836 1 0 0 0 0.0  0.6  212 4.03  10   648.0  71.30  77 316 17.1 1
108 2583 2 1 18393 1 0 0 0 0.0  0.4  127 3.50  14  1062.0  49.60  84 334 10.3 2
109 2504 0 2 16094 1 0 0 0 0.0  0.5  120 3.61  53   804.0 110.05  52 271 10.6 3
110 2105 2 1 14212 1 0 1 1 0.0  1.9  486 3.54  74  1052.0 108.50 109 141 10.9 3
111 2350 1 1 15031 1 0 0 0 0.0  5.5  528 4.18  77  2404.0 172.05  78 467 10.7 3
112 3445 2 2 20256 1 0 1 1 0.0  2.0  267 3.67  89   754.0 196.85  90 136 11.8 4
113  980 2 1 18713 1 0 1 1 0.0  6.7  374 3.74 103   979.0 128.65 100 266 11.1 4
114 3395 2 2 19295 0 0 0 0 0.0  3.2  259 4.30 208  1040.0 110.05  78 268 11.7 3
115 3422 0 2 15574 1 0 0 1 0.0  0.7  303 4.19  81  1584.0 111.60 156 307 10.3 3
116 3336 0 1 22306 1 0 0 1 0.5  3.0  458 3.63  74  1588.0 106.95 382 438  9.9 3
117 1083 2 1 18137 1 0 1 1 0.0  6.5  950 3.11 111  2374.0 170.50 149 354 11.0 4
118 2288 2 1 17844 1 0 1 0 0.0  3.5  390 3.30  67   878.0 137.95  93 207 10.2 3
119  515 2 1 19817 1 0 0 1 0.0  0.6  636 3.83 129   944.0  97.65 114 306  9.5 3
120 2033 1 1 12839 0 0 0 0 0.0  3.5  325 3.98 444   766.0 130.20 210 344 10.6 3
121  191 2 2 24803 0 1 1 0 1.0  1.3  151 3.08  73  1112.0  46.50  49 213 13.2 4
122 3297 0 1 20248 1 0 0 0 0.0  0.6  298 4.13  29   758.0  65.10  85 256 10.7 3
123  971 2 1 16736 1 0 1 1 1.0  5.1    . 3.23  18   790.0 179.80   . 104 13.0 4
124 3069 0 1 19318 0 0 1 0 0.0  0.6  251 3.90  25   681.0  57.35 107 182 10.8 4
125 2468 1 2 17233 1 0 1 0 0.0  1.3  316 3.51  75  1162.0 147.25 137 238 10.0 4
126  824 2 1 19577 1 1 1 1 0.0  1.2  269 3.12   .  1441.0 165.85  68 166 11.1 4
127 3255 0 2 16109 1 0 0 0 0.0  0.5  268 4.08   9  1174.0  86.80  95 453 10.0 2
128 1037 2 1 15322 1 0 1 1 0.0 16.2    . 2.89  42  1828.0 299.15   . 123 12.6 4
129 3239 0 1 23235 1 0 1 0 0.0  0.9  420 3.87  30  1009.0  57.35 232   .  9.7 3
130 1413 2 2 16154 1 0 1 1 0.0 17.4 1775 3.43 205  2065.0 165.85  97 418 11.5 3
131  850 2 2 22646 1 0 1 1 0.0  2.8  242 3.80  74   614.0 136.40 104 121 13.2 4
132 2944 0 1 14812 1 0 0 0 0.0  1.9  448 3.83  60  1052.0 127.10 175 181  9.8 3
133 2796 2 2 22881 0 0 0 0 0.0  1.5  331 3.95  13   577.0 128.65  99 165 10.1 4
134 3149 0 2 15463 1 0 0 0 0.0  0.7  578 3.67  35  1353.0 127.10 105 427 10.7 2
135 3150 0 1 15694 1 0 0 0 0.0  0.4  263 3.57 123   836.0  74.40 121 445 11.0 2
136 3098 0 1 20440 1 0 0 0 0.0  0.8  263 3.35  27  1636.0 116.25  69 206  9.8 2
137 2990 0 1 22960 1 0 0 0 0.0  1.1  399 3.60  79  3472.0 155.00 152 344 10.1 2
138 1297 2 1 18719 0 0 1 0 0.0  7.3  426 3.93 262  2424.0 145.70 218 252 10.5 3
139 2106 0 2 17080 1 0 1 0 0.0  1.1  328 3.31 159  1260.0  94.55 134 142 11.6 4
140 3059 0 1 19751 1 0 1 0 0.0  1.1  290 4.09  38  2120.0 186.00 146 318 10.0 3
141 3050 0 1 17180 1 0 0 0 0.0  0.9  346 3.77  59   794.0 125.55  56 336 10.6 2
142 2419 2 2 20354 1 0 1 0 0.0  1.0  364 3.48  20   720.0 134.85  88 283  9.9 2
143  786 2 2 16839 1 0 1 0 0.0  2.9  332 3.60  86  1492.0 134.85 103 277 11.0 4
144  943 2 2 19098 1 0 1 0 0.5 28.0  556 3.26 152  3896.0 198.40 171 335 10.0 3
145 2976 0 2 18701 1 0 0 1 0.0  0.7  309 3.84  96   858.0  41.85 106 253 11.4 3
146 2615 0 2 12369 1 0 0 0 0.5  1.2    . 3.89  58  1284.0 173.60   . 239  9.4 3
147 2995 0 1 27398 1 0 0 0 0.5  1.2  288 3.37  32   791.0  57.35 114 213 10.7 2
148 1427 2 2 11273 1 0 1 0 0.0  7.2 1015 3.26 247  3836.0 198.40 280 330  9.8 3
149  762 2 1 22574 0 0 1 1 0.5  3.0  257 3.79 290  1664.0 102.30 112 140  9.9 4
150 2891 0 2 12779 1 0 0 1 0.0  1.0    . 3.63  57  1536.0 134.85   . 233 10.0 1
151 2870 0 1 20104 1 0 0 0 0.0  0.9  460 3.03  57   721.0  85.25 174 301  9.4 2
152 1152 2 1 25546 0 0 1 0 0.0  2.3  586 3.01 243  2276.0 114.70 126 339 10.9 3
153 2863 0 1 18118 1 0 0 0 0.0  0.5  217 3.85  68   453.0  54.25  68 270 11.1 1
154  140 2 1 25340 0 0 0 1 1.0  2.4  168 2.56 225  1056.0 120.90  75 108 14.1 3
155 2666 0 2 15909 1 0 1 1 0.5  0.6  220 3.35  57  1620.0 153.45  80 311 11.2 4
156  853 2 2 21699 1 0 1 0 0.0 25.5  358 3.52 219  2468.0 201.50 205 151 11.5 2
157 2835 0 2 17809 1 0 0 0 0.0  0.6  286 3.42  34  1868.0  77.50 206 487 10.0 2
158 2475 1 1 13329 1 0 0 0 0.0  3.4  450 3.37  32  1408.0 116.25 118 313 11.2 2
159 1536 2 2 16714 0 0 0 0 0.0  2.5  317 3.46 217   714.0 130.20 140 207 10.1 3
160 2772 0 2 20955 1 0 0 0 0.0  0.6  217 3.62  13   414.0  75.95 119 224 10.5 3
161 2797 0 2 15612 1 0 0 0 0.0  2.3  502 3.56   4   964.0 120.90 180 269  9.6 2
162  186 2 2 21483 1 0 1 1 0.0  3.2  260 3.19  91   815.0 127.10 101 160 12.0 4
163 2055 2 1 19540 1 0 0 0 0.0  0.3  233 4.08  20   622.0  66.65  68 358  9.9 3
164  264 2 2 15857 1 0 1 1 0.5  8.5    . 3.34 161  1428.0 181.35   .  88 13.3 4
165 1077 2 1 19470 0 0 1 0 0.0  4.0  196 3.45  80  2496.0 133.30 142 212 11.3 4
166 2721 0 2 15105 1 0 1 0 0.0  5.7 1480 3.26  84  1960.0 457.25 108 213  9.5 2
167 1682 2 1 22265 0 0 1 0 0.0  0.9  376 3.86 200  1015.0  83.70 154 238 10.3 4
168 2713 0 2 17442 1 0 1 0 0.0  0.4  257 3.80  44   842.0  97.65 110   .  9.2 2
169 1212 2 2 12963 1 0 0 0 0.0  1.3  408 4.22  67  1387.0 142.60 137 295 10.1 3
170 2692 0 1 17774 1 0 0 0 0.0  1.2  390 3.61  32  1509.0  88.35  52 263  9.0 3
171 2574 0 1 19237 1 0 0 0 0.0  0.5    . 4.52  31   784.0  74.40   . 361 10.1 3
172 2301 0 2 18215 1 0 0 1 0.0  1.3  205 3.34  65  1031.0  91.45 126 217  9.8 3
173 2657 0 1 11058 1 0 1 1 0.0  3.0  236 3.42  76  1403.0  89.90  86 493  9.8 2
174 2644 0 1 20296 1 0 0 0 0.0  0.5    . 3.85  63   663.0  79.05   . 311  9.7 1
175 2624 0 2 19049 1 0 0 0 0.0  0.8  283 3.80 152   718.0 108.50 168 340 10.1 3
176 1492 2 1 15198 1 0 1 1 0.0  3.2    . 3.56  77  1790.0 139.50   . 149 10.1 4
177 2609 0 2 20254 1 0 0 0 0.0  0.9  258 4.01  49   559.0  43.40 133 277 10.4 2
178 2580 0 1 25569 1 0 0 0 0.0  0.6    . 4.08  51   665.0  74.40   . 325 10.2 4
179 2573 0 2 16050 1 0 1 0 0.0  1.8  396 3.83  39  2148.0 102.30 133 278  9.9 4
180 2563 0 2 15548 1 0 0 0 0.0  4.7  478 4.38  44  1629.0 237.15  76 175 10.4 3
181 2556 0 1 16279 1 0 1 1 0.0  1.4  248 3.58  63   554.0  75.95 106  79 10.3 4
182 2555 0 1 20799 1 0 1 0 0.0  0.6    . 3.69 161   674.0  26.35   . 539  9.9 2
183 2241 1 2 14705 1 0 0 0 0.0  0.5  201 3.73  44  1345.0  54.25 145 445 10.1 2
184  974 2 2 13736 1 0 1 0 0.0 11.0  674 3.55 358  2412.0 167.40 140 471  9.8 3
185 2527 0 1 17664 1 0 0 0 0.0  0.8  256 3.54  42  1132.0  74.40  94 192 10.5 3
186 1576 2 1 25873 1 0 0 1 0.5  2.0  225 3.53  51   933.0  69.75  62 200 12.7 3
187  733 2 2 13073 1 0 1 0 0.0 14.0  808 3.43 251  2870.0 153.45 137 268 11.5 3
188 2332 0 1 22873 1 0 1 0 0.0  0.7  187 3.48  41   654.0 120.90  98 164 11.0 4
189 2456 0 2 18499 1 0 1 0 0.0  1.3  360 3.63  52  1812.0  97.65 164 256  9.9 3
190 2504 0 1 19916 1 0 0 1 0.0  2.3    . 3.93  24  1828.0 133.30   . 327 10.2 2
191  216 2 2 19246 1 1 1 1 0.0 24.5 1092 3.35 233  3740.0 147.25 432 399 15.2 4
192 2443 0 1 19256 1 0 1 0 0.0  0.9  308 3.69  67   696.0  51.15 101 344  9.8 4
193  797 2 2 20736 1 0 0 0 0.0 10.8  932 3.19 267  2184.0 161.20 157 382 10.4 4
194 2449 0 1 16216 1 0 0 0 0.0  1.5  293 4.30  50   975.0 125.55  56 336  9.1 2
195 2330 0 1 10795 1 0 1 0 0.0  3.7  347 3.90  76  2544.0 221.65  90 129 11.5 4
196 2363 0 1 20834 1 0 1 1 0.0  1.4  226 3.36  13   810.0  72.85  62 117 11.6 4
197 2365 0 1 16300 1 0 0 0 0.0  0.6  266 3.97  25  1164.0 102.30 102 201 10.1 2
198 2357 0 2 13075 1 0 0 1 0.0  0.7  286 2.90  38  1692.0 141.05  90 381  9.6 2
199 1592 0 1 14872 1 0 0 0 0.0  2.1  392 3.43  52  1395.0 184.45 194 328 10.2 3
200 2318 0 2 11773 1 0 0 1 0.0  4.7  236 3.55 112  1391.0 137.95 114 332  9.9 3
201 2294 0 2 15009 1 0 1 0 0.0  0.6  235 3.20  26  1758.0 106.95  67 228 10.8 4
202 2272 0 1 22514 1 0 0 0 0.0  0.5  223 3.80  15  1044.0  80.60  89 514 10.0 2
203 2221 0 2 13535 1 0 1 0 0.0  0.5  149 4.04 227   598.0  52.70  57 166  9.9 2
204 2090 2 2 22857 1 0 0 0 0.0  0.7  255 3.74  23  1024.0  77.50  58 281 10.2 3
205 2081 2 1 17889 1 1 0 0 0.0  2.5  382 3.55 108  1516.0 238.70   . 126 10.3 3
206 2255 0 1 22642 1 0 0 0 0.0  0.6  213 4.07  12  5300.0  57.35  68 240 11.0 1
207 2171 0 1 26580 1 0 0 0 0.5  0.6    . 3.33  14   733.0  85.25   . 259 10.1 4
208  904 2 1 22388 1 0 1 0 0.0  3.9  396 3.20  58  1440.0 153.45 131 156 10.0 4
209 2216 0 2 19221 1 0 1 1 0.0  0.7  252 4.01  11  1210.0  72.85  58 309  9.5 2
210 2224 0 2 18176 0 0 1 0 0.0  0.9  346 3.37  81  1098.0 122.45  90 298 10.0 2
211 2195 0 2 19327 1 0 0 0 0.0  1.3    . 3.76  27  1282.0 100.75   . 114 10.3 3
212 2176 0 2 17263 1 0 0 0 0.0  1.2  232 3.98  11  1074.0 100.75  99 223  9.9 3
213 2178 0 1 18337 1 0 0 1 0.0  0.5  400 3.40   9  1134.0  96.10  55 356 10.2 3
214 1786 2 2 25329 1 0 1 0 0.0  0.9  404 3.43  34  1866.0  79.05 224 236  9.9 3
215 1080 2 2 15037 1 0 0 0 0.0  5.9 1276 3.85 141  1204.0 203.05 157 216 10.7 3
216 2168 0 1 21610 1 0 0 0 0.0  0.5    . 3.68  20   856.0  55.80   . 146 10.4 3
217  790 2 2 13178 1 0 1 0 0.0 11.4  608 3.31  65  1790.0 151.90 210 298 10.8 4
218 2170 0 1 12636 1 0 0 0 0.0  0.5    . 3.89  29   897.0  66.65   . 423 10.1 1
219 2157 0 2 15601 1 0 0 0 0.0  1.6  215 4.17  67   936.0 134.85  85 176  9.6 3
220 1235 2 1 23241 1 0 0 1 0.0  3.8  426 3.22  96  2716.0 210.80 113 228 10.6 2
221 2050 0 2 20684 1 0 1 0 0.0  0.9  360 3.65  72  3186.0  94.55 154 269  9.7 4
222  597 2 2 16898 1 0 1 0 0.0  4.5  372 3.38 227  2310.0 167.40 135 240 12.4 3
223  334 2 1 22369 1 1 1 0 1.0 14.1  448 2.43 123  1833.0 134.00 155 210 11.0 4
224 1945 0 1 14106 1 0 0 0 0.0  1.0  309 3.66  67  1214.0 158.10 101 309  9.7 3
225 2022 0 1 14161 1 0 0 0 0.0  0.7  274 3.66 108  1065.0  88.35 135 251 10.1 2
226 1978 0 2 20708 1 0 1 0 0.0  0.5  223 3.70  39   884.0  75.95 104 231  9.6 3
227  999 2 1 21532 0 0 0 0 0.0  2.3  316 3.35 172  1601.0 179.80  63 394  9.7 2
228 1967 0 2 13486 1 0 0 0 0.0  0.7  215 3.35  41   645.0  93.00  74 165  9.6 3
229  348 2 1 22797 1 1 1 0 0.5  4.5  191 3.05 200  1020.0 175.15 118 139 11.4 4
230 1979 0 2 12641 1 0 1 1 0.0  3.3  302 3.41  51   310.0  83.70  44  95 11.5 4
231 1165 2 2 21307 1 0 1 1 0.0  3.4  518 1.96 115  2250.0 203.05  90 190 10.7 4
232 1951 0 1 18329 1 0 1 0 0.0  0.4  267 3.02  47  1001.0 133.30  87 265 10.6 3
233 1932 0 1 15591 1 0 1 1 0.0  0.9  514 3.06 412  2622.0 105.40  87 284  9.8 4
234 1776 0 2 12557 1 0 0 0 0.0  0.9  578 3.35  78   976.0 116.25 177 322 11.2 2
235 1882 0 2 12120 1 0 1 0 0.0 13.0 1336 4.16  71  3510.0 209.25 111 338 11.9 3
236 1908 0 1 14019 1 0 1 1 0.0  1.5  253 3.79  67  1006.0 139.50 106 341  9.7 3
237 1882 0 1 21828 1 0 1 0 0.0  1.6  442 2.95 105   820.0  85.25 108 181 10.1 3
238 1874 0 2 24257 1 0 0 0 0.5  0.6  280 3.35   .  1093.0 128.65  81 295  9.8 2
239  694 2 1 17090 1 0 1 1 0.0  0.8  300 2.94 231  1794.0 130.20  99 319 11.2 4
240 1831 0 1 20483 1 0 0 0 0.0  0.4  232 3.72  24   369.0  51.15 139 326 10.1 3
241  837 1 2 15112 1 0 1 1 0.0  4.4  316 3.62 308  1119.0 114.70 322 282  9.8 4
242 1810 0 1 23585 1 0 1 0 0.0  1.9  354 2.97  86  1553.0 196.85 152 277  9.9 3
243  930 2 2 24650 1 0 1 0 0.0  8.0  468 2.81 139  2009.0 198.40 139 233 10.0 4
244 1690 2 1 16374 1 0 0 1 0.0  3.9  350 3.22 121  1268.0 272.80 231 270  9.6 3
245 1790 0 2 16718 1 0 1 0 0.0  0.6  273 3.65  48   794.0  52.70 214 305  9.6 3
246 1435 1 1 12035 1 0 1 0 0.0  2.1  387 3.77  63  1613.0 150.35  33 185 10.1 4
247  732 1 1 15056 1 0 1 0 0.0  6.1 1712 2.83  89  3681.0 158.10 139 297 10.0 3
248 1785 0 2 20241 1 0 1 0 0.0  0.8  324 3.51  39  1237.0  66.65 146 371 10.0 3
249 1783 0 1 17525 1 0 0 1 0.0  1.3  242 3.20  35  1556.0 175.15  71 195 10.6 4
250 1769 0 2 14899 1 0 1 0 0.0  0.6  299 3.36  23  2769.0 220.10  85 303 10.9 4
251 1457 0 1 20810 1 0 0 0 0.0  0.5  227 3.61  40   676.0  83.00 120 249  9.9 2
252 1770 0 1 25006 1 0 1 1 0.0  1.1  246 3.35 116   924.0 113.15  90 317 10.0 4
253 1765 0 1 28650 0 1 1 1 0.0  7.1  243 3.03 380   983.0 158.10 154  97 11.2 4
254  737 1 1 14558 1 0 1 1 0.0  3.1  227 3.75 121  1136.0 110.00  91 264 10.0 3
255 1735 0 2 12897 1 0 1 1 0.0  0.7  193 3.85  35   466.0  53.00 118 156 10.3 3
256 1701 0 1 11485 1 0 0 0 0.0  1.1  336 3.74  48   823.0  84.00 108 242  9.7 3
257 1614 0 1 21281 1 0 0 0 0.0  0.5  280 4.23  36   377.0  56.00 146 227 10.6 2
258 1702 0 1 18806 1 0 0 0 0.0  1.1  414 3.44  80  1003.0  99.00  55 271  9.6 1
259 1615 0 2 21904 1 0 1 0 0.0  3.1  277 2.97  42  1110.0 125.00 126 221  9.8 3
260 1656 0 2 27220 0 0 1 0 0.0  5.6  232 3.59 188  1120.0  98.00 128 248 10.9 4
261 1677 0 2 19126 1 0 1 1 0.0  3.2  375 3.14 129   857.0  89.00   . 375  9.5 3
262 1666 0 2 15628 1 0 1 0 0.0  2.8  322 3.06  65  2562.0  91.00 209 231  9.5 3
263 1301 1 2 12738 1 0 1 1 0.5  1.1  432 3.57  45  1406.0 190.00  77 248 11.4 4
264 1542 1 2 16122 1 0 1 1 0.0  3.4  356 3.12 188  1911.0  92.00 130 318 11.2 3
265 1084 1 2 16941 1 0 1 0 0.0  3.5  348 3.20 121   938.0 120.00 146 296 10.0 4
266 1614 0 1 20567 1 0 0 0 0.0  0.5  318 3.32  52   613.0  70.00 260 279 10.2 3
267  179 2 1 25899 1 1 1 1 1.0  6.6  222 2.33 138   620.0 106.00  91 195 12.1 4
268 1191 2 1 20233 1 1 1 0 0.5  6.4  344 2.75  16   834.0  82.00 179 149 11.0 4
269 1363 0 2 16467 1 0 0 0 0.0  3.6  374 3.50 143  1428.0 188.00  44 151 10.1 2
270 1568 0 1  9598 1 0 1 1 0.0  1.0  448 3.74 102  1128.0  71.00 117 228 10.2 3
271 1569 0 2 18435 1 0 1 0 0.0  1.0  321 3.50  94   955.0 111.00 177 289  9.7 3
272 1525 0 1 14025 1 0 0 0 0.0  0.5  226 2.93  22   674.0  58.00  85 153  9.8 1
273 1558 0 2 17320 1 0 0 1 0.0  2.2  328 3.46  75  1677.0  87.00 116 202  9.6 3
274 1447 1 1 17525 1 0 0 0 0.0  1.6    . 3.07 136  1995.0 128.00   . 372  9.6 4
275 1349 0 1 13995 1 0 0 0 0.0  2.2  572 3.77  77  2520.0  92.00 114 309  9.5 4
276 1481 0 1 18302 1 0 0 0 0.0  1.0  219 3.85  67   640.0 145.00 108  95 10.7 2
277 1434 0 2 12816 1 0 0 0 0.5  1.0  317 3.56  44  1636.0  84.00 111 394  9.8 3
278 1420 0 2 11872 1 0 0 0 0.0  5.6  338 3.70 130  2139.0 185.00 193 215  9.9 4
279 1433 0 2 20510 1 0 0 0 0.0  0.5  198 3.77  38   911.0  57.00  56 280  9.8 2
280 1412 0 1 16858 1 0 0 0 0.0  1.6  325 3.69  69  2583.0 142.00 140 284  9.6 3
281   41 2 1 24064 1 1 0 0 1.0 17.9  175 2.10 220   705.0 338.00 229  62 12.9 4
282 1455 0 2 12398 1 0 1 0 0.0  1.3  304 3.52  97  1622.0  71.00 169 255  9.5 4
283 1030 0 2 22960 1 0 0 0 0.0  1.1  412 3.99 103  1293.0  91.00 113 422  9.6 4
284 1418 0 2 17738 1 0 0 0 0.0  1.3  291 3.44  75  1082.0  85.00 195 251  9.5 3
285 1401 0 1 16929 1 0 0 0 0.0  0.8  253 3.48  65   688.0  57.00  80 252 10.0 1
286 1408 0 1 14191 1 0 1 1 0.0  2.0  310 3.36  70  1257.0 122.00 118 143  9.8 3
287 1234 0 1 21421 1 0 0 1 0.0  6.4  373 3.46 155  1768.0 120.00 151 258 10.1 4
288 1067 1 2 17874 1 0 1 0 0.5  8.7  310 3.89 107   637.0 117.00 242 298  9.6 2
289  799 2 1 24681 0 0 1 0 0.5  4.0  416 3.99 177   960.0  86.00 242 269  9.8 2
290 1363 0 1 24101 1 0 0 0 0.0  1.4  294 3.57  33   722.0  93.00  69 283  9.8 3
291  901 1 1 14939 1 0 0 0 0.0  3.2  339 3.18 123  3336.0 205.00  84 304  9.9 4
292 1329 0 2 18352 0 0 1 0 0.0  8.6  546 3.73  84  1070.0 127.00 153 291 11.2 3
293 1320 0 2 20891 1 0 1 1 1.0  8.5  194 2.98 196   815.0 163.00  78 122 12.3 4
294 1302 0 1 22111 0 0 1 0 0.0  6.6 1000 3.07  88  3150.0 193.00 133 299 10.9 4
295  877 1 1 12912 0 0 0 0 0.0  2.4  646 3.83 102   855.0 127.00 194 306 10.3 3
296 1321 0 2 11462 1 0 0 0 0.0  0.8  328 3.31  62  1105.0 137.00  95 293 10.9 4
297  533 1 1 20449 0 0 1 0 0.0  1.2  275 3.43 100  1142.0  75.00  91 217 11.3 4
298 1300 0 2 19258 1 0 1 0 0.0  1.1  340 3.37  73   289.0  97.00  93 243 10.2 3
299 1293 0 1 13913 1 0 0 0 0.0  2.4  342 3.76  90  1653.0 150.00 127 213 10.8 3
300  207 2 2 21247 1 0 1 0 0.0  5.2    . 2.23 234   601.0 135.00   . 206 12.3 4
301 1295 0 2 16513 1 0 0 0 0.0  1.0  393 3.57  50  1307.0  74.00 103 295 10.5 4
302 1271 0 1 13806 1 0 0 0 0.0  0.7  335 3.95  43   657.0  52.00 104 268 10.6 2
303 1250 0 2 22156 1 0 1 1 0.0  1.0  372 3.25 108  1190.0 140.00  55 248 10.6 4
304 1230 0 1 12979 1 0 0 0 0.0  0.5  219 3.93  22   663.0  45.00  75 246 10.8 3
305 1216 0 2 15730 1 0 1 1 0.0  2.9  426 3.61  73  5184.0 288.00 144 275 10.6 3
306 1216 0 2 20597 1 0 1 0 0.0  0.6  239 3.45  31  1072.0  55.00  64 227 10.7 2
307 1149 0 2 11167 1 0 0 0 0.0  0.8  273 3.56  52  1282.0 130.00  59 344 10.5 2
308 1153 0 1 22347 1 0 1 0 0.0  0.4  246 3.58  24   797.0  91.00 113 288 10.4 2
309  994 0 2 21294 1 0 0 0 0.0  0.4  260 2.75  41  1166.0  70.00  82 231 10.8 2
310  939 0 1 22767 1 0 0 0 0.0  1.7  434 3.35  39  1713.0 171.00 100 234 10.2 2
311  839 0 1 13879 1 0 0 0 0.0  2.0  247 3.16  69  1050.0 117.00  88 335 10.5 2
312  788 0 2 12109 1 0 0 1 0.0  6.4  576 3.79 186  2115.0 136.00 149 200 10.8 2
313 4062 0 . 21915 1 . . . 0.0  0.7    . 3.65   .      .     .     . 378 11.0 .
314 3561 2 . 23741 1 . . . 0.5  1.4    . 3.04   .      .     .     . 331 12.1 4
315 2844 0 . 19724 1 . . . 0.0  0.7    . 4.03   .      .     .     . 226  9.8 4
316 2071 2 . 27394 1 . . . 0.5  0.7    . 3.96   .      .     .     .   . 11.3 4
317 3030 0 . 22646 1 . . . 0.0  0.8    . 2.48   .      .     .     . 273 10.0 .
318 1680 0 . 15706 1 . . . 0.0  0.7    . 3.68   .      .     .     . 306  9.5 2

推荐答案

任何以."开头的列.过滤操作之前,将保留在从文本文件读取时所具有的字符或因子类中.您需要在简化的数据集上运行它:

Any column that started out with a "." before a filter operation will remain in the character or factor class that it had at the time of the read from text file. You need to run this on the reduced dataset:

surv.df[] <- lapply( surv.df, function(x) as.numeric(as.character(x)))

它将任何因子或字符分类的列转换为数字类.您可以在 read 操作中指定 na.strings =" .." 参数以避免对字符进行隐式和静默强制,或者可以指定 colClasses =数字" .

It converts any factor or character classed column to numeric class. You could have specified the na.strings="." parameter in the read operation to have avoid the implicit and silent coercion to character, or you could have specified colClasses="numeric".

这是经过测试的代码:

names(surv.df)[ 2:3] <- c("times", "state") # better to stay in df

surv.cox = coxph(Surv(times, state == 1) ~ V4 + V5 + V6 + V7 + V8 + V9 + V10 + V11 + V12 + V13 + V14 + V15 + V16 + V17 + V18 + V19 + V20, data = surv.df)

#------------------------------------------


surv.cox
Call:
coxph(formula = Surv(time, state == 1) ~ V4 + V5 + V6 + V7 +
    V8 + V9 + V10 + V11 + V12 + V13 + V14 + V15 + V16 + V17 +
    V18 + V19 + V20, data = surv.df)

          coef  exp(coef)   se(coef)      z        p
V4  -5.421e-01  5.815e-01  5.616e-01 -0.965 0.334359
V5  -3.486e-04  9.997e-01  9.199e-05 -3.790 0.000151
V6  -1.151e+00  3.162e-01  9.316e-01 -1.236 0.216510
V7  -1.918e+01  4.658e-09  5.592e+03 -0.003 0.997263
V8   9.737e-01  2.648e+00  6.580e-01  1.480 0.138930
V9  -8.052e-01  4.470e-01  6.920e-01 -1.164 0.244590
V10  1.596e+00  4.935e+00  1.470e+00  1.086 0.277434
V11  5.874e-02  1.061e+00  1.027e-01  0.572 0.567217
V12  1.202e-03  1.001e+00  1.290e-03  0.931 0.351631
V13 -1.289e+00  2.757e-01  9.781e-01 -1.317 0.187686
V14  1.310e-03  1.001e+00  2.874e-03  0.456 0.648608
V15 -7.055e-04  9.993e-01  4.298e-04 -1.641 0.100732
V16  6.424e-06  1.000e+00  5.255e-03  0.001 0.999025
V17  4.114e-03  1.004e+00  4.627e-03  0.889 0.373941
V18  5.841e-03  1.006e+00  3.255e-03  1.795 0.072718
V19 -4.326e-01  6.488e-01  4.629e-01 -0.935 0.350031
V20  1.125e+00  3.081e+00  4.656e-01  2.416 0.015672

Likelihood ratio test=39.63  on 17 df, p=0.001458
n= 276, number of events= 18
   (42 observations deleted due to missingness)

可能其中某些列确实应该转换为因数.这可以在读取文件时使用更复杂的 colClasses 规范来完成,也可以在以后使用

It's possible that some of those columns really should be converted to factors. That could be done with a more complex colClasses specification at the time of reading from file or it can be done afterwards with

fac_vector <- # a character vector with names of columns to be coerced
surv.df[ fac_vector ] <- lapply (surv.df[fac_vector], factor)

我还注意到,您的状态"向量至少具有3个级别,因此这可能意味着您需要做进一步的工作来定义事件标记实际记录的有关现实的东西.

I also note that your "state" vector has at least 3 levels, so that might mean you need to do further work defining what the event marker really is recording about reality.

这篇关于删除缺失的数据值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:05