library(tidyverse)
Registered S3 method overwritten by 'dplyr':
method from
print.rowwise_df
[30m── [1mAttaching packages[22m ─── tidyverse 1.2.1 ──[39m
[30m[32m✔[30m [34mggplot2[30m 3.2.1 [32m✔[30m [34mpurrr [30m 0.3.2
[32m✔[30m [34mtibble [30m 2.1.3 [32m✔[30m [34mdplyr [30m 0.8.3
[32m✔[30m [34mtidyr [30m 1.0.0 [32m✔[30m [34mstringr[30m 1.4.0
[32m✔[30m [34mreadr [30m 1.3.1 [32m✔[30m [34mforcats[30m 0.4.0[39m
[30m── [1mConflicts[22m ────── tidyverse_conflicts() ──
[31m✖[30m [34mdplyr[30m::[32mfilter()[30m masks [34mstats[30m::filter()
[31m✖[30m [34mdplyr[30m::[32mlag()[30m masks [34mstats[30m::lag()[39m
library(tableone) #create 'Table 1' to describe baseline characteristics
library(Matching) #multivariate and propensity score matching with balance optimization
Le chargement a nécessité le package : MASS
Attachement du package : ‘MASS’
The following object is masked from ‘package:dplyr’:
select
##
## Matching (Version 4.9-6, Build Date: 2019-04-07)
## See http://sekhon.berkeley.edu/matching for additional documentation.
## Please cite software as:
## Jasjeet S. Sekhon. 2011. ``Multivariate and Propensity Score Matching
## Software with Automated Balance Optimization: The Matching package for R.''
## Journal of Statistical Software, 42(7): 1-52.
##
Une description complète est disponible à cette adresse http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/rhc.html. Il s’agit de données sur des patients (2184 traités et 3551 contrôles) admis aux urgences dans 5 hôpitaux, la variable de traitement est swang1
(right heat catheterization vs. non) et l’outcome est death
(yes or no). Nous allons considérer les variables de confusion suivantes : - cat1
: Primary disease category - age
- sex`` -
meanbp1`: Mean blood pressure
rhc = read_csv("./Data/rhc_data.csv")
tableone
ne supporte pas les variables discrètes à plusieurs facteurs, il faut donc d’abord construire la table disjonctive.rhc_small_disjunctive = as_tibble(model.matrix(~ . , data=rhc_small)[,-1])
glimpse(rhc_small_disjunctive)
Observations: 5,735
Variables: 13
$ treatmentRHC [3m[38;5;246m<dbl>[39m[23m 0, 1, 1, 0, 1…
$ deathYes [3m[38;5;246m<dbl>[39m[23m 0, 1, 0, 1, 1…
$ cat1CHF [3m[38;5;246m<dbl>[39m[23m 0, 0, 0, 0, 0…
$ cat1Cirrhosis [3m[38;5;246m<dbl>[39m[23m 0, 0, 0, 0, 0…
$ `cat1Colon Cancer` [3m[38;5;246m<dbl>[39m[23m 0, 0, 0, 0, 0…
$ cat1Coma [3m[38;5;246m<dbl>[39m[23m 0, 0, 0, 0, 0…
$ cat1COPD [3m[38;5;246m<dbl>[39m[23m 1, 0, 0, 0, 0…
$ `cat1Lung Cancer` [3m[38;5;246m<dbl>[39m[23m 0, 0, 0, 0, 0…
$ `cat1MOSF w/Malignancy` [3m[38;5;246m<dbl>[39m[23m 0, 0, 1, 0, 0…
$ `cat1MOSF w/Sepsis` [3m[38;5;246m<dbl>[39m[23m 0, 1, 0, 0, 1…
$ age [3m[38;5;246m<dbl>[39m[23m 70.25098, 78.…
$ sexMale [3m[38;5;246m<dbl>[39m[23m 1, 0, 0, 0, 1…
$ meanbp1 [3m[38;5;246m<dbl>[39m[23m 41, 63, 57, 5…
names(rhc_small_disjunctive) = c("treatment","Death","CHF","Cirr",
"colcan","Coma","COPD",
"lungcan","MOSF","sepsis",
"age","male","meanbp1")
xvars = c("CHF","Cirr","colcan","Coma","COPD",
"lungcan","MOSF","sepsis",
"age","male","meanbp1") # variables de confusion
table1 = CreateTableOne(vars=xvars,strata="treatment", data=rhc_small_disjunctive, test=FALSE)
print(table1,smd=TRUE)
Stratified by treatment
0 1
n 3551 2184
CHF (mean (SD)) 0.07 (0.25) 0.10 (0.29)
Cirr (mean (SD)) 0.05 (0.22) 0.02 (0.15)
colcan (mean (SD)) 0.00 (0.04) 0.00 (0.02)
Coma (mean (SD)) 0.10 (0.29) 0.04 (0.20)
COPD (mean (SD)) 0.11 (0.32) 0.03 (0.16)
lungcan (mean (SD)) 0.01 (0.10) 0.00 (0.05)
MOSF (mean (SD)) 0.07 (0.25) 0.07 (0.26)
sepsis (mean (SD)) 0.15 (0.36) 0.32 (0.47)
age (mean (SD)) 61.76 (17.29) 60.75 (15.63)
male (mean (SD)) 0.54 (0.50) 0.59 (0.49)
meanbp1 (mean (SD)) 84.87 (38.87) 68.20 (34.24)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.095
Cirr (mean (SD)) 0.145
colcan (mean (SD)) 0.038
Coma (mean (SD)) 0.207
COPD (mean (SD)) 0.342
lungcan (mean (SD)) 0.095
MOSF (mean (SD)) 0.018
sepsis (mean (SD)) 0.415
age (mean (SD)) 0.061
male (mean (SD)) 0.093
meanbp1 (mean (SD)) 0.455
greedymatch = Match(Tr=rhc_small_disjunctive$treatment,
M=1,
X=rhc_small_disjunctive[xvars],replace=FALSE)
rhc_small_disjunctive_matched = rhc_small_disjunctive %>%
slice(c(greedymatch$index.control,
greedymatch$index.treated)) %>%
mutate( match_id = rep(c(1:2184),2))
matchedtab1 = CreateTableOne(vars=xvars,strata="treatment", data=rhc_small_disjunctive_matched, test=FALSE)
print(matchedtab1, smd = TRUE)
Stratified by treatment
0 1
n 2184 2184
CHF (mean (SD)) 0.10 (0.29) 0.10 (0.29)
Cirr (mean (SD)) 0.02 (0.15) 0.02 (0.15)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.02)
Coma (mean (SD)) 0.04 (0.20) 0.04 (0.20)
COPD (mean (SD)) 0.03 (0.16) 0.03 (0.16)
lungcan (mean (SD)) 0.00 (0.05) 0.00 (0.05)
MOSF (mean (SD)) 0.07 (0.26) 0.07 (0.26)
sepsis (mean (SD)) 0.24 (0.43) 0.32 (0.47)
age (mean (SD)) 61.25 (16.38) 60.75 (15.63)
male (mean (SD)) 0.56 (0.50) 0.59 (0.49)
meanbp1 (mean (SD)) 72.93 (34.14) 68.20 (34.24)
Stratified by treatment
SMD
n
CHF (mean (SD)) <0.001
Cirr (mean (SD)) <0.001
colcan (mean (SD)) <0.001
Coma (mean (SD)) <0.001
COPD (mean (SD)) <0.001
lungcan (mean (SD)) <0.001
MOSF (mean (SD)) <0.001
sepsis (mean (SD)) 0.177
age (mean (SD)) 0.031
male (mean (SD)) 0.042
meanbp1 (mean (SD)) 0.138
y_trt = rhc_small_disjunctive_matched %>% filter(treatment==1) %>%
dplyr::select(Death) %>% pull()
y_con = rhc_small_disjunctive_matched %>% filter(treatment==0) %>%
dplyr::select(Death)%>% pull()
table(y_trt,y_con)
y_con
y_trt 0 1
0 303 395
1 508 978
mcnemar.test(matrix(table(y_trt,y_con),2,2))
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 13.891, df = 1, p-value
= 0.0001937
psmodel = glm(treatment ~ . - Death ,
family=binomial(),
data=rhc_small_disjunctive)
summary(psmodel)
Call:
glm(formula = treatment ~ . - Death, family = binomial(), data = rhc_small_disjunctive)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.7013 -1.0097 -0.6336 1.1814 2.4791
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.3934383 0.1388907 2.833 0.004615
CHF 0.3872748 0.1049917 3.689 0.000225
Cirr -0.7697450 0.1694342 -4.543 5.55e-06
colcan -1.2636489 1.0901722 -1.159 0.246404
Coma -0.5918506 0.1263961 -4.683 2.83e-06
COPD -1.2931956 0.1487784 -8.692 < 2e-16
lungcan -1.3801526 0.4852428 -2.844 0.004452
MOSF 0.0114630 0.1126526 0.102 0.918951
sepsis 0.7501648 0.0726732 10.322 < 2e-16
age -0.0031374 0.0017289 -1.815 0.069567
male 0.1697903 0.0583574 2.909 0.003620
meanbp1 -0.0109824 0.0008217 -13.366 < 2e-16
(Intercept) **
CHF ***
Cirr ***
colcan
Coma ***
COPD ***
lungcan **
MOSF
sepsis ***
age .
male **
meanbp1 ***
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 7621.4 on 5734 degrees of freedom
Residual deviance: 6983.6 on 5723 degrees of freedom
AIC: 7007.6
Number of Fisher Scoring iterations: 4
ggplot(rhc_small_disjunctive %>% mutate(propensity = pscore) ,
aes(as.factor(treatment),pscore,fill = treatment) )+ geom_violin()
#logit = function(p) {log(p)-log(1-p)}
#logit_pscore = logit(pscore) # or
predict(psmodel)
1 2 3 4
-1.400648912 0.206435553 -0.365702788 -0.446938036
5 6 7 8
0.386478803 -2.432791038 -0.333583743 -0.979428947
9 10 11 12
-0.233769759 -0.560200391 -0.269666530 -0.200324292
13 14 15 16
0.496933291 0.165445731 -0.429765350 -1.010832061
17 18 19 20
-0.351163270 -0.544522136 0.601348372 -0.252588293
21 22 23 24
0.638501114 -1.121127331 0.302395050 -1.386075423
25 26 27 28
0.063756725 -1.312987197 -1.485354631 -0.752852707
29 30 31 32
-0.735231558 -0.263661837 0.553191164 -0.125712536
33 34 35 36
-0.012037181 -2.169902474 -0.220063003 0.500564612
37 38 39 40
-0.304270328 -0.037328206 -0.321020718 -0.392746715
41 42 43 44
-0.009096550 -0.015754710 -0.417882807 0.030075445
45 46 47 48
-0.073346976 -0.692253800 -0.311221247 -2.245760828
49 50 51 52
-1.622956974 -1.094100164 -0.355751720 -1.022260594
53 54 55 56
-1.615104551 -0.197929059 0.557622560 -0.366691537
57 58 59 60
-0.332140615 0.816305732 -0.443913304 -0.590350667
61 62 63 64
-0.350888542 -0.460618569 0.558692445 -0.235604151
65 66 67 68
-0.423986112 0.439442291 -0.535514682 -2.468019128
69 70 71 72
-1.144485692 -1.088701436 0.026776416 -0.115804169
73 74 75 76
0.788996260 -1.997475116 -1.062562512 -0.618636970
77 78 79 80
0.128631257 -0.607510122 -1.134748165 0.746155514
81 82 83 84
-2.517407412 -2.097756628 -1.012519067 0.375518164
85 86 87 88
-0.300756712 -0.313193023 -2.418509668 -1.351554781
89 90 91 92
-0.453460554 -0.325369408 -1.832222170 -1.747207758
93 94 95 96
-0.618048385 -0.429072240 -1.174785938 -1.037662008
97 98 99 100
-0.474790115 -0.626512025 -0.568803160 0.986737159
101 102 103 104
0.745256732 0.131305928 -0.756925651 -1.180240587
105 106 107 108
-0.994541841 -0.130795311 -0.252869087 -1.766164149
109 110 111 112
-0.536342183 -0.497079576 -0.287012544 -0.451697532
113 114 115 116
-1.497674133 -0.494227711 -1.681941425 -0.571193773
117 118 119 120
-0.955575973 0.544051942 -1.137706566 0.584800140
121 122 123 124
0.498304271 -1.806786940 0.584086403 -0.247229842
125 126 127 128
-1.293951261 -0.432721217 -0.222171538 -1.682684800
129 130 131 132
-1.564921999 -0.183602042 -1.713368905 -0.353757820
133 134 135 136
0.319654292 0.185604913 -0.980498813 -0.264301790
137 138 139 140
-0.359121109 -0.288403122 -1.710996526 -1.775848040
141 142 143 144
0.016331188 -0.353419106 -0.045089192 -0.619049809
145 146 147 148
-0.278697487 0.401488066 -0.488519211 0.093230875
149 150 151 152
-0.170433038 -0.771024543 -0.389570941 -1.280378942
153 154 155 156
-0.788144850 -2.319550646 -0.456023600 -0.405585826
157 158 159 160
-1.053467291 -0.219887413 -1.357760638 0.491395637
161 162 163 164
-1.671719521 -0.391381374 -1.177919832 -0.888477164
165 166 167 168
0.304153904 -1.076748891 -2.217587167 -1.704265496
169 170 171 172
-0.262462724 -1.023550165 0.212024338 0.404996979
173 174 175 176
-0.398454528 -0.478881049 0.076401682 -0.346787447
177 178 179 180
-0.059754045 0.551377629 -0.290487757 0.364033839
181 182 183 184
-2.213005059 -0.323365979 -0.265815454 -0.815768058
185 186 187 188
-0.586075910 -0.334340484 0.476789530 -1.081428403
189 190 191 192
0.482873223 -0.296900525 -0.691086858 0.270809801
193 194 195 196
-0.979627349 -1.037431656 -0.228043824 -2.857726713
197 198 199 200
-1.138839086 -1.883293225 -0.120164395 0.052449598
201 202 203 204
0.098517957 -0.036892086 -0.261303475 -0.271138147
205 206 207 208
-0.902426184 0.270524342 -1.360308285 -0.152474706
209 210 211 212
-1.553444166 -1.190108659 -1.175168574 -1.079304590
213 214 215 216
-0.216571135 -1.276087418 -0.104262478 0.258611760
217 218 219 220
-0.364915156 -1.478013051 0.517260118 -1.118516686
221 222 223 224
-1.191807644 0.072371933 -0.986471988 -0.343638322
225 226 227 228
-0.099439678 -0.138747942 -1.137294154 0.627066852
229 230 231 232
-1.941603032 -1.182006493 -0.300526750 -1.365386165
233 234 235 236
-1.071234903 0.401859540 0.265793132 0.605042526
237 238 239 240
-0.852048653 -1.181525143 -0.310305264 -1.085691267
241 242 243 244
-1.225979982 -2.003014139 -1.584985118 -0.233760901
245 246 247 248
-0.000728897 -2.462214727 -1.010277558 0.491433446
249 250 251 252
-2.054487680 -0.059421024 -2.078585749 -0.278114300
253 254 255 256
-2.590342024 -0.304127542 0.487237292 0.012659905
257 258 259 260
-0.121574618 -0.373316252 -0.964558582 -0.256057015
261 262 263 264
-0.408450997 -0.265512900 -0.285439961 0.480148282
265 266 267 268
0.183941553 -0.186787476 -1.287407967 -0.926410446
269 270 271 272
-0.953947268 -0.653102749 -0.070195345 -1.694159646
273 274 275 276
-0.024215676 0.592499278 -1.266393741 -1.683637414
277 278 279 280
-0.159678165 -0.408693183 0.414914122 -0.033499097
281 282 283 284
0.476562016 -0.322195218 -0.314826914 -1.136697763
285 286 287 288
-0.516132931 -1.880364913 -1.044841058 -0.550021220
289 290 291 292
-0.720334401 0.554146256 -0.217269286 -2.634042824
293 294 295 296
-1.159392053 -0.649050555 -1.180778119 -1.327864719
297 298 299 300
-1.424934900 0.050115325 0.728895153 -1.058673472
301 302 303 304
-1.590547780 -1.650348030 0.022192671 -0.019123321
305 306 307 308
-1.001061209 -0.432025950 0.363426919 -0.359263272
309 310 311 312
0.322498009 -2.494864063 -1.750472821 -1.400221810
313 314 315 316
-0.773537387 -2.209288926 0.520341058 -0.679989930
317 318 319 320
0.097397226 -0.491154372 0.317785665 0.492478087
321 322 323 324
-1.277277623 -0.166398233 -0.378726574 0.125643029
325 326 327 328
-1.078124708 -0.454020437 -0.260525985 -0.250323383
329 330 331 332
-1.911022014 -0.490456497 -2.404198378 0.614130076
333 334 335 336
-0.122992605 0.442839949 -0.393006281 -1.656136317
337 338 339 340
0.459633100 -0.896054906 -1.232910225 0.535692178
341 342 343 344
-0.335975055 0.104100282 -0.954618957 -1.337192129
345 346 347 348
-2.068706029 -0.063504935 -1.956498321 0.188713624
349 350 351 352
-0.226721467 -0.083111364 -0.290798354 -0.099170605
353 354 355 356
-0.333488765 -0.337840373 -1.641659130 0.594301858
357 358 359 360
0.409378346 -0.252197849 -1.004652139 -0.431126985
361 362 363 364
-0.695881056 -1.415279865 -1.629752679 -0.841487094
365 366 367 368
-0.338011393 -2.171834587 0.498564690 0.580993023
369 370 371 372
-1.800085489 0.540520942 0.167856387 -1.441431649
373 374 375 376
-0.347112894 -0.210175118 -0.259978591 -0.455598514
377 378 379 380
-0.783834074 -0.349510783 0.528388524 -0.649929439
381 382 383 384
-0.830305662 -1.183211704 -0.636771215 0.287128878
385 386 387 388
0.569604267 -0.452800022 -1.174589955 0.261675294
389 390 391 392
0.259566566 -1.097953084 0.486578199 -0.323334521
393 394 395 396
0.048896333 -0.449237634 -1.105273024 -1.051155043
397 398 399 400
-0.110588274 0.204782132 -1.592446401 -1.710297059
401 402 403 404
-0.739150986 0.485488148 0.462031410 -0.361009359
405 406 407 408
-0.180988730 0.750731390 -1.011168238 -0.438768385
409 410 411 412
-1.971475784 -0.359024010 -0.173575890 -0.741455862
413 414 415 416
0.346375029 0.351118823 -2.620429665 -0.221035836
417 418 419 420
-0.246782789 0.624536592 -1.068817504 -1.227151831
421 422 423 424
0.324796255 0.244851060 0.019677025 -0.474868527
425 426 427 428
-0.323329902 0.586979158 -1.263237930 -0.399849817
429 430 431 432
0.546513193 -2.240538890 -1.583653669 -1.572023724
433 434 435 436
0.201735393 -0.479663577 -0.152979851 0.642653517
437 438 439 440
-2.337556015 -0.209940470 -1.262715621 -0.220753387
441 442 443 444
-0.191092657 -1.759064581 -2.107047973 0.347667867
445 446 447 448
-0.348411820 -0.373091894 -0.104457040 -0.236486549
449 450 451 452
-0.460143121 -0.991741618 -1.959870929 -0.352332698
453 454 455 456
-0.036521693 0.315164482 0.083150424 0.313737190
457 458 459 460
-1.011199868 -0.716040044 -0.211581149 -0.129579557
461 462 463 464
-0.246683085 -0.813215515 -0.275204050 -0.830955796
465 466 467 468
-0.549081553 0.614953376 -1.018498883 -0.508377761
469 470 471 472
0.475382466 -0.773430498 0.577679896 -0.414934237
473 474 475 476
-0.361021633 -0.958666891 -0.543088994 -1.917004690
477 478 479 480
-0.226907998 -1.055864925 -0.308398318 0.342362399
481 482 483 484
-0.339376072 -1.825286932 -0.291816718 -0.723783072
485 486 487 488
-1.297980970 -1.088696845 0.491067840 -0.894870333
489 490 491 492
-0.405256185 -0.289010244 0.483914850 -0.790163577
493 494 495 496
0.679414083 -0.564342529 0.665926499 -0.188529465
497 498 499 500
0.603017349 -1.104648205 -0.261249909 -0.247882268
501 502 503 504
-0.388688810 -1.539397777 -1.684515886 -0.927361155
505 506 507 508
0.435766282 -2.180974264 -1.612018942 -0.120663092
509 510 511 512
-1.347767247 -0.314908641 -1.598614030 0.419077563
513 514 515 516
-0.138511681 -0.474923561 0.256697858 -0.451693854
517 518 519 520
0.252633581 -0.060643396 -0.855645690 -1.125434867
521 522 523 524
-0.916272746 -0.387602336 -0.868593370 -0.434439392
525 526 527 528
-0.801797154 -0.398827761 -1.049896367 -1.197397675
529 530 531 532
-1.821295770 -2.017578230 -0.224861963 0.041051459
533 534 535 536
0.637158389 -0.400046753 -0.462789216 -0.941143624
537 538 539 540
-1.744957638 -0.917514399 -0.597801908 -0.260858377
541 542 543 544
0.239517667 -0.283365521 -1.223570404 0.454239643
545 546 547 548
-0.816418718 -0.362398063 -0.992140429 -2.473457677
549 550 551 552
-1.681936714 0.025400950 0.476703322 -0.454601895
553 554 555 556
-0.764749222 -0.428137224 -0.387492612 0.380621300
557 558 559 560
-0.220116490 -0.618583690 0.448474649 -0.357425512
561 562 563 564
-1.215443148 -0.121041267 0.288103113 -0.487813285
565 566 567 568
-1.787114375 -0.306462818 0.476491587 -0.954711326
569 570 571 572
-0.239839876 0.005805957 -0.451201710 0.235921779
573 574 575 576
-1.071031699 0.376710512 -0.165399009 0.380296377
577 578 579 580
0.507629933 0.508765895 -1.113857786 0.489301715
581 582 583 584
-2.358894928 -0.511128909 -1.278664486 0.418977068
585 586 587 588
0.207059816 -0.288649256 -0.810357274 -1.867449769
589 590 591 592
-0.202760457 -1.643737718 -1.619022655 -0.233563282
593 594 595 596
-1.952203288 0.300074774 0.328696951 0.303360019
597 598 599 600
-1.820652430 -0.060030175 -0.370795182 0.118767490
601 602 603 604
0.592491603 -1.433012550 -0.279663947 0.412504751
605 606 607 608
-1.139909954 0.181155956 0.050435317 -0.221169212
609 610 611 612
-0.685577857 0.495257940 -2.455588859 -2.623584356
613 614 615 616
-1.716317609 -0.091353007 0.401881851 0.053745368
617 618 619 620
0.428408121 -0.106208835 -1.649629218 -0.474524912
621 622 623 624
-1.800951512 -0.472744091 0.616969244 -0.340609356
625 626 627 628
0.080350093 -0.340070297 -0.727540047 0.127467201
629 630 631 632
-0.215293652 0.508372168 0.701645457 -0.573995463
633 634 635 636
-2.083354524 -1.554913701 -2.103311262 -1.209872812
637 638 639 640
-1.651166786 -1.496641266 0.153780443 -0.886266808
641 642 643 644
-1.572053151 0.442469798 0.538469067 -0.168775759
645 646 647 648
-0.119122747 -1.509247455 1.131679479 -0.232733485
649 650 651 652
-0.113304427 -0.241347080 0.603630766 -0.683201149
653 654 655 656
0.097246661 0.405001697 -1.739548112 -1.930278753
657 658 659 660
-0.967993234 -0.346581017 -0.247697093 -0.643059983
661 662 663 664
-0.444685210 -0.425800004 -0.248973457 -0.073412646
665 666 667 668
-1.695239018 -2.456442244 0.372926719 0.311336928
669 670 671 672
-2.142305784 -1.490322835 -0.213896732 0.395584837
673 674 675 676
-0.387394595 -1.662513258 -0.211720818 -0.712796097
677 678 679 680
-2.360678258 0.422988375 -2.308880512 0.470340870
681 682 683 684
-1.856597705 -0.291484190 -0.903194134 -1.702282518
685 686 687 688
-1.398377170 0.487403406 -0.687888554 -0.299582564
689 690 691 692
-0.136925692 -1.300898703 -0.497852139 -0.339838781
693 694 695 696
-1.981171728 -1.044329221 -0.356832562 -0.918359902
697 698 699 700
-1.671147445 -0.255059733 -0.350496523 -0.359557311
701 702 703 704
-0.346441628 -1.073820243 -0.104844598 -1.019273767
705 706 707 708
-0.726982507 0.246476240 -0.533081035 -0.135750998
709 710 711 712
-2.509548536 -1.413113410 -0.027161573 0.670827178
713 714 715 716
0.362401110 -0.223703926 -0.108555921 -0.720833821
717 718 719 720
-0.302971498 -0.300033236 -0.522821634 0.114472126
721 722 723 724
-0.537862206 0.122129884 -0.806187817 0.100669511
725 726 727 728
-1.111664151 -0.413904406 -0.990899406 -1.183317735
729 730 731 732
-0.515128677 -1.603982146 0.500843933 -0.305144303
733 734 735 736
-1.581077590 -0.379149755 -0.910727722 -1.768504918
737 738 739 740
-1.128295933 0.390274266 -0.462096256 -1.067199273
741 742 743 744
-1.795102173 -2.017093038 -0.961130245 0.258697899
745 746 747 748
-0.119097662 0.700920765 -0.177543769 -0.197448993
749 750 751 752
-0.161998173 -0.891822409 -0.134277907 0.612765173
753 754 755 756
-0.368657300 0.373879156 -0.874028936 -0.538232513
757 758 759 760
0.402457437 0.553059095 0.123700982 -1.709435841
761 762 763 764
-0.010046261 -0.230065188 -1.324954760 -0.324394156
765 766 767 768
-0.111429063 -1.174893872 -0.777237793 -0.494947094
769 770 771 772
-0.560503119 -0.682869996 -0.245926252 -1.070704989
773 774 775 776
-0.289455577 -0.597384596 -0.213902884 -0.498099220
777 778 779 780
-2.225565665 -0.103214462 -0.350320726 0.602739661
781 782 783 784
-0.065838360 -1.025289660 -0.925535255 0.582062884
785 786 787 788
-0.879859722 0.632212202 -1.332162737 -0.065157470
789 790 791 792
-0.213620604 -1.303433931 -1.000200402 0.256968960
793 794 795 796
-0.410285404 -1.629150572 -3.025573018 -1.273385755
797 798 799 800
-0.331897636 -1.271312642 -1.662456664 -0.611717729
801 802 803 804
-1.698354569 -0.341835791 -0.863854390 -1.158556432
805 806 807 808
-0.298794195 0.184482856 -0.597936485 -0.463749407
809 810 811 812
-0.458026288 -0.273748354 0.567213607 -2.201558069
813 814 815 816
0.610674096 0.220176778 0.186274399 -0.961298060
817 818 819 820
-0.120595903 -0.303278200 0.480301958 0.261116815
821 822 823 824
-2.426356005 -0.146676668 -0.287331553 0.619323942
825 826 827 828
-0.334078452 -0.471677713 -1.045784659 0.115361854
829 830 831 832
-0.402622537 0.693681352 -2.453543216 -1.581763511
833 834 835 836
-2.760830218 -0.468234553 -0.852124718 -1.692269888
837 838 839 840
-0.422530085 -0.355749421 -1.461364855 -0.845546335
841 842 843 844
0.167836112 0.260004708 0.174650864 -0.909787145
845 846 847 848
-1.339276854 -1.747092317 -0.677506707 -0.992319148
849 850 851 852
-1.584154156 -0.349254033 0.615038238 -0.540342182
853 854 855 856
-1.556460516 -0.209596814 -0.235940936 -0.738706198
857 858 859 860
-2.407550588 -0.150647182 0.410986558 -1.333218679
861 862 863 864
-1.416995771 -0.153750913 0.456801557 -2.383560908
865 866 867 868
-0.842229093 -0.354612557 0.263331882 0.653679701
869 870 871 872
-0.461773034 -0.235381593 -0.305070507 -2.695182225
873 874 875 876
0.478093405 -1.774896968 -0.996464036 -1.079717259
877 878 879 880
-0.278491349 -1.633150808 -0.226991323 -0.155626095
881 882 883 884
0.505156330 0.156207253 0.450813636 -0.078027758
885 886 887 888
-0.238220861 -0.097251854 -1.102241562 0.430047203
889 890 891 892
-0.314918690 -0.303073338 0.594968559 -2.168145272
893 894 895 896
-0.384146576 0.444893548 0.287635596 0.504106889
897 898 899 900
0.167147447 -0.587985193 -0.218069458 0.196627589
901 902 903 904
-0.365005149 -0.181900109 -0.308647850 -1.592736578
905 906 907 908
0.612716658 -2.170254032 -0.273560007 -0.133405610
909 910 911 912
-0.560689845 -2.481537724 0.498551974 -1.640330164
913 914 915 916
-2.340338897 0.380084615 -2.000137140 -0.169214070
917 918 919 920
-0.755312043 -0.365068239 -1.910667062 -0.568718190
921 922 923 924
-0.399988853 -0.367094875 0.593349541 -0.095016654
925 926 927 928
-1.025834401 -1.455844663 -0.135661471 0.553416977
929 930 931 932
-0.545161319 -0.372028513 -0.080108838 -0.384640004
933 934 935 936
-0.274719322 -0.609604599 -1.148229537 -1.188666505
937 938 939 940
-0.146232179 -1.503699282 -0.319876697 -2.472513156
941 942 943 944
-1.069732231 -1.393236581 -1.810694341 -0.324233731
945 946 947 948
-1.884857474 -1.107143974 -1.025623780 -0.088473738
949 950 951 952
-0.195008064 -1.909829272 0.235445238 1.056407529
953 954 955 956
-1.663328816 -2.540048592 -0.344974748 0.320071227
957 958 959 960
-2.330732159 0.394663420 -0.241159714 0.571610739
961 962 963 964
-0.403807798 0.633707245 0.452686874 -0.741528241
965 966 967 968
-1.265917365 0.070891191 -2.207259034 -1.925541700
969 970 971 972
0.032155507 -0.994483663 0.771670310 0.156353563
973 974 975 976
0.009953937 -0.856336321 -0.164352215 -0.959666752
977 978 979 980
-0.273887916 -0.120023285 -1.479593408 -0.591708360
981 982 983 984
-0.577790930 -0.827642953 -0.236059232 0.258396639
985 986 987 988
0.317871962 -0.305911391 -0.389589939 -0.224244565
989 990 991 992
-1.264793982 -0.296597011 -0.216898619 0.580244473
993 994 995 996
-0.370569312 0.283045557 0.348455422 0.057444241
997 998 999 1000
-0.870011453 0.248071300 -0.986103848 0.982169152
[ reached getOption("max.print") -- omitted 4735 entries ]
logit
du score de propension avec le “capiler” calculé à la question précédentepsmatch = Match(Tr=rhc_small_disjunctive$treatment,M=1,X=logit_pscore,
replace=FALSE,caliper=caliper)
n_matched = length(psmatch$index.control)
rhc_small_disjunctive_matched_propensity =rhc_small_disjunctive %>%
slice(c(psmatch$index.control,
psmatch$index.treated)) %>%
mutate( match_id = rep(c(1:n_matched),2))
matchedtab1<-CreateTableOne(vars=xvars, strata ="treatment",
data=rhc_small_disjunctive_matched_propensity, test = FALSE)
print(matchedtab1, smd = TRUE)
Stratified by treatment
0 1
n 1925 1925
CHF (mean (SD)) 0.09 (0.29) 0.09 (0.29)
Cirr (mean (SD)) 0.03 (0.16) 0.03 (0.16)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.02)
Coma (mean (SD)) 0.04 (0.21) 0.05 (0.22)
COPD (mean (SD)) 0.03 (0.16) 0.03 (0.17)
lungcan (mean (SD)) 0.00 (0.06) 0.00 (0.05)
MOSF (mean (SD)) 0.08 (0.27) 0.08 (0.27)
sepsis (mean (SD)) 0.25 (0.43) 0.25 (0.43)
age (mean (SD)) 61.14 (17.78) 60.94 (15.53)
male (mean (SD)) 0.57 (0.50) 0.57 (0.49)
meanbp1 (mean (SD)) 71.37 (33.68) 71.06 (35.06)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.009
Cirr (mean (SD)) 0.003
colcan (mean (SD)) <0.001
Coma (mean (SD)) 0.025
COPD (mean (SD)) 0.019
lungcan (mean (SD)) 0.010
MOSF (mean (SD)) <0.001
sepsis (mean (SD)) 0.012
age (mean (SD)) 0.012
male (mean (SD)) 0.015
meanbp1 (mean (SD)) 0.009
y_trt = rhc_small_disjunctive_matched_propensity %>% filter(treatment==1) %>%
dplyr::select(Death) %>% pull()
y_con = rhc_small_disjunctive_matched_propensity %>% filter(treatment==0) %>%
dplyr::select(Death)%>% pull()
table(y_trt,y_con)
y_con
y_trt 0 1
0 231 381
1 468 845
mcnemar.test(matrix(table(y_trt,y_con),2,2))
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 8.7114, df = 1, p-value
= 0.003162
for (cal_const in c(0.0001,0.01,0.1,0.5,1,5)){
caliper = cal_const *sd(logit_pscore)
print(paste(c("Le caliper vaut ",caliper),collapse=""))
psmatch = Match(Tr=rhc_small_disjunctive$treatment,M=1,X=logit_pscore,
replace=FALSE,caliper=caliper)
n_matched = length(psmatch$index.control)
rhc_small_disjunctive_matched_propensity =rhc_small_disjunctive %>%
slice(c(psmatch$index.control,
psmatch$index.treated)) %>%
mutate( match_id = rep(c(1:n_matched),2))
print(paste(c("Il y a ",length(psmatch$index.treated)," données matchées"),collapse=""))
matchedtab1<-CreateTableOne(vars=xvars, strata ="treatment",
data=rhc_small_disjunctive_matched_propensity, test = FALSE)
print(matchedtab1, smd = TRUE)
y_trt = rhc_small_disjunctive_matched_propensity %>% filter(treatment==1) %>%
dplyr::select(Death) %>% pull()
y_con = rhc_small_disjunctive_matched_propensity %>% filter(treatment==0) %>%
dplyr::select(Death)%>% pull()
print(table(y_trt,y_con))
print(mcnemar.test(matrix(table(y_trt,y_con),2,2)))
}
[1] "Le caliper vaut 7.7179970051288e-05"
[1] "Il y a 335 données matchées"
Stratified by treatment
0 1
n 335 335
CHF (mean (SD)) 0.05 (0.21) 0.05 (0.22)
Cirr (mean (SD)) 0.04 (0.19) 0.04 (0.19)
colcan (mean (SD)) 0.00 (0.00) 0.00 (0.00)
Coma (mean (SD)) 0.05 (0.22) 0.04 (0.19)
COPD (mean (SD)) 0.01 (0.12) 0.01 (0.12)
lungcan (mean (SD)) 0.00 (0.00) 0.00 (0.05)
MOSF (mean (SD)) 0.08 (0.28) 0.13 (0.33)
sepsis (mean (SD)) 0.24 (0.43) 0.21 (0.41)
age (mean (SD)) 62.28 (17.65) 61.94 (15.10)
male (mean (SD)) 0.52 (0.50) 0.56 (0.50)
meanbp1 (mean (SD)) 69.27 (31.02) 68.71 (31.26)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.014
Cirr (mean (SD)) <0.001
colcan (mean (SD)) <0.001
Coma (mean (SD)) 0.058
COPD (mean (SD)) <0.001
lungcan (mean (SD)) 0.077
MOSF (mean (SD)) 0.146
sepsis (mean (SD)) 0.057
age (mean (SD)) 0.020
male (mean (SD)) 0.072
meanbp1 (mean (SD)) 0.018
y_con
y_trt 0 1
0 38 81
1 90 126
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 0.37427, df = 1,
p-value = 0.5407
[1] "Le caliper vaut 0.0077179970051288"
[1] "Il y a 1863 données matchées"
Stratified by treatment
0 1
n 1863 1863
CHF (mean (SD)) 0.09 (0.29) 0.08 (0.27)
Cirr (mean (SD)) 0.03 (0.16) 0.03 (0.16)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.00)
Coma (mean (SD)) 0.05 (0.21) 0.05 (0.22)
COPD (mean (SD)) 0.03 (0.16) 0.03 (0.17)
lungcan (mean (SD)) 0.00 (0.06) 0.00 (0.05)
MOSF (mean (SD)) 0.08 (0.27) 0.08 (0.28)
sepsis (mean (SD)) 0.25 (0.43) 0.25 (0.44)
age (mean (SD)) 60.83 (17.91) 60.92 (15.58)
male (mean (SD)) 0.57 (0.50) 0.57 (0.50)
meanbp1 (mean (SD)) 71.63 (33.51) 71.25 (34.94)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.033
Cirr (mean (SD)) 0.007
colcan (mean (SD)) 0.033
Coma (mean (SD)) 0.020
COPD (mean (SD)) 0.020
lungcan (mean (SD)) 0.019
MOSF (mean (SD)) 0.008
sepsis (mean (SD)) 0.011
age (mean (SD)) 0.006
male (mean (SD)) 0.003
meanbp1 (mean (SD)) 0.011
y_con
y_trt 0 1
0 230 376
1 467 790
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 9.6085, df = 1, p-value
= 0.001937
[1] "Le caliper vaut 0.077179970051288"
[1] "Il y a 1915 données matchées"
Stratified by treatment
0 1
n 1915 1915
CHF (mean (SD)) 0.10 (0.30) 0.09 (0.28)
Cirr (mean (SD)) 0.03 (0.17) 0.03 (0.16)
colcan (mean (SD)) 0.00 (0.03) 0.00 (0.02)
Coma (mean (SD)) 0.04 (0.21) 0.05 (0.22)
COPD (mean (SD)) 0.03 (0.17) 0.03 (0.17)
lungcan (mean (SD)) 0.00 (0.05) 0.00 (0.05)
MOSF (mean (SD)) 0.08 (0.27) 0.08 (0.27)
sepsis (mean (SD)) 0.25 (0.44) 0.25 (0.43)
age (mean (SD)) 60.96 (17.72) 60.86 (15.61)
male (mean (SD)) 0.57 (0.50) 0.57 (0.50)
meanbp1 (mean (SD)) 71.82 (33.96) 71.17 (35.12)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.042
Cirr (mean (SD)) 0.019
colcan (mean (SD)) 0.019
Coma (mean (SD)) 0.022
COPD (mean (SD)) 0.009
lungcan (mean (SD)) <0.001
MOSF (mean (SD)) 0.006
sepsis (mean (SD)) 0.004
age (mean (SD)) 0.006
male (mean (SD)) 0.009
meanbp1 (mean (SD)) 0.019
y_con
y_trt 0 1
0 239 373
1 460 843
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 8.8788, df = 1, p-value
= 0.002885
[1] "Le caliper vaut 0.38589985025644"
[1] "Il y a 1957 données matchées"
Stratified by treatment
0 1
n 1957 1957
CHF (mean (SD)) 0.09 (0.29) 0.10 (0.30)
Cirr (mean (SD)) 0.03 (0.16) 0.03 (0.16)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.02)
Coma (mean (SD)) 0.04 (0.20) 0.05 (0.21)
COPD (mean (SD)) 0.03 (0.16) 0.03 (0.17)
lungcan (mean (SD)) 0.00 (0.06) 0.00 (0.05)
MOSF (mean (SD)) 0.08 (0.28) 0.08 (0.27)
sepsis (mean (SD)) 0.25 (0.43) 0.25 (0.43)
age (mean (SD)) 61.24 (17.71) 60.91 (15.49)
male (mean (SD)) 0.57 (0.50) 0.58 (0.49)
meanbp1 (mean (SD)) 71.51 (34.12) 70.72 (34.91)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.021
Cirr (mean (SD)) 0.013
colcan (mean (SD)) <0.001
Coma (mean (SD)) 0.029
COPD (mean (SD)) 0.022
lungcan (mean (SD)) 0.010
MOSF (mean (SD)) 0.015
sepsis (mean (SD)) 0.006
age (mean (SD)) 0.020
male (mean (SD)) 0.014
meanbp1 (mean (SD)) 0.023
y_con
y_trt 0 1
0 251 374
1 461 871
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 8.8575, df = 1, p-value
= 0.002919
[1] "Le caliper vaut 0.77179970051288"
[1] "Il y a 2041 données matchées"
Stratified by treatment
0 1
n 2041 2041
CHF (mean (SD)) 0.09 (0.29) 0.10 (0.30)
Cirr (mean (SD)) 0.02 (0.15) 0.02 (0.15)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.02)
Coma (mean (SD)) 0.05 (0.21) 0.05 (0.21)
COPD (mean (SD)) 0.03 (0.16) 0.03 (0.17)
lungcan (mean (SD)) 0.00 (0.06) 0.00 (0.05)
MOSF (mean (SD)) 0.09 (0.28) 0.08 (0.27)
sepsis (mean (SD)) 0.24 (0.43) 0.28 (0.45)
age (mean (SD)) 60.70 (17.98) 60.92 (15.53)
male (mean (SD)) 0.58 (0.49) 0.58 (0.49)
meanbp1 (mean (SD)) 70.48 (33.19) 69.94 (34.56)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.021
Cirr (mean (SD)) <0.001
colcan (mean (SD)) <0.001
Coma (mean (SD)) 0.005
COPD (mean (SD)) 0.006
lungcan (mean (SD)) 0.018
MOSF (mean (SD)) 0.034
sepsis (mean (SD)) 0.088
age (mean (SD)) 0.013
male (mean (SD)) 0.003
meanbp1 (mean (SD)) 0.016
y_con
y_trt 0 1
0 243 410
1 500 888
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 8.7044, df = 1, p-value
= 0.003174
[1] "Le caliper vaut 3.8589985025644"
[1] "Il y a 2184 données matchées"
Stratified by treatment
0 1
n 2184 2184
CHF (mean (SD)) 0.09 (0.28) 0.10 (0.29)
Cirr (mean (SD)) 0.02 (0.15) 0.02 (0.15)
colcan (mean (SD)) 0.00 (0.02) 0.00 (0.02)
Coma (mean (SD)) 0.05 (0.21) 0.04 (0.20)
COPD (mean (SD)) 0.03 (0.17) 0.03 (0.16)
lungcan (mean (SD)) 0.00 (0.04) 0.00 (0.05)
MOSF (mean (SD)) 0.09 (0.28) 0.07 (0.26)
sepsis (mean (SD)) 0.23 (0.42) 0.32 (0.47)
age (mean (SD)) 61.00 (17.80) 60.75 (15.63)
male (mean (SD)) 0.56 (0.50) 0.59 (0.49)
meanbp1 (mean (SD)) 70.09 (32.48) 68.20 (34.24)
Stratified by treatment
SMD
n
CHF (mean (SD)) 0.027
Cirr (mean (SD)) 0.006
colcan (mean (SD)) <0.001
Coma (mean (SD)) 0.011
COPD (mean (SD)) 0.014
lungcan (mean (SD)) 0.010
MOSF (mean (SD)) 0.054
sepsis (mean (SD)) 0.197
age (mean (SD)) 0.015
male (mean (SD)) 0.044
meanbp1 (mean (SD)) 0.057
y_con
y_trt 0 1
0 244 454
1 545 941
McNemar's Chi-squared test with continuity
correction
data: matrix(table(y_trt, y_con), 2, 2)
McNemar's chi-squared = 8.1081, df = 1, p-value
= 0.004407