pacman::p_load(reader, stringr, missForest, mice, ggplot2, sandwich, tidyverse, readxl, tableone, lubridate, skimr, summarytools, naniar, norm2, lmtest, car, ROCR, pROC, Hmisc, rms, glmnet, ggpubr, ggcorrplot,VIM,stringr,doParallel,gtsummary,rmda)
data<-read_excel("varix_prediction_meld.xlsx")
# "cohort"という新しい列を作成します。これは、年度に基づいて "develop"または "validation"となります。
data_cohort <- data %>%
mutate(cohort = ifelse(year %in% 2010:2016, "develop",
ifelse(year %in% 2017:2022, "validation", NA)))
df <-
data_cohort|>
mutate(
hosp_id=as.integer(hosp_id),
pt_id=as.integer(pt_id),
hosp_num=as.integer(hosp_num),
year=as.integer(year),
age=as.integer(age),
sex= factor(sex, levels = c("M", "F")),
smoke= as.integer(smoke),
barthel= factor(barthel, levels = c("0", "1", "2")),
child_num= as.integer(child_num),
child_score=factor(child_score, levels = c("0", "1", "2")),
gcs=as.integer(gcs),
cci_num=as.integer(cci_num),
pad=factor(pad),
stroke=factor(stroke),
dimentia=factor(dimentia),
ch_lung=factor(ch_lung),
rheumati=factor(rheumati),
pept_ulcer=factor(pept_ulcer),
dm=factor(dm),
dm_compli=factor(dm_compli),
paralysis=factor(paralysis),
malignancy=factor(malignancy),
meta_tumor=factor(meta_tumor),
aids=factor(aids),
eGFR30=factor(eGFR30),
hd=factor(hd),
hcc=factor(hcc),
alcohol=factor(alcohol),
past_rupture=factor(past_rupture),
antiplate=factor(antiplate),
anticoag=factor(anticoag),
antithro=factor(antithro),
nsaids=factor(nsaids),
steroid=factor(steroid),
beta=factor(beta),
vaso=factor(vaso),
map= as.integer(map),
ffp=factor(ffp),
pc=factor(pc),
albner=factor(albner),
sBP= as.integer(sBP),
dBP= as.integer(dBP),
hr=as.integer(hr),
shock=factor(shock),
los=as.integer(los),
cohort=factor(cohort),
meld=as.integer(meld)
)
# 新しい列 "cohort" を使用してデータフレームを分割します
df_dev <- df %>%
filter(cohort == "develop")
df_val <- df %>%
filter(cohort == "validation")
str(df)
## tibble [980 × 64] (S3: tbl_df/tbl/data.frame)
## $ hosp_id : int [1:980] 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ pt_id : int [1:980] 1 2 3 4 5 6 7 8 9 10 ...
## $ hosp_num : int [1:980] 1 1 1 1 1 1 1 1 1 1 ...
## $ year : int [1:980] 2012 2011 2010 2011 2010 2017 2010 2010 2010 2011 ...
## $ age : int [1:980] 50 80 59 44 67 47 65 49 73 69 ...
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 1 2 1 2 ...
## $ bmi : num [1:980] NA 25.3 NA 14.5 NA ...
## $ smoke : int [1:980] 0 0 0 240 0 270 0 NA 1000 0 ...
## $ barthel : Factor w/ 3 levels "0","1","2": NA 3 1 2 NA NA NA NA 1 NA ...
## $ child_num : int [1:980] 11 6 NA 8 NA 11 NA NA 9 15 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 NA 2 NA 3 NA NA 2 3 ...
## $ gcs : int [1:980] 15 15 15 15 15 15 15 15 15 6 ...
## $ cci_num : int [1:980] 4 4 3 4 4 4 3 4 4 4 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 2 1 2 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ map : int [1:980] 0 2 0 6 2 0 2 0 4 14 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 2 1 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ bt : num [1:980] 36.4 36.8 35.9 36 36.6 36.4 38.4 37 37 35.5 ...
## $ sBP : int [1:980] 78 88 100 69 66 102 84 132 90 52 ...
## $ dBP : int [1:980] 48 49 56 44 40 67 46 69 54 37 ...
## $ hr : int [1:980] 118 72 110 104 72 83 127 83 114 98 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 1 2 1 2 2 ...
## $ bil : num [1:980] 2.2 1.2 3.1 3.4 1.2 7.5 2.4 1.2 2.2 8.7 ...
## $ ast : num [1:980] 217 31 60 129 52 112 90 154 55 96 ...
## $ alt : num [1:980] 63 22 40 46 36 53 19 109 20 87 ...
## $ wbc : num [1:980] 7400 5000 7800 9100 3900 9800 8000 7900 11100 12800 ...
## $ hb : num [1:980] 6.9 10.8 9.7 10.7 6.3 12.2 9.8 13.5 5.6 6 ...
## $ plt : num [1:980] 115 77 74 162 63 69 93 132 124 168 ...
## $ tp : num [1:980] 6.3 5.6 6.4 6.1 5.1 5.7 7.2 7.6 4.9 5.3 ...
## $ alb : num [1:980] 2.2 3.2 2.8 2.9 2.8 2.6 3.2 4 2.3 1.2 ...
## $ eGFR : num [1:980] 58 57.7 63.7 112.4 123.6 ...
## $ bun : num [1:980] 13.2 41.5 26.3 2.9 27.4 13.7 15.8 15.5 27 63.2 ...
## $ cre : num [1:980] 1.08 0.96 0.72 0.61 0.38 0.74 0.44 0.4 0.97 2.07 ...
## $ crp : num [1:980] 0.92 0.29 0.68 0.29 0.29 0.1 0.96 0.29 NA 2.75 ...
## $ pt : num [1:980] 37.8 55 46.7 37.8 74.6 28.5 45.9 49.7 45.9 37.2 ...
## $ aptt : num [1:980] 29.4 29 27.2 35.3 30.1 37.8 27.6 32.6 27.5 36 ...
## $ meld : int [1:980] 16 11 13 14 6 20 8 6 15 29 ...
## $ hosp_mortality: num [1:980] 0 0 0 0 0 0 0 0 0 1 ...
## $ los : int [1:980] 12 7 0 10 3 6 2 1 8 0 ...
## $ cohort : Factor w/ 2 levels "develop","validation": 1 1 1 1 1 2 1 1 1 1 ...
col_continuous = c("age", "bmi","smoke","child_num","gcs","cci_num","map","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt","los","meld")
col_factors = c("sex","barthel","child_score","pad","stroke","dimentia","ch_lung","rheumati","pept_ulcer","dm","dm_compli","paralysis","malignancy","meta_tumor","aids","eGFR30","hd","hcc","alcohol","past_rupture","antiplate","anticoag","antithro","nsaids","steroid","beta", "vaso","ffp","pc", "albner","shock","hosp_mortality", "cohort")
# Create your table
df %>%
select(c(col_continuous, col_factors)) %>%
CreateTableOne(vars = c(col_continuous, col_factors), strata="cohort",factorVars = col_factors, addOverall = T) -> tableone
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(col_continuous)
##
## # Now:
## data %>% select(all_of(col_continuous))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(col_factors)
##
## # Now:
## data %>% select(all_of(col_factors))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Print your table
print(tableone, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by cohort
## Overall develop validation
## n 980 536 444
## age (mean (SD)) 60.86 (13.01) 61.23 (13.06) 60.42 (12.96)
## bmi (mean (SD)) 23.61 (11.49) 22.91 (3.73) 24.38 (16.12)
## smoke (mean (SD)) 265.31 (483.85) 299.62 (571.82) 226.73 (356.99)
## child_num (mean (SD)) 8.59 (2.12) 8.77 (2.13) 8.38 (2.09)
## gcs (mean (SD)) 14.46 (1.87) 14.33 (2.20) 14.61 (1.34)
## cci_num (mean (SD)) 4.47 (1.32) 4.44 (1.20) 4.50 (1.45)
## map (mean (SD)) 3.37 (3.96) 3.49 (4.51) 3.21 (3.18)
## bt (mean (SD)) 36.73 (0.72) 36.65 (0.76) 36.81 (0.65)
## sBP (mean (SD)) 88.55 (16.32) 87.35 (15.48) 89.95 (17.16)
## dBP (mean (SD)) 52.78 (12.72) 51.00 (11.90) 54.84 (13.33)
## hr (mean (SD)) 86.90 (21.06) 85.58 (21.10) 88.43 (20.93)
## bil (mean (SD)) 2.30 (2.19) 2.20 (2.08) 2.42 (2.32)
## ast (mean (SD)) 83.87 (100.75) 85.41 (92.54) 82.05 (109.78)
## alt (mean (SD)) 41.79 (46.84) 43.36 (50.96) 39.93 (41.41)
## wbc (mean (SD)) 8676.10 (4747.62) 8348.30 (4401.79) 9068.42 (5108.48)
## hb (mean (SD)) 8.72 (2.49) 8.55 (2.46) 8.92 (2.51)
## plt (mean (SD)) 113.92 (66.44) 110.70 (57.80) 117.76 (75.39)
## tp (mean (SD)) 6.11 (0.92) 6.09 (0.93) 6.13 (0.92)
## alb (mean (SD)) 2.85 (0.61) 2.82 (0.59) 2.90 (0.64)
## eGFR (mean (SD)) 69.80 (31.04) 69.15 (30.82) 70.59 (31.31)
## bun (mean (SD)) 28.52 (17.92) 28.41 (18.64) 28.64 (17.04)
## cre (mean (SD)) 1.06 (0.90) 1.07 (0.92) 1.05 (0.89)
## crp (mean (SD)) 0.84 (1.76) 0.81 (1.67) 0.87 (1.86)
## pt (mean (SD)) 54.98 (17.67) 51.73 (16.99) 58.78 (17.72)
## aptt (mean (SD)) 34.08 (17.48) 32.43 (17.30) 36.06 (17.52)
## los (mean (SD)) 12.37 (14.69) 13.77 (15.28) 10.67 (13.77)
## meld (mean (SD)) 11.91 (6.07) 12.13 (6.16) 11.66 (5.97)
## sex = F (%) 246 ( 25.1) 131 ( 24.4) 115 ( 25.9)
## barthel (%)
## 0 313 ( 38.4) 142 ( 35.9) 171 ( 40.7)
## 1 249 ( 30.5) 118 ( 29.8) 131 ( 31.2)
## 2 254 ( 31.1) 136 ( 34.3) 118 ( 28.1)
## child_score (%)
## 0 149 ( 16.9) 66 ( 13.9) 83 ( 20.3)
## 1 437 ( 49.5) 231 ( 48.7) 206 ( 50.4)
## 2 297 ( 33.6) 177 ( 37.3) 120 ( 29.3)
## pad = 1 (%) 2 ( 0.2) 1 ( 0.2) 1 ( 0.2)
## stroke = 1 (%) 21 ( 2.1) 10 ( 1.9) 11 ( 2.5)
## dimentia = 1 (%) 10 ( 1.0) 4 ( 0.7) 6 ( 1.4)
## ch_lung = 1 (%) 15 ( 1.5) 11 ( 2.1) 4 ( 0.9)
## rheumati = 1 (%) 3 ( 0.3) 3 ( 0.6) 0 ( 0.0)
## pept_ulcer = 1 (%) 101 ( 10.3) 59 ( 11.0) 42 ( 9.5)
## dm = 1 (%) 210 ( 21.4) 106 ( 19.8) 104 ( 23.4)
## dm_compli = 1 (%) 13 ( 1.3) 6 ( 1.1) 7 ( 1.6)
## paralysis = 0 (%) 980 (100.0) 536 (100.0) 444 (100.0)
## malignancy = 1 (%) 115 ( 11.7) 58 ( 10.8) 57 ( 12.8)
## meta_tumor = 1 (%) 17 ( 1.7) 6 ( 1.1) 11 ( 2.5)
## aids = 0 (%) 980 (100.0) 536 (100.0) 444 (100.0)
## eGFR30 = 1 (%) 87 ( 9.1) 51 ( 9.8) 36 ( 8.2)
## hd = 1 (%) 13 ( 1.3) 3 ( 0.6) 10 ( 2.3)
## hcc = 1 (%) 175 ( 17.9) 111 ( 20.7) 64 ( 14.4)
## alcohol = 1 (%) 472 ( 48.2) 231 ( 43.1) 241 ( 54.3)
## past_rupture = 1 (%) 225 ( 23.0) 104 ( 19.4) 121 ( 27.3)
## antiplate = 1 (%) 7 ( 0.7) 4 ( 0.7) 3 ( 0.7)
## anticoag = 1 (%) 4 ( 0.4) 1 ( 0.2) 3 ( 0.7)
## antithro = 1 (%) 10 ( 1.0) 4 ( 0.7) 6 ( 1.4)
## nsaids = 1 (%) 9 ( 0.9) 5 ( 0.9) 4 ( 0.9)
## steroid = 1 (%) 5 ( 0.5) 2 ( 0.4) 3 ( 0.7)
## beta = 1 (%) 58 ( 5.9) 18 ( 3.4) 40 ( 9.0)
## vaso = 1 (%) 58 ( 5.9) 31 ( 5.8) 27 ( 6.1)
## ffp = 1 (%) 291 ( 29.7) 137 ( 25.6) 154 ( 34.7)
## pc = 1 (%) 17 ( 1.7) 6 ( 1.1) 11 ( 2.5)
## albner = 1 (%) 80 ( 8.2) 47 ( 8.8) 33 ( 7.4)
## shock = 1 (%) 409 ( 43.0) 215 ( 42.0) 194 ( 44.1)
## hosp_mortality = 1 (%) 118 ( 12.0) 73 ( 13.6) 45 ( 10.1)
## cohort = validation (%) 444 ( 45.3) 0 ( 0.0) 444 (100.0)
## Stratified by cohort
## p test SMD Missing
## n
## age (mean (SD)) 0.336 0.062 0.0
## bmi (mean (SD)) 0.060 0.126 11.7
## smoke (mean (SD)) 0.028 0.153 12.9
## child_num (mean (SD)) 0.007 0.186 13.2
## gcs (mean (SD)) 0.023 0.149 0.0
## cci_num (mean (SD)) 0.476 0.045 0.0
## map (mean (SD)) 0.273 0.071 0.0
## bt (mean (SD)) 0.001 0.224 3.8
## sBP (mean (SD)) 0.014 0.160 2.3
## dBP (mean (SD)) <0.001 0.304 2.3
## hr (mean (SD)) 0.038 0.135 2.9
## bil (mean (SD)) 0.135 0.097 3.8
## ast (mean (SD)) 0.608 0.033 2.6
## alt (mean (SD)) 0.261 0.074 2.6
## wbc (mean (SD)) 0.019 0.151 2.0
## hb (mean (SD)) 0.022 0.148 2.0
## plt (mean (SD)) 0.101 0.105 2.0
## tp (mean (SD)) 0.517 0.043 7.9
## alb (mean (SD)) 0.042 0.133 4.7
## eGFR (mean (SD)) 0.474 0.046 2.1
## bun (mean (SD)) 0.844 0.013 2.1
## cre (mean (SD)) 0.820 0.015 2.9
## crp (mean (SD)) 0.632 0.031 5.3
## pt (mean (SD)) <0.001 0.407 6.0
## aptt (mean (SD)) 0.002 0.208 11.4
## los (mean (SD)) 0.001 0.213 0.0
## meld (mean (SD)) 0.251 0.077 8.2
## sex = F (%) 0.652 0.034 0.0
## barthel (%) 0.140 0.139 16.7
## 0
## 1
## 2
## child_score (%) 0.008 0.210 9.9
## 0
## 1
## 2
## pad = 1 (%) 1.000 0.009 0.0
## stroke = 1 (%) 0.662 0.042 0.0
## dimentia = 1 (%) 0.536 0.059 0.0
## ch_lung = 1 (%) 0.230 0.096 0.0
## rheumati = 1 (%) 0.318 0.106 0.0
## pept_ulcer = 1 (%) 0.492 0.051 0.0
## dm = 1 (%) 0.191 0.089 0.0
## dm_compli = 1 (%) 0.732 0.040 0.0
## paralysis = 0 (%) NA <0.001 0.0
## malignancy = 1 (%) 0.381 0.062 0.0
## meta_tumor = 1 (%) 0.169 0.102 0.0
## aids = 0 (%) NA <0.001 0.0
## eGFR30 = 1 (%) 0.478 0.054 2.1
## hd = 1 (%) 0.043 0.144 0.0
## hcc = 1 (%) 0.013 0.166 0.0
## alcohol = 1 (%) 0.001 0.225 0.0
## past_rupture = 1 (%) 0.005 0.186 0.0
## antiplate = 1 (%) 1.000 0.008 0.0
## anticoag = 1 (%) 0.489 0.075 0.0
## antithro = 1 (%) 0.536 0.059 0.0
## nsaids = 1 (%) 1.000 0.003 0.0
## steroid = 1 (%) 0.833 0.042 0.0
## beta = 1 (%) <0.001 0.236 0.0
## vaso = 1 (%) 0.952 0.013 0.0
## ffp = 1 (%) 0.002 0.200 0.0
## pc = 1 (%) 0.169 0.102 0.0
## albner = 1 (%) 0.520 0.049 0.0
## shock = 1 (%) 0.558 0.042 2.9
## hosp_mortality = 1 (%) 0.116 0.108 0.0
## cohort = validation (%) <0.001 NaN 0.0
# specify your data and variables
tbl_summary(data = df,
by = "cohort",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | develop, N = 5361 | validation, N = 4441 |
|---|---|---|
| hosp_id | 1,011 (1,004.00, 1,024) | 1,022 (1,006.00, 1,024) |
| pt_id | 372 (177.75, 589) | 492 (244.75, 643) |
| hosp_num | ||
| 1 | 472 (88%) | 365 (82%) |
| 2 | 48 (9.0%) | 50 (11%) |
| 3 | 15 (2.8%) | 13 (2.9%) |
| 4 | 1 (0.2%) | 10 (2.3%) |
| 5 | 0 (0%) | 4 (0.9%) |
| 6 | 0 (0%) | 2 (0.5%) |
| year | ||
| 2010 | 76 (14%) | 0 (0%) |
| 2011 | 79 (15%) | 0 (0%) |
| 2012 | 88 (16%) | 0 (0%) |
| 2013 | 70 (13%) | 0 (0%) |
| 2014 | 77 (14%) | 0 (0%) |
| 2015 | 72 (13%) | 0 (0%) |
| 2016 | 74 (14%) | 0 (0%) |
| 2017 | 0 (0%) | 64 (14%) |
| 2018 | 0 (0%) | 62 (14%) |
| 2019 | 0 (0%) | 72 (16%) |
| 2020 | 0 (0%) | 82 (18%) |
| 2021 | 0 (0%) | 83 (19%) |
| 2022 | 0 (0%) | 81 (18%) |
| age | 62 (51.75, 70) | 60 (50.00, 70) |
| sex | ||
| M | 405 (76%) | 329 (74%) |
| F | 131 (24%) | 115 (26%) |
| bmi | 23 (20.32, 25) | 23 (20.59, 26) |
| Unknown | 85 | 30 |
| smoke | 20 (0.00, 440) | 0 (0.00, 360) |
| Unknown | 84 | 42 |
| barthel | ||
| 0 | 142 (36%) | 171 (41%) |
| 1 | 118 (30%) | 131 (31%) |
| 2 | 136 (34%) | 118 (28%) |
| Unknown | 140 | 24 |
| child_num | 8 (7.00, 10) | 8 (7.00, 10) |
| Unknown | 81 | 48 |
| child_score | ||
| 0 | 66 (14%) | 83 (20%) |
| 1 | 231 (49%) | 206 (50%) |
| 2 | 177 (37%) | 120 (29%) |
| Unknown | 62 | 35 |
| gcs | 15 (15.00, 15) | 15 (15.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| pad | ||
| 0 | 535 (100%) | 443 (100%) |
| 1 | 1 (0.2%) | 1 (0.2%) |
| stroke | ||
| 0 | 526 (98%) | 433 (98%) |
| 1 | 10 (1.9%) | 11 (2.5%) |
| dimentia | ||
| 0 | 532 (99%) | 438 (99%) |
| 1 | 4 (0.7%) | 6 (1.4%) |
| ch_lung | ||
| 0 | 525 (98%) | 440 (99%) |
| 1 | 11 (2.1%) | 4 (0.9%) |
| rheumati | ||
| 0 | 533 (99%) | 444 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| pept_ulcer | ||
| 0 | 477 (89%) | 402 (91%) |
| 1 | 59 (11%) | 42 (9.5%) |
| dm | ||
| 0 | 430 (80%) | 340 (77%) |
| 1 | 106 (20%) | 104 (23%) |
| dm_compli | ||
| 0 | 530 (99%) | 437 (98%) |
| 1 | 6 (1.1%) | 7 (1.6%) |
| paralysis | ||
| 0 | 536 (100%) | 444 (100%) |
| malignancy | ||
| 0 | 478 (89%) | 387 (87%) |
| 1 | 58 (11%) | 57 (13%) |
| meta_tumor | ||
| 0 | 530 (99%) | 433 (98%) |
| 1 | 6 (1.1%) | 11 (2.5%) |
| aids | ||
| 0 | 536 (100%) | 444 (100%) |
| eGFR30 | ||
| 0 | 471 (90%) | 401 (92%) |
| 1 | 51 (9.8%) | 36 (8.2%) |
| Unknown | 14 | 7 |
| hd | ||
| 0 | 533 (99%) | 434 (98%) |
| 1 | 3 (0.6%) | 10 (2.3%) |
| hcc | ||
| 0 | 425 (79%) | 380 (86%) |
| 1 | 111 (21%) | 64 (14%) |
| alcohol | ||
| 0 | 305 (57%) | 203 (46%) |
| 1 | 231 (43%) | 241 (54%) |
| past_rupture | ||
| 0 | 432 (81%) | 323 (73%) |
| 1 | 104 (19%) | 121 (27%) |
| antiplate | ||
| 0 | 532 (99%) | 441 (99%) |
| 1 | 4 (0.7%) | 3 (0.7%) |
| anticoag | ||
| 0 | 535 (100%) | 441 (99%) |
| 1 | 1 (0.2%) | 3 (0.7%) |
| antithro | ||
| 0 | 532 (99%) | 438 (99%) |
| 1 | 4 (0.7%) | 6 (1.4%) |
| nsaids | ||
| 0 | 531 (99%) | 440 (99%) |
| 1 | 5 (0.9%) | 4 (0.9%) |
| steroid | ||
| 0 | 534 (100%) | 441 (99%) |
| 1 | 2 (0.4%) | 3 (0.7%) |
| beta | ||
| 0 | 518 (97%) | 404 (91%) |
| 1 | 18 (3.4%) | 40 (9.0%) |
| vaso | ||
| 0 | 505 (94%) | 417 (94%) |
| 1 | 31 (5.8%) | 27 (6.1%) |
| map | 4 (0.00, 4) | 4 (0.00, 4) |
| ffp | ||
| 0 | 399 (74%) | 290 (65%) |
| 1 | 137 (26%) | 154 (35%) |
| pc | ||
| 0 | 530 (99%) | 433 (98%) |
| 1 | 6 (1.1%) | 11 (2.5%) |
| albner | ||
| 0 | 489 (91%) | 411 (93%) |
| 1 | 47 (8.8%) | 33 (7.4%) |
| bt | 37 (36.30, 37) | 37 (36.50, 37) |
| Unknown | 32 | 5 |
| sBP | 89 (79.00, 96) | 91 (80.00, 100) |
| Unknown | 22 | 1 |
| dBP | 51 (44.00, 58) | 54 (46.00, 63) |
| Unknown | 22 | 1 |
| hr | 82 (70.00, 98) | 85 (73.00, 101) |
| Unknown | 24 | 4 |
| shock | ||
| 0 | 297 (58%) | 246 (56%) |
| 1 | 215 (42%) | 194 (44%) |
| Unknown | 24 | 4 |
| bil | 1 (0.90, 3) | 2 (1.00, 3) |
| Unknown | 28 | 9 |
| ast | 56 (33.00, 96) | 49 (32.00, 89) |
| Unknown | 18 | 7 |
| alt | 29 (20.00, 47) | 29 (19.00, 44) |
| Unknown | 18 | 7 |
| wbc | 7,330 (5,315.00, 10,395) | 8,300 (5,800.00, 11,100) |
| Unknown | 13 | 7 |
| hb | 8 (6.90, 10) | 9 (7.20, 10) |
| Unknown | 13 | 7 |
| plt | 97 (72.00, 135) | 103 (75.00, 141) |
| Unknown | 13 | 7 |
| tp | 6 (5.50, 7) | 6 (5.50, 7) |
| Unknown | 45 | 32 |
| alb | 3 (2.50, 3) | 3 (2.50, 3) |
| Unknown | 34 | 12 |
| eGFR | 67 (48.25, 89) | 68 (49.43, 89) |
| Unknown | 14 | 7 |
| bun | 23 (15.85, 36) | 25 (16.60, 36) |
| Unknown | 14 | 7 |
| cre | 1 (0.67, 1) | 1 (0.65, 1) |
| Unknown | 18 | 10 |
| crp | 0 (0.11, 1) | 0 (0.12, 1) |
| Unknown | 37 | 15 |
| pt | 51 (40.00, 63) | 59 (46.00, 72) |
| Unknown | 39 | 20 |
| aptt | 29 (25.90, 33) | 32 (29.65, 37) |
| Unknown | 63 | 49 |
| meld | 11 (7.00, 15) | 10 (6.00, 15) |
| Unknown | 54 | 26 |
| hosp_mortality | 73 (14%) | 45 (10%) |
| los | 10 (6.00, 18) | 7 (5.00, 13) |
| 1 Median (IQR); n (%) | ||
df |> #全体
select(col_continuous) |>
pivot_longer(cols = col_continuous, names_to = "name", values_to = "value") |>
ggplot()+
geom_histogram(aes(x = value), color = "black")+
facet_wrap(~ name, scales = "free", ncol = 5) +
theme_bw()+
theme(text = element_text(size = 12))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1124 rows containing non-finite values (`stat_bin()`).
col_cont = c("age", "bmi","smoke","child_num","gcs","cci_num","map","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt","los","meld")
col_fact = c("sex","barthel","child_score","pad","stroke","dimentia","ch_lung","rheumati","pept_ulcer","dm","dm_compli","paralysis","malignancy","meta_tumor","aids","eGFR30","hd","hcc","alcohol","past_rupture","antiplate","anticoag","antithro","nsaids","steroid","beta", "vaso","ffp","pc", "albner","shock","hosp_mortality")
# Create your table
df_dev %>%
select(c(col_cont, col_fact)) %>%
CreateTableOne(vars = c(col_cont, col_fact), strata="hosp_mortality",factorVars = col_fact, addOverall = T) -> tableone_dev
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(col_cont)
##
## # Now:
## data %>% select(all_of(col_cont))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(col_fact)
##
## # Now:
## data %>% select(all_of(col_fact))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Print your table
print(tableone_dev, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by hosp_mortality
## Overall 0 1
## n 536 463 73
## age (mean (SD)) 61.23 (13.06) 60.82 (13.02) 63.84 (13.09)
## bmi (mean (SD)) 22.91 (3.73) 23.02 (3.76) 22.17 (3.41)
## smoke (mean (SD)) 299.62 (571.82) 283.65 (394.78) 406.02 (1214.88)
## child_num (mean (SD)) 8.77 (2.13) 8.47 (1.95) 10.91 (2.13)
## gcs (mean (SD)) 14.33 (2.20) 14.72 (1.27) 11.90 (4.33)
## cci_num (mean (SD)) 4.44 (1.20) 4.43 (1.08) 4.53 (1.78)
## map (mean (SD)) 3.49 (4.51) 3.10 (4.35) 5.96 (4.71)
## bt (mean (SD)) 36.65 (0.76) 36.68 (0.67) 36.48 (1.24)
## sBP (mean (SD)) 87.35 (15.48) 90.12 (13.62) 69.74 (15.05)
## dBP (mean (SD)) 51.00 (11.90) 52.83 (11.00) 39.39 (10.83)
## hr (mean (SD)) 85.58 (21.10) 83.17 (19.18) 100.84 (25.93)
## bil (mean (SD)) 2.20 (2.08) 1.97 (1.80) 3.69 (2.92)
## ast (mean (SD)) 85.41 (92.54) 79.65 (88.38) 121.08 (109.08)
## alt (mean (SD)) 43.36 (50.96) 41.65 (50.23) 53.94 (54.43)
## wbc (mean (SD)) 8348.30 (4401.79) 8193.93 (4211.45) 9299.86 (5366.73)
## hb (mean (SD)) 8.55 (2.46) 8.62 (2.47) 8.11 (2.38)
## plt (mean (SD)) 110.70 (57.80) 109.10 (52.04) 120.60 (84.92)
## tp (mean (SD)) 6.09 (0.93) 6.15 (0.86) 5.75 (1.21)
## alb (mean (SD)) 2.82 (0.59) 2.90 (0.54) 2.30 (0.62)
## eGFR (mean (SD)) 69.15 (30.82) 72.85 (30.55) 46.36 (21.32)
## bun (mean (SD)) 28.41 (18.64) 27.53 (17.80) 33.94 (22.59)
## cre (mean (SD)) 1.07 (0.92) 1.00 (0.92) 1.46 (0.82)
## crp (mean (SD)) 0.81 (1.67) 0.71 (1.59) 1.46 (1.96)
## pt (mean (SD)) 51.73 (16.99) 53.40 (16.04) 41.66 (19.06)
## aptt (mean (SD)) 32.43 (17.30) 30.76 (12.33) 42.18 (32.59)
## los (mean (SD)) 13.77 (15.28) 14.21 (14.24) 11.01 (20.59)
## meld (mean (SD)) 12.13 (6.16) 11.04 (4.91) 18.84 (8.52)
## sex = F (%) 131 ( 24.4) 111 ( 24.0) 20 ( 27.4)
## barthel (%)
## 0 142 ( 35.9) 136 ( 39.8) 6 ( 11.1)
## 1 118 ( 29.8) 108 ( 31.6) 10 ( 18.5)
## 2 136 ( 34.3) 98 ( 28.7) 38 ( 70.4)
## child_score (%)
## 0 66 ( 13.9) 65 ( 15.9) 1 ( 1.5)
## 1 231 ( 48.7) 217 ( 53.1) 14 ( 21.5)
## 2 177 ( 37.3) 127 ( 31.1) 50 ( 76.9)
## pad = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0)
## stroke = 1 (%) 10 ( 1.9) 10 ( 2.2) 0 ( 0.0)
## dimentia = 1 (%) 4 ( 0.7) 4 ( 0.9) 0 ( 0.0)
## ch_lung = 1 (%) 11 ( 2.1) 9 ( 1.9) 2 ( 2.7)
## rheumati = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0)
## pept_ulcer = 1 (%) 59 ( 11.0) 58 ( 12.5) 1 ( 1.4)
## dm = 1 (%) 106 ( 19.8) 98 ( 21.2) 8 ( 11.0)
## dm_compli = 1 (%) 6 ( 1.1) 6 ( 1.3) 0 ( 0.0)
## paralysis = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0)
## malignancy = 1 (%) 58 ( 10.8) 46 ( 9.9) 12 ( 16.4)
## meta_tumor = 1 (%) 6 ( 1.1) 2 ( 0.4) 4 ( 5.5)
## aids = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0)
## eGFR30 = 1 (%) 51 ( 9.8) 34 ( 7.6) 17 ( 23.3)
## hd = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0)
## hcc = 1 (%) 111 ( 20.7) 95 ( 20.5) 16 ( 21.9)
## alcohol = 1 (%) 231 ( 43.1) 205 ( 44.3) 26 ( 35.6)
## past_rupture = 1 (%) 104 ( 19.4) 96 ( 20.7) 8 ( 11.0)
## antiplate = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4)
## anticoag = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0)
## antithro = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4)
## nsaids = 1 (%) 5 ( 0.9) 5 ( 1.1) 0 ( 0.0)
## steroid = 1 (%) 2 ( 0.4) 1 ( 0.2) 1 ( 1.4)
## beta = 1 (%) 18 ( 3.4) 18 ( 3.9) 0 ( 0.0)
## vaso = 1 (%) 31 ( 5.8) 11 ( 2.4) 20 ( 27.4)
## ffp = 1 (%) 137 ( 25.6) 100 ( 21.6) 37 ( 50.7)
## pc = 1 (%) 6 ( 1.1) 3 ( 0.6) 3 ( 4.1)
## albner = 1 (%) 47 ( 8.8) 32 ( 6.9) 15 ( 20.5)
## shock = 1 (%) 215 ( 42.0) 155 ( 35.1) 60 ( 85.7)
## hosp_mortality = 1 (%) 73 ( 13.6) 0 ( 0.0) 73 (100.0)
## Stratified by hosp_mortality
## p test SMD Missing
## n
## age (mean (SD)) 0.066 0.231 0.0
## bmi (mean (SD)) 0.108 0.236 15.9
## smoke (mean (SD)) 0.125 0.135 15.7
## child_num (mean (SD)) <0.001 1.191 15.1
## gcs (mean (SD)) <0.001 0.882 0.0
## cci_num (mean (SD)) 0.490 0.071 0.0
## map (mean (SD)) <0.001 0.630 0.0
## bt (mean (SD)) 0.056 0.197 6.0
## sBP (mean (SD)) <0.001 1.420 4.1
## dBP (mean (SD)) <0.001 1.231 4.1
## hr (mean (SD)) <0.001 0.775 4.5
## bil (mean (SD)) <0.001 0.708 5.2
## ast (mean (SD)) <0.001 0.417 3.4
## alt (mean (SD)) 0.057 0.235 3.4
## wbc (mean (SD)) 0.046 0.229 2.4
## hb (mean (SD)) 0.099 0.211 2.4
## plt (mean (SD)) 0.115 0.163 2.4
## tp (mean (SD)) 0.001 0.381 8.4
## alb (mean (SD)) <0.001 1.019 6.3
## eGFR (mean (SD)) <0.001 1.006 2.6
## bun (mean (SD)) 0.007 0.316 2.6
## cre (mean (SD)) <0.001 0.533 3.4
## crp (mean (SD)) <0.001 0.421 6.9
## pt (mean (SD)) <0.001 0.667 7.3
## aptt (mean (SD)) <0.001 0.463 11.8
## los (mean (SD)) 0.097 0.180 0.0
## meld (mean (SD)) <0.001 1.121 10.1
## sex = F (%) 0.627 0.078 0.0
## barthel (%) <0.001 0.955 26.1
## 0
## 1
## 2
## child_score (%) <0.001 1.072 11.6
## 0
## 1
## 2
## pad = 1 (%) 1.000 0.066 0.0
## stroke = 1 (%) 0.422 0.210 0.0
## dimentia = 1 (%) 0.948 0.132 0.0
## ch_lung = 1 (%) 0.999 0.053 0.0
## rheumati = 1 (%) 1.000 0.114 0.0
## pept_ulcer = 1 (%) 0.009 0.450 0.0
## dm = 1 (%) 0.061 0.281 0.0
## dm_compli = 1 (%) 0.704 0.162 0.0
## paralysis = 0 (%) NA <0.001 0.0
## malignancy = 1 (%) 0.144 0.193 0.0
## meta_tumor = 1 (%) 0.001 0.301 0.0
## aids = 0 (%) NA <0.001 0.0
## eGFR30 = 1 (%) <0.001 0.446 2.6
## hd = 1 (%) 1.000 0.114 0.0
## hcc = 1 (%) 0.905 0.034 0.0
## alcohol = 1 (%) 0.207 0.178 0.0
## past_rupture = 1 (%) 0.071 0.270 0.0
## antiplate = 1 (%) 1.000 0.072 0.0
## anticoag = 1 (%) 1.000 0.066 0.0
## antithro = 1 (%) 1.000 0.072 0.0
## nsaids = 1 (%) 0.813 0.148 0.0
## steroid = 1 (%) 0.638 0.130 0.0
## beta = 1 (%) 0.173 0.284 0.0
## vaso = 1 (%) <0.001 0.751 0.0
## ffp = 1 (%) <0.001 0.635 0.0
## pc = 1 (%) 0.044 0.229 0.0
## albner = 1 (%) <0.001 0.404 0.0
## shock = 1 (%) <0.001 1.210 4.5
## hosp_mortality = 1 (%) <0.001 NaN 0.0
# specify your data and variables
tbl_summary(data = df_dev,
by = "hosp_mortality",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | 0, N = 4631 | 1, N = 731 |
|---|---|---|
| hosp_id | 1,010 (1,003.00, 1,024) | 1,017 (1,005.00, 1,024) |
| pt_id | 359 (149.50, 583) | 426 (235.00, 599) |
| hosp_num | ||
| 1 | 404 (87%) | 68 (93%) |
| 2 | 43 (9.3%) | 5 (6.8%) |
| 3 | 15 (3.2%) | 0 (0%) |
| 4 | 1 (0.2%) | 0 (0%) |
| year | ||
| 2010 | 68 (15%) | 8 (11%) |
| 2011 | 70 (15%) | 9 (12%) |
| 2012 | 72 (16%) | 16 (22%) |
| 2013 | 55 (12%) | 15 (21%) |
| 2014 | 69 (15%) | 8 (11%) |
| 2015 | 67 (14%) | 5 (6.8%) |
| 2016 | 62 (13%) | 12 (16%) |
| age | 62 (51.00, 70) | 66 (55.00, 74) |
| sex | ||
| M | 352 (76%) | 53 (73%) |
| F | 111 (24%) | 20 (27%) |
| bmi | 23 (20.39, 25) | 22 (20.15, 24) |
| Unknown | 69 | 16 |
| smoke | 60 (0.00, 440) | 0 (0.00, 400) |
| Unknown | 70 | 14 |
| barthel | ||
| 0 | 136 (40%) | 6 (11%) |
| 1 | 108 (32%) | 10 (19%) |
| 2 | 98 (29%) | 38 (70%) |
| Unknown | 121 | 19 |
| child_num | 8 (7.00, 10) | 11 (9.00, 12) |
| Unknown | 64 | 17 |
| child_score | ||
| 0 | 65 (16%) | 1 (1.5%) |
| 1 | 217 (53%) | 14 (22%) |
| 2 | 127 (31%) | 50 (77%) |
| Unknown | 54 | 8 |
| gcs | 15 (15.00, 15) | 15 (9.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| pad | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| stroke | ||
| 0 | 453 (98%) | 73 (100%) |
| 1 | 10 (2.2%) | 0 (0%) |
| dimentia | ||
| 0 | 459 (99%) | 73 (100%) |
| 1 | 4 (0.9%) | 0 (0%) |
| ch_lung | ||
| 0 | 454 (98%) | 71 (97%) |
| 1 | 9 (1.9%) | 2 (2.7%) |
| rheumati | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| pept_ulcer | ||
| 0 | 405 (87%) | 72 (99%) |
| 1 | 58 (13%) | 1 (1.4%) |
| dm | ||
| 0 | 365 (79%) | 65 (89%) |
| 1 | 98 (21%) | 8 (11%) |
| dm_compli | ||
| 0 | 457 (99%) | 73 (100%) |
| 1 | 6 (1.3%) | 0 (0%) |
| paralysis | ||
| 0 | 463 (100%) | 73 (100%) |
| malignancy | ||
| 0 | 417 (90%) | 61 (84%) |
| 1 | 46 (9.9%) | 12 (16%) |
| meta_tumor | ||
| 0 | 461 (100%) | 69 (95%) |
| 1 | 2 (0.4%) | 4 (5.5%) |
| aids | ||
| 0 | 463 (100%) | 73 (100%) |
| eGFR30 | ||
| 0 | 415 (92%) | 56 (77%) |
| 1 | 34 (7.6%) | 17 (23%) |
| Unknown | 14 | 0 |
| hd | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| hcc | ||
| 0 | 368 (79%) | 57 (78%) |
| 1 | 95 (21%) | 16 (22%) |
| alcohol | ||
| 0 | 258 (56%) | 47 (64%) |
| 1 | 205 (44%) | 26 (36%) |
| past_rupture | ||
| 0 | 367 (79%) | 65 (89%) |
| 1 | 96 (21%) | 8 (11%) |
| antiplate | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| anticoag | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| antithro | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| nsaids | ||
| 0 | 458 (99%) | 73 (100%) |
| 1 | 5 (1.1%) | 0 (0%) |
| steroid | ||
| 0 | 462 (100%) | 72 (99%) |
| 1 | 1 (0.2%) | 1 (1.4%) |
| beta | ||
| 0 | 445 (96%) | 73 (100%) |
| 1 | 18 (3.9%) | 0 (0%) |
| vaso | ||
| 0 | 452 (98%) | 53 (73%) |
| 1 | 11 (2.4%) | 20 (27%) |
| map | 4 (0.00, 4) | 6 (4.00, 8) |
| ffp | ||
| 0 | 363 (78%) | 36 (49%) |
| 1 | 100 (22%) | 37 (51%) |
| pc | ||
| 0 | 460 (99%) | 70 (96%) |
| 1 | 3 (0.6%) | 3 (4.1%) |
| albner | ||
| 0 | 431 (93%) | 58 (79%) |
| 1 | 32 (6.9%) | 15 (21%) |
| bt | 37 (36.30, 37) | 36 (36.00, 37) |
| Unknown | 22 | 10 |
| sBP | 90 (82.00, 98) | 64 (59.00, 79) |
| Unknown | 19 | 3 |
| dBP | 52 (46.00, 60) | 39 (33.00, 46) |
| Unknown | 19 | 3 |
| hr | 80 (70.00, 94) | 101 (89.00, 112) |
| Unknown | 21 | 3 |
| shock | ||
| 0 | 287 (65%) | 10 (14%) |
| 1 | 155 (35%) | 60 (86%) |
| Unknown | 21 | 3 |
| bil | 1 (0.90, 2) | 3 (1.53, 5) |
| Unknown | 24 | 4 |
| ast | 53 (32.00, 92) | 82 (48.75, 153) |
| Unknown | 17 | 1 |
| alt | 28 (20.00, 44) | 33 (25.00, 63) |
| Unknown | 17 | 1 |
| wbc | 7,215 (5,300.00, 10,300) | 7,990 (6,200.00, 10,800) |
| Unknown | 13 | 0 |
| hb | 8 (7.00, 10) | 8 (6.60, 10) |
| Unknown | 13 | 0 |
| plt | 97 (72.00, 135) | 98 (76.00, 130) |
| Unknown | 13 | 0 |
| tp | 6 (5.50, 7) | 6 (5.10, 6) |
| Unknown | 37 | 8 |
| alb | 3 (2.58, 3) | 2 (1.80, 3) |
| Unknown | 31 | 3 |
| eGFR | 71 (52.10, 92) | 44 (30.40, 58) |
| Unknown | 14 | 0 |
| bun | 23 (15.25, 35) | 28 (17.98, 45) |
| Unknown | 13 | 1 |
| cre | 1 (0.65, 1) | 1 (0.99, 2) |
| Unknown | 18 | 0 |
| crp | 0 (0.10, 1) | 1 (0.37, 2) |
| Unknown | 33 | 4 |
| pt | 53 (42.00, 64) | 40 (26.90, 56) |
| Unknown | 37 | 2 |
| aptt | 28 (25.40, 33) | 32 (29.10, 44) |
| Unknown | 59 | 4 |
| meld | 10 (7.00, 14) | 16 (13.00, 24) |
| Unknown | 48 | 6 |
| los | 10 (7.00, 18) | 4 (1.00, 16) |
| cohort | ||
| develop | 463 (100%) | 73 (100%) |
| validation | 0 (0%) | 0 (0%) |
| 1 Median (IQR); n (%) | ||
df_dev |> #全体
select(col_continuous) |>
pivot_longer(cols = col_continuous, names_to = "name", values_to = "value") |>
ggplot()+
geom_histogram(aes(x = value), color = "black")+
facet_wrap(~ name, scales = "free", ncol = 5) +
theme_bw()+
theme(text = element_text(size = 12))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 771 rows containing non-finite values (`stat_bin()`).
# Create your table
df_val %>%
select(c(col_cont, col_fact)) %>%
CreateTableOne(vars = c(col_cont, col_fact), strata="hosp_mortality",factorVars = col_fact, addOverall = T) -> tableone_val
# Print your table
print(tableone_val, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by hosp_mortality
## Overall 0 1
## n 444 399 45
## age (mean (SD)) 60.42 (12.96) 60.18 (13.03) 62.62 (12.19)
## bmi (mean (SD)) 24.38 (16.12) 24.46 (16.74) 23.43 (4.22)
## smoke (mean (SD)) 226.73 (356.99) 233.57 (364.62) 157.22 (261.19)
## child_num (mean (SD)) 8.38 (2.09) 8.13 (1.93) 10.52 (2.14)
## gcs (mean (SD)) 14.61 (1.34) 14.66 (1.24) 14.09 (1.94)
## cci_num (mean (SD)) 4.50 (1.45) 4.46 (1.36) 4.91 (2.11)
## map (mean (SD)) 3.21 (3.18) 2.88 (2.76) 6.13 (4.81)
## bt (mean (SD)) 36.81 (0.65) 36.81 (0.54) 36.84 (1.30)
## sBP (mean (SD)) 89.95 (17.16) 92.40 (15.70) 68.33 (14.21)
## dBP (mean (SD)) 54.84 (13.33) 56.33 (12.84) 41.69 (10.03)
## hr (mean (SD)) 88.43 (20.93) 86.76 (20.28) 103.84 (20.79)
## bil (mean (SD)) 2.42 (2.32) 2.18 (1.86) 4.54 (4.21)
## ast (mean (SD)) 82.05 (109.78) 72.39 (79.19) 168.27 (237.83)
## alt (mean (SD)) 39.93 (41.41) 36.47 (27.91) 70.91 (95.88)
## wbc (mean (SD)) 9068.42 (5108.48) 8834.15 (5148.20) 11160.91 (4243.62)
## hb (mean (SD)) 8.92 (2.51) 9.00 (2.55) 8.18 (1.96)
## plt (mean (SD)) 117.76 (75.39) 118.45 (77.27) 111.57 (56.24)
## tp (mean (SD)) 6.13 (0.92) 6.19 (0.90) 5.64 (1.03)
## alb (mean (SD)) 2.90 (0.64) 2.97 (0.61) 2.29 (0.54)
## eGFR (mean (SD)) 70.59 (31.31) 73.60 (30.92) 43.71 (20.02)
## bun (mean (SD)) 28.64 (17.04) 27.83 (16.43) 35.88 (20.60)
## cre (mean (SD)) 1.05 (0.89) 1.00 (0.87) 1.54 (0.88)
## crp (mean (SD)) 0.87 (1.86) 0.74 (1.64) 2.03 (3.01)
## pt (mean (SD)) 58.78 (17.72) 60.61 (16.94) 43.01 (16.65)
## aptt (mean (SD)) 36.06 (17.52) 34.27 (13.26) 51.43 (34.63)
## los (mean (SD)) 10.67 (13.77) 10.72 (13.83) 10.18 (13.38)
## meld (mean (SD)) 11.66 (5.97) 10.71 (4.98) 19.75 (7.47)
## sex = F (%) 115 ( 25.9) 103 ( 25.8) 12 ( 26.7)
## barthel (%)
## 0 171 ( 40.7) 167 ( 44.3) 4 ( 9.3)
## 1 131 ( 31.2) 120 ( 31.8) 11 ( 25.6)
## 2 118 ( 28.1) 90 ( 23.9) 28 ( 65.1)
## child_score (%)
## 0 83 ( 20.3) 81 ( 22.3) 2 ( 4.4)
## 1 206 ( 50.4) 193 ( 53.0) 13 ( 28.9)
## 2 120 ( 29.3) 90 ( 24.7) 30 ( 66.7)
## pad = 1 (%) 1 ( 0.2) 1 ( 0.3) 0 ( 0.0)
## stroke = 1 (%) 11 ( 2.5) 8 ( 2.0) 3 ( 6.7)
## dimentia = 1 (%) 6 ( 1.4) 5 ( 1.3) 1 ( 2.2)
## ch_lung = 1 (%) 4 ( 0.9) 3 ( 0.8) 1 ( 2.2)
## rheumati = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0)
## pept_ulcer = 1 (%) 42 ( 9.5) 40 ( 10.0) 2 ( 4.4)
## dm = 1 (%) 104 ( 23.4) 96 ( 24.1) 8 ( 17.8)
## dm_compli = 1 (%) 7 ( 1.6) 6 ( 1.5) 1 ( 2.2)
## paralysis = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0)
## malignancy = 1 (%) 57 ( 12.8) 50 ( 12.5) 7 ( 15.6)
## meta_tumor = 1 (%) 11 ( 2.5) 7 ( 1.8) 4 ( 8.9)
## aids = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0)
## eGFR30 = 1 (%) 36 ( 8.2) 22 ( 5.6) 14 ( 31.8)
## hd = 1 (%) 10 ( 2.3) 7 ( 1.8) 3 ( 6.7)
## hcc = 1 (%) 64 ( 14.4) 56 ( 14.0) 8 ( 17.8)
## alcohol = 1 (%) 241 ( 54.3) 212 ( 53.1) 29 ( 64.4)
## past_rupture = 1 (%) 121 ( 27.3) 115 ( 28.8) 6 ( 13.3)
## antiplate = 1 (%) 3 ( 0.7) 2 ( 0.5) 1 ( 2.2)
## anticoag = 1 (%) 3 ( 0.7) 3 ( 0.8) 0 ( 0.0)
## antithro = 1 (%) 6 ( 1.4) 5 ( 1.3) 1 ( 2.2)
## nsaids = 1 (%) 4 ( 0.9) 4 ( 1.0) 0 ( 0.0)
## steroid = 1 (%) 3 ( 0.7) 3 ( 0.8) 0 ( 0.0)
## beta = 1 (%) 40 ( 9.0) 40 ( 10.0) 0 ( 0.0)
## vaso = 1 (%) 27 ( 6.1) 18 ( 4.5) 9 ( 20.0)
## ffp = 1 (%) 154 ( 34.7) 126 ( 31.6) 28 ( 62.2)
## pc = 1 (%) 11 ( 2.5) 6 ( 1.5) 5 ( 11.1)
## albner = 1 (%) 33 ( 7.4) 26 ( 6.5) 7 ( 15.6)
## shock = 1 (%) 194 ( 44.1) 153 ( 38.5) 41 ( 95.3)
## hosp_mortality = 1 (%) 45 ( 10.1) 0 ( 0.0) 45 (100.0)
## Stratified by hosp_mortality
## p test SMD Missing
## n
## age (mean (SD)) 0.230 0.194 0.0
## bmi (mean (SD)) 0.730 0.084 6.8
## smoke (mean (SD)) 0.221 0.241 9.5
## child_num (mean (SD)) <0.001 1.174 10.8
## gcs (mean (SD)) 0.006 0.353 0.0
## cci_num (mean (SD)) 0.048 0.255 0.0
## map (mean (SD)) <0.001 0.828 0.0
## bt (mean (SD)) 0.785 0.029 1.1
## sBP (mean (SD)) <0.001 1.607 0.2
## dBP (mean (SD)) <0.001 1.271 0.2
## hr (mean (SD)) <0.001 0.832 0.9
## bil (mean (SD)) <0.001 0.724 2.0
## ast (mean (SD)) <0.001 0.541 1.6
## alt (mean (SD)) <0.001 0.488 1.6
## wbc (mean (SD)) 0.004 0.493 1.6
## hb (mean (SD)) 0.040 0.361 1.6
## plt (mean (SD)) 0.566 0.102 1.6
## tp (mean (SD)) <0.001 0.566 7.2
## alb (mean (SD)) <0.001 1.177 2.7
## eGFR (mean (SD)) <0.001 1.148 1.6
## bun (mean (SD)) 0.003 0.432 1.6
## cre (mean (SD)) <0.001 0.623 2.3
## crp (mean (SD)) <0.001 0.532 3.4
## pt (mean (SD)) <0.001 1.048 4.5
## aptt (mean (SD)) <0.001 0.654 11.0
## los (mean (SD)) 0.801 0.040 0.0
## meld (mean (SD)) <0.001 1.424 5.9
## sex = F (%) 1.000 0.019 0.0
## barthel (%) <0.001 1.041 5.4
## 0
## 1
## 2
## child_score (%) <0.001 0.972 7.9
## 0
## 1
## 2
## pad = 1 (%) 1.000 0.071 0.0
## stroke = 1 (%) 0.161 0.230 0.0
## dimentia = 1 (%) 1.000 0.074 0.0
## ch_lung = 1 (%) 0.875 0.122 0.0
## rheumati = 0 (%) NA <0.001 0.0
## pept_ulcer = 1 (%) 0.345 0.217 0.0
## dm = 1 (%) 0.449 0.155 0.0
## dm_compli = 1 (%) 1.000 0.053 0.0
## paralysis = 0 (%) NA <0.001 0.0
## malignancy = 1 (%) 0.734 0.087 0.0
## meta_tumor = 1 (%) 0.016 0.322 0.0
## aids = 0 (%) NA <0.001 0.0
## eGFR30 = 1 (%) <0.001 0.714 1.6
## hd = 1 (%) 0.115 0.246 0.0
## hcc = 1 (%) 0.650 0.102 0.0
## alcohol = 1 (%) 0.198 0.231 0.0
## past_rupture = 1 (%) 0.042 0.387 0.0
## antiplate = 1 (%) 0.707 0.149 0.0
## anticoag = 1 (%) 1.000 0.123 0.0
## antithro = 1 (%) 1.000 0.074 0.0
## nsaids = 1 (%) 1.000 0.142 0.0
## steroid = 1 (%) 1.000 0.123 0.0
## beta = 1 (%) 0.051 0.472 0.0
## vaso = 1 (%) <0.001 0.486 0.0
## ffp = 1 (%) <0.001 0.645 0.0
## pc = 1 (%) 0.001 0.403 0.0
## albner = 1 (%) 0.059 0.292 0.0
## shock = 1 (%) <0.001 1.515 0.9
## hosp_mortality = 1 (%) <0.001 NaN 0.0
# specify your data and variables
tbl_summary(data = df_val,
by = "hosp_mortality",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | 0, N = 3991 | 1, N = 451 |
|---|---|---|
| hosp_id | 1,022 (1,005.00, 1,024) | 1,022 (1,006.00, 1,062) |
| pt_id | 488 (232.50, 640) | 510 (299.00, 738) |
| hosp_num | ||
| 1 | 326 (82%) | 39 (87%) |
| 2 | 46 (12%) | 4 (8.9%) |
| 3 | 12 (3.0%) | 1 (2.2%) |
| 4 | 10 (2.5%) | 0 (0%) |
| 5 | 3 (0.8%) | 1 (2.2%) |
| 6 | 2 (0.5%) | 0 (0%) |
| year | ||
| 2017 | 57 (14%) | 7 (16%) |
| 2018 | 53 (13%) | 9 (20%) |
| 2019 | 63 (16%) | 9 (20%) |
| 2020 | 74 (19%) | 8 (18%) |
| 2021 | 76 (19%) | 7 (16%) |
| 2022 | 76 (19%) | 5 (11%) |
| age | 60 (50.00, 70) | 64 (52.00, 70) |
| sex | ||
| M | 296 (74%) | 33 (73%) |
| F | 103 (26%) | 12 (27%) |
| bmi | 23 (20.59, 26) | 23 (20.16, 26) |
| Unknown | 17 | 13 |
| smoke | 0 (0.00, 390) | 0 (0.00, 312) |
| Unknown | 33 | 9 |
| barthel | ||
| 0 | 167 (44%) | 4 (9.3%) |
| 1 | 120 (32%) | 11 (26%) |
| 2 | 90 (24%) | 28 (65%) |
| Unknown | 22 | 2 |
| child_num | 8 (7.00, 9) | 11 (9.00, 12) |
| Unknown | 45 | 3 |
| child_score | ||
| 0 | 81 (22%) | 2 (4.4%) |
| 1 | 193 (53%) | 13 (29%) |
| 2 | 90 (25%) | 30 (67%) |
| Unknown | 35 | 0 |
| gcs | 15 (15.00, 15) | 15 (14.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| pad | ||
| 0 | 398 (100%) | 45 (100%) |
| 1 | 1 (0.3%) | 0 (0%) |
| stroke | ||
| 0 | 391 (98%) | 42 (93%) |
| 1 | 8 (2.0%) | 3 (6.7%) |
| dimentia | ||
| 0 | 394 (99%) | 44 (98%) |
| 1 | 5 (1.3%) | 1 (2.2%) |
| ch_lung | ||
| 0 | 396 (99%) | 44 (98%) |
| 1 | 3 (0.8%) | 1 (2.2%) |
| rheumati | ||
| 0 | 399 (100%) | 45 (100%) |
| 1 | 0 (0%) | 0 (0%) |
| pept_ulcer | ||
| 0 | 359 (90%) | 43 (96%) |
| 1 | 40 (10%) | 2 (4.4%) |
| dm | ||
| 0 | 303 (76%) | 37 (82%) |
| 1 | 96 (24%) | 8 (18%) |
| dm_compli | ||
| 0 | 393 (98%) | 44 (98%) |
| 1 | 6 (1.5%) | 1 (2.2%) |
| paralysis | ||
| 0 | 399 (100%) | 45 (100%) |
| malignancy | ||
| 0 | 349 (87%) | 38 (84%) |
| 1 | 50 (13%) | 7 (16%) |
| meta_tumor | ||
| 0 | 392 (98%) | 41 (91%) |
| 1 | 7 (1.8%) | 4 (8.9%) |
| aids | ||
| 0 | 399 (100%) | 45 (100%) |
| eGFR30 | ||
| 0 | 371 (94%) | 30 (68%) |
| 1 | 22 (5.6%) | 14 (32%) |
| Unknown | 6 | 1 |
| hd | ||
| 0 | 392 (98%) | 42 (93%) |
| 1 | 7 (1.8%) | 3 (6.7%) |
| hcc | ||
| 0 | 343 (86%) | 37 (82%) |
| 1 | 56 (14%) | 8 (18%) |
| alcohol | ||
| 0 | 187 (47%) | 16 (36%) |
| 1 | 212 (53%) | 29 (64%) |
| past_rupture | ||
| 0 | 284 (71%) | 39 (87%) |
| 1 | 115 (29%) | 6 (13%) |
| antiplate | ||
| 0 | 397 (99%) | 44 (98%) |
| 1 | 2 (0.5%) | 1 (2.2%) |
| anticoag | ||
| 0 | 396 (99%) | 45 (100%) |
| 1 | 3 (0.8%) | 0 (0%) |
| antithro | ||
| 0 | 394 (99%) | 44 (98%) |
| 1 | 5 (1.3%) | 1 (2.2%) |
| nsaids | ||
| 0 | 395 (99%) | 45 (100%) |
| 1 | 4 (1.0%) | 0 (0%) |
| steroid | ||
| 0 | 396 (99%) | 45 (100%) |
| 1 | 3 (0.8%) | 0 (0%) |
| beta | ||
| 0 | 359 (90%) | 45 (100%) |
| 1 | 40 (10%) | 0 (0%) |
| vaso | ||
| 0 | 381 (95%) | 36 (80%) |
| 1 | 18 (4.5%) | 9 (20%) |
| map | 2 (0.00, 4) | 4 (4.00, 8) |
| ffp | ||
| 0 | 273 (68%) | 17 (38%) |
| 1 | 126 (32%) | 28 (62%) |
| pc | ||
| 0 | 393 (98%) | 40 (89%) |
| 1 | 6 (1.5%) | 5 (11%) |
| albner | ||
| 0 | 373 (93%) | 38 (84%) |
| 1 | 26 (6.5%) | 7 (16%) |
| bt | 37 (36.50, 37) | 37 (36.20, 38) |
| Unknown | 1 | 4 |
| sBP | 93 (82.25, 101) | 68 (56.00, 79) |
| Unknown | 1 | 0 |
| dBP | 56 (48.00, 64) | 43 (34.00, 49) |
| Unknown | 1 | 0 |
| hr | 83 (72.00, 100) | 106 (90.50, 118) |
| Unknown | 2 | 2 |
| shock | ||
| 0 | 244 (61%) | 2 (4.7%) |
| 1 | 153 (39%) | 41 (95%) |
| Unknown | 2 | 2 |
| bil | 2 (0.96, 3) | 3 (1.63, 6) |
| Unknown | 8 | 1 |
| ast | 47 (31.00, 84) | 81 (39.00, 167) |
| Unknown | 6 | 1 |
| alt | 29 (19.00, 42) | 33 (18.75, 70) |
| Unknown | 6 | 1 |
| wbc | 8,050 (5,600.00, 10,800) | 9,850 (8,842.50, 13,925) |
| Unknown | 6 | 1 |
| hb | 9 (7.30, 11) | 8 (6.88, 9) |
| Unknown | 6 | 1 |
| plt | 102 (75.00, 141) | 109 (55.75, 147) |
| Unknown | 6 | 1 |
| tp | 6 (5.60, 7) | 6 (5.00, 6) |
| Unknown | 30 | 2 |
| alb | 3 (2.50, 3) | 2 (1.80, 3) |
| Unknown | 11 | 1 |
| eGFR | 71 (53.87, 92) | 41 (28.14, 58) |
| Unknown | 6 | 1 |
| bun | 25 (16.40, 36) | 32 (19.82, 48) |
| Unknown | 6 | 1 |
| cre | 1 (0.64, 1) | 1 (0.92, 2) |
| Unknown | 9 | 1 |
| crp | 0 (0.11, 1) | 1 (0.19, 2) |
| Unknown | 13 | 2 |
| pt | 60 (48.22, 72) | 41 (30.75, 54) |
| Unknown | 19 | 1 |
| aptt | 32 (29.33, 36) | 40 (35.30, 56) |
| Unknown | 45 | 4 |
| meld | 10 (6.00, 14) | 20 (14.00, 24) |
| Unknown | 25 | 1 |
| los | 7 (5.00, 13) | 6 (2.00, 12) |
| cohort | ||
| develop | 0 (0%) | 0 (0%) |
| validation | 399 (100%) | 45 (100%) |
| 1 Median (IQR); n (%) | ||
df_val |> #全体
select(col_continuous) |>
pivot_longer(cols = col_continuous, names_to = "name", values_to = "value") |>
ggplot()+
geom_histogram(aes(x = value), color = "black")+
facet_wrap(~ name, scales = "free", ncol = 5) +
theme_bw()+
theme(text = element_text(size = 12))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 353 rows containing non-finite values (`stat_bin()`).
# 連続変数のリストを指定します。
col_continu <- c("age", "bmi","smoke","child_num","gcs","cci_num","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt")
# 指定した変数だけで相関行列を作成します。
corresult <- df_dev %>%
dplyr::select(all_of(col_continu)) %>%
drop_na() %>%
cor(method = "pearson")
# 相関行列の数値を表示します。
print(corresult)
## age bmi smoke child_num gcs
## age 1.000000000 -1.296100e-01 -0.13183344 -0.07904746 -0.056003460
## bmi -0.129610011 1.000000e+00 0.05466316 -0.03675640 -0.002670049
## smoke -0.131833435 5.466316e-02 1.00000000 0.11712280 0.012041939
## child_num -0.079047459 -3.675640e-02 0.11712280 1.00000000 -0.446313124
## gcs -0.056003460 -2.670049e-03 0.01204194 -0.44631312 1.000000000
## cci_num 0.173806387 5.024066e-02 0.01130821 0.01885518 0.032132947
## bt -0.105549686 -4.913514e-05 -0.02113526 0.05596907 0.055599410
## sBP -0.050237673 2.058716e-02 -0.07168332 -0.33446966 0.249658005
## dBP -0.065716671 2.963271e-03 -0.01202908 -0.26953193 0.248596331
## hr -0.129842553 -8.735062e-02 0.15546953 0.28402598 -0.049489433
## bil -0.231662689 -5.051886e-02 0.15359723 0.64601643 -0.255979204
## ast -0.161693213 -1.337139e-01 -0.02897554 0.18680748 -0.050480785
## alt 0.003882512 -1.409287e-02 -0.04844208 0.06228414 0.014555916
## wbc -0.193288481 3.516464e-02 0.11847396 0.22927340 -0.091775211
## hb -0.058416009 1.827695e-01 -0.01758879 -0.22162265 0.065107613
## plt 0.092221345 -4.431667e-02 -0.08794923 -0.15424065 0.028328140
## tp -0.085020719 3.998964e-02 -0.10721569 -0.20602561 0.028327021
## alb -0.142467295 7.661253e-02 -0.09456042 -0.65673209 0.346804566
## eGFR -0.421581160 -1.510401e-04 -0.02066158 -0.18092871 0.247110945
## bun 0.236651282 -4.360478e-02 -0.07590300 0.06459151 -0.137820967
## cre 0.093021049 -7.317137e-03 0.05553996 0.15426154 -0.243630164
## crp -0.005293644 -6.675397e-02 0.02185618 0.19786931 -0.027971543
## pt 0.177417560 2.038415e-02 -0.15734504 -0.66164510 0.225617727
## aptt 0.032688987 -7.245584e-02 0.05439131 0.30180218 -0.163820383
## cci_num bt sBP dBP hr
## age 0.173806387 -1.055497e-01 -0.0502376731 -0.065716671 -0.12984255
## bmi 0.050240657 -4.913514e-05 0.0205871583 0.002963271 -0.08735062
## smoke 0.011308208 -2.113526e-02 -0.0716833228 -0.012029085 0.15546953
## child_num 0.018855185 5.596907e-02 -0.3344696572 -0.269531928 0.28402598
## gcs 0.032132947 5.559941e-02 0.2496580047 0.248596331 -0.04948943
## cci_num 1.000000000 -1.281198e-01 -0.0811716905 -0.178497367 -0.13172033
## bt -0.128119797 1.000000e+00 0.2368694297 0.164333733 0.25591612
## sBP -0.081171691 2.368694e-01 1.0000000000 0.605357525 -0.15071133
## dBP -0.178497367 1.643337e-01 0.6053575253 1.000000000 -0.10642854
## hr -0.131720328 2.559161e-01 -0.1507113296 -0.106428543 1.00000000
## bil -0.133648822 5.981601e-02 -0.1677211615 -0.221208944 0.31476430
## ast -0.068234899 3.059386e-02 -0.0576587901 -0.036318866 0.15641394
## alt 0.132973609 -5.003688e-02 -0.0318011591 -0.047556489 0.02960149
## wbc -0.090971027 8.325622e-02 -0.1625636450 -0.126387695 0.28203400
## hb -0.006796172 -5.898742e-04 0.0920759203 0.113575537 -0.10008674
## plt 0.108837598 -1.072875e-01 -0.0617947620 -0.008897726 -0.05141042
## tp 0.027755188 -5.917779e-02 0.1792214811 0.077045024 -0.09569402
## alb -0.043708852 1.711312e-02 0.3427230030 0.277426076 -0.17757371
## eGFR -0.035233837 9.245822e-02 0.2033327260 0.158352541 -0.04424801
## bun 0.078270164 -3.851523e-02 -0.0528615394 -0.048348133 0.06432638
## cre 0.035292036 -4.830078e-02 -0.0377773508 -0.035203607 0.12673924
## crp -0.021155411 -6.147842e-02 -0.0005477627 -0.023554640 0.02831096
## pt 0.010651701 -3.238337e-02 0.2486208414 0.237449213 -0.27288392
## aptt -0.073689313 5.748142e-02 -0.1422777096 -0.179225336 0.13148526
## bil ast alt wbc hb
## age -0.231662689 -0.16169321 0.003882512 -0.19328848 -0.0584160095
## bmi -0.050518861 -0.13371394 -0.014092866 0.03516464 0.1827695297
## smoke 0.153597229 -0.02897554 -0.048442083 0.11847396 -0.0175887861
## child_num 0.646016426 0.18680748 0.062284144 0.22927340 -0.2216226477
## gcs -0.255979204 -0.05048079 0.014555916 -0.09177521 0.0651076127
## cci_num -0.133648822 -0.06823490 0.132973609 -0.09097103 -0.0067961722
## bt 0.059816013 0.03059386 -0.050036882 0.08325622 -0.0005898742
## sBP -0.167721161 -0.05765879 -0.031801159 -0.16256365 0.0920759203
## dBP -0.221208944 -0.03631887 -0.047556489 -0.12638769 0.1135755375
## hr 0.314764295 0.15641394 0.029601488 0.28203400 -0.1000867410
## bil 1.000000000 0.24515899 0.080686623 0.24509282 0.0052262177
## ast 0.245158987 1.00000000 0.713569279 0.23456177 -0.0865216624
## alt 0.080686623 0.71356928 1.000000000 0.11793436 0.0096813469
## wbc 0.245092818 0.23456177 0.117934355 1.00000000 -0.1655430038
## hb 0.005226218 -0.08652166 0.009681347 -0.16554300 1.0000000000
## plt -0.174243770 0.05342028 0.082966951 0.30106793 -0.1054903948
## tp 0.012518151 0.04101746 0.023922312 -0.09972653 0.4019832235
## alb -0.255644701 -0.08217463 0.015350205 -0.12925971 0.3884854516
## eGFR -0.054887252 -0.02619620 -0.037626487 -0.14849069 0.2648169513
## bun 0.030376381 0.03514411 0.147371774 0.16964975 -0.2699004874
## cre 0.155929485 0.06726628 0.040052392 0.11988522 -0.1810436238
## crp 0.302861515 0.24460499 0.206884173 0.17776026 -0.0491261686
## pt -0.503926564 -0.19129890 -0.098671705 -0.34108680 0.3188720028
## aptt 0.224658658 0.04295108 -0.001659784 0.08477517 -0.1081389027
## plt tp alb eGFR bun
## age 0.092221345 -0.085020719 -0.14246730 -0.4215811597 0.23665128
## bmi -0.044316671 0.039989635 0.07661253 -0.0001510401 -0.04360478
## smoke -0.087949228 -0.107215689 -0.09456042 -0.0206615776 -0.07590300
## child_num -0.154240647 -0.206025609 -0.65673209 -0.1809287110 0.06459151
## gcs 0.028328140 0.028327021 0.34680457 0.2471109454 -0.13782097
## cci_num 0.108837598 0.027755188 -0.04370885 -0.0352338370 0.07827016
## bt -0.107287516 -0.059177786 0.01711312 0.0924582208 -0.03851523
## sBP -0.061794762 0.179221481 0.34272300 0.2033327260 -0.05286154
## dBP -0.008897726 0.077045024 0.27742608 0.1583525414 -0.04834813
## hr -0.051410421 -0.095694019 -0.17757371 -0.0442480079 0.06432638
## bil -0.174243770 0.012518151 -0.25564470 -0.0548872524 0.03037638
## ast 0.053420281 0.041017463 -0.08217463 -0.0261962029 0.03514411
## alt 0.082966951 0.023922312 0.01535021 -0.0376264873 0.14737177
## wbc 0.301067926 -0.099726529 -0.12925971 -0.1484906941 0.16964975
## hb -0.105490395 0.401983223 0.38848545 0.2648169513 -0.26990049
## plt 1.000000000 0.089248410 0.06965940 -0.1080944525 0.13865202
## tp 0.089248410 1.000000000 0.45416125 0.1829208844 -0.15122064
## alb 0.069659398 0.454161248 1.00000000 0.2868053223 -0.07656109
## eGFR -0.108094453 0.182920884 0.28680532 1.0000000000 -0.48614545
## bun 0.138652016 -0.151220644 -0.07656109 -0.4861454533 1.00000000
## cre 0.012580290 -0.075551213 -0.12332435 -0.6435014645 0.59022745
## crp 0.147401481 0.001746056 -0.13218785 -0.0529216750 0.09367348
## pt 0.138877637 0.225869452 0.48651726 0.1217545292 -0.09432596
## aptt -0.109063601 -0.319854060 -0.42762353 -0.1874785739 0.11294775
## cre crp pt aptt
## age 0.093021049 -0.0052936444 0.17741756 0.032688987
## bmi -0.007317137 -0.0667539682 0.02038415 -0.072455842
## smoke 0.055539958 0.0218561798 -0.15734504 0.054391313
## child_num 0.154261541 0.1978693093 -0.66164510 0.301802176
## gcs -0.243630164 -0.0279715426 0.22561773 -0.163820383
## cci_num 0.035292036 -0.0211554113 0.01065170 -0.073689313
## bt -0.048300776 -0.0614784176 -0.03238337 0.057481422
## sBP -0.037777351 -0.0005477627 0.24862084 -0.142277710
## dBP -0.035203607 -0.0235546395 0.23744921 -0.179225336
## hr 0.126739240 0.0283109574 -0.27288392 0.131485257
## bil 0.155929485 0.3028615150 -0.50392656 0.224658658
## ast 0.067266283 0.2446049888 -0.19129890 0.042951078
## alt 0.040052392 0.2068841729 -0.09867171 -0.001659784
## wbc 0.119885215 0.1777602553 -0.34108680 0.084775171
## hb -0.181043624 -0.0491261686 0.31887200 -0.108138903
## plt 0.012580290 0.1474014808 0.13887764 -0.109063601
## tp -0.075551213 0.0017460561 0.22586945 -0.319854060
## alb -0.123324350 -0.1321878521 0.48651726 -0.427623526
## eGFR -0.643501465 -0.0529216750 0.12175453 -0.187478574
## bun 0.590227449 0.0936734761 -0.09432596 0.112947751
## cre 1.000000000 0.0716154896 -0.10466814 0.168143227
## crp 0.071615490 1.0000000000 -0.12359882 0.070965103
## pt -0.104668145 -0.1235988181 1.00000000 -0.441098246
## aptt 0.168143227 0.0709651031 -0.44109825 1.000000000
# 指定した連続変数だけで相関行列を作成します。
corresult <- df_dev %>%
dplyr::select(all_of(col_continu)) %>%
drop_na() %>%
cor(method = "pearson")
# 相関行列を基に相関プロットを作成します。
corrplot <- ggcorrplot(corr = corresult, hc.order = FALSE, method = "square", title = "cor plot",
colors = c("#4b61ba", "white", "red"), lab = TRUE)
# プロットを表示します。
corrplot
bilとchild_numlが0.65と相関係数は高め。ただ他は許容できそう。
# 連続変数の変数名をまとめる
con_var <- c("age", "bmi","smoke","child_num","gcs","cci_num","map","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt","meld")
# datadistを計算
ddist <- datadist(df_dev)
options(datadist='ddist')
# プロット結果をまとめるリストを用意する
plot <- list()
for (x in con_var){
# lrmに投入するformulaを文字列で、for文で順番に指定していく
formula_tmp <- as.formula(paste("hosp_mortality ~ rcs(", x, ", 4)"))
fit_tmp <- lrm(formula_tmp, data = df_dev)
# Predict関数の呼び出しを文字列として作成し、それをパースして評価する
plot_cmd <- paste("plot(Predict(fit_tmp, ", x, "))")
plot_tmp <- eval(parse(text = plot_cmd))
plot[[x]] <- plot_tmp
}
# 結果をggarrangeでまとめて表示する
logOR_plot <- ggarrange(plotlist = plot, ncol = 1, nrow = 1)
logOR_plot
## $`1`
##
## $`2`
##
## $`3`
##
## $`4`
##
## $`5`
##
## $`6`
##
## $`7`
##
## $`8`
##
## $`9`
##
## $`10`
##
## $`11`
##
## $`12`
##
## $`13`
##
## $`14`
##
## $`15`
##
## $`16`
##
## $`17`
##
## $`18`
##
## $`19`
##
## $`20`
##
## $`21`
##
## $`22`
##
## $`23`
##
## $`24`
##
## $`25`
##
## $`26`
##
## attr(,"class")
## [1] "list" "ggarrange"
naplot_1 <- gg_miss_var(df_dev, show_pct = TRUE)
naplot_1
## Warning: The `guide` argument in `scale_*()` cannot be `FALSE`. This was deprecated in
## ggplot2 3.3.4.
## ℹ Please use "none" instead.
## ℹ The deprecated feature was likely used in the naniar package.
## Please report the issue at <https://github.com/njtierney/naniar/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
naplot_2 <- vis_miss(df_dev)
## Warning: `gather_()` was deprecated in tidyr 1.2.0.
## ℹ Please use `gather()` instead.
## ℹ The deprecated feature was likely used in the visdat package.
## Please report the issue at <https://github.com/ropensci/visdat/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
naplot_2
vari_cat.f <-c("sex","barthel","child_score","pad","stroke","dimentia","ch_lung","rheumati","pept_ulcer","dm","dm_compli","paralysis","malignancy","meta_tumor","aids","eGFR30","hd","hcc","alcohol","past_rupture","antiplate","anticoag","antithro","nsaids","steroid","beta", "vaso","ffp","pc", "albner","shock","hosp_mortality")
vari_numeric <- c("age", "bmi","smoke","child_num","gcs","cci_num","map","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt","los","meld")
# vari_cat.f (defined as above) in the data_original is changed to factor type and set into data_factor_for_imp
data_factor_for_imp <- as.data.frame(lapply(df_dev[vari_cat.f],as.factor))
#check all the variable is factor
str(data_factor_for_imp)
## 'data.frame': 536 obs. of 32 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": NA 3 1 2 NA NA NA 1 NA 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 NA 2 NA NA NA 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
#summary numeric type
data_numeric_for_imp <- as.data.frame(lapply(df_dev[vari_numeric],as.numeric))
# check all the variable is numeric
str(data_numeric_for_imp)
## 'data.frame': 536 obs. of 27 variables:
## $ age : num 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num NA 25.3 NA 14.5 NA ...
## $ smoke : num 0 0 0 240 0 0 NA 1000 0 0 ...
## $ child_num: num 11 6 NA 8 NA NA NA 9 15 11 ...
## $ gcs : num 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : num 4 4 3 4 4 3 4 4 4 4 ...
## $ map : num 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : num 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : num 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : num 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 0.96 0.29 NA 2.75 0.12 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : num 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : num 16 11 13 14 6 8 6 15 29 12 ...
# combine the factor type and numeric type
data_for_imp <- cbind(data_factor_for_imp, data_numeric_for_imp)
#check all the variable type
str(data_for_imp)
## 'data.frame': 536 obs. of 59 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": NA 3 1 2 NA NA NA 1 NA 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 NA 2 NA NA NA 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
## $ age : num 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num NA 25.3 NA 14.5 NA ...
## $ smoke : num 0 0 0 240 0 0 NA 1000 0 0 ...
## $ child_num : num 11 6 NA 8 NA NA NA 9 15 11 ...
## $ gcs : num 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : num 4 4 3 4 4 3 4 4 4 4 ...
## $ map : num 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : num 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : num 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : num 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 0.96 0.29 NA 2.75 0.12 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : num 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : num 16 11 13 14 6 8 6 15 29 12 ...
cores <- detectCores(logical = FALSE) ###並列化処理
registerDoParallel(cores = cores) ###並列化処理
set.seed(2023)
md.pattern(data_for_imp) #see patern the missing
## sex pad stroke dimentia ch_lung rheumati pept_ulcer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## 1 1 1 1 1 1 0 0 1 0 1 1 1 4
## 1 1 1 1 0 1 0 1 0 1 1 1 0 7
## 1 1 1 0 0 1 0 1 0 1 1 0 0 9
## 1 1 0 0 1 0 0 0 0 0 0 0 0 13
## 1 1 0 0 0 0 0 1 0 1 1 1 1 9
## 1 1 0 0 1 0 0 0 0 0 1 1 1 11
## 1 1 1 0 1 1 0 1 1 1 1 0 1 6
## 1 1 0 1 0 0 0 1 0 1 1 1 0 13
## 1 1 1 1 1 1 1 1 1 1 1 1 1 3
## 5 1 0 0 0 0 0 1 0 1 1 1 1 16
## 4 1 0 0 0 0 0 0 0 0 1 1 1 18
## 2 0 0 0 0 0 0 1 0 1 1 1 1 21
## 1 0 0 0 0 0 0 0 0 0 1 1 1 23
## 32 34 37 39 45 54 62 63 81 84 85 140 1011
imp.mf <- missForest(data_for_imp,
maxiter = 10,
ntree = 100,
mtry = floor(sqrt(ncol(data_for_imp))),
parallelize = "variables",
verbose = TRUE)
## parallelizing over the variables of the input data matrix 'xmis'
## missForest iteration 1 in progress...
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
##
## 次のパッケージを付け加えます: 'randomForest'
## 以下のオブジェクトは 'package:dplyr' からマスクされています:
##
## combine
## 以下のオブジェクトは 'package:ggplot2' からマスクされています:
##
## margin
## 要求されたパッケージ rngtools をロード中です
## done!
## estimated error(s): 0.4019074 0.02111852
## difference(s): 0.0004840515 0.005597015
## time: 1.275 seconds
##
## missForest iteration 2 in progress...done!
## estimated error(s): 0.4004004 0.0207036
## difference(s): 0.0001136674 0.002390392
## time: 1.098 seconds
##
## missForest iteration 3 in progress...done!
## estimated error(s): 0.3995062 0.02053885
## difference(s): 0.0001359508 0.002390392
## time: 1.095 seconds
summary(imp.mf$ximp)
## sex barthel child_score pad stroke dimentia ch_lung rheumati
## M:405 0:193 0: 66 0:535 0:526 0:532 0:525 0:533
## F:131 1:154 1:291 1: 1 1: 10 1: 4 1: 11 1: 3
## 2:189 2:179
##
##
##
## pept_ulcer dm dm_compli paralysis malignancy meta_tumor aids eGFR30
## 0:477 0:430 0:530 0:536 0:478 0:530 0:536 0:485
## 1: 59 1:106 1: 6 1: 58 1: 6 1: 51
##
##
##
##
## hd hcc alcohol past_rupture antiplate anticoag antithro nsaids
## 0:533 0:425 0:305 0:432 0:532 0:535 0:532 0:531
## 1: 3 1:111 1:231 1:104 1: 4 1: 1 1: 4 1: 5
##
##
##
##
## steroid beta vaso ffp pc albner shock hosp_mortality
## 0:534 0:518 0:505 0:399 0:530 0:489 0:318 0:463
## 1: 2 1: 18 1: 31 1:137 1: 6 1: 47 1:218 1: 73
##
##
##
##
## age bmi smoke child_num
## Min. :26.00 Min. :13.72 Min. : 0.0 Min. : 5.000
## 1st Qu.:51.75 1st Qu.:20.81 1st Qu.: 0.0 1st Qu.: 7.045
## Median :62.00 Median :22.66 Median : 200.0 Median : 8.291
## Mean :61.23 Mean :22.90 Mean : 301.3 Mean : 8.805
## 3rd Qu.:70.00 3rd Qu.:24.45 3rd Qu.: 411.6 3rd Qu.:10.000
## Max. :90.00 Max. :33.95 Max. :9000.0 Max. :15.000
## gcs cci_num map bt
## Min. : 3.00 Min. : 3.000 Min. : 0.000 Min. :32.80
## 1st Qu.:15.00 1st Qu.: 4.000 1st Qu.: 0.000 1st Qu.:36.30
## Median :15.00 Median : 4.000 Median : 4.000 Median :36.70
## Mean :14.33 Mean : 4.444 Mean : 3.493 Mean :36.66
## 3rd Qu.:15.00 3rd Qu.: 5.000 3rd Qu.: 4.000 3rd Qu.:37.00
## Max. :15.00 Max. :12.000 Max. :68.000 Max. :41.70
## sBP dBP hr bil
## Min. : 50.00 Min. : 3.00 Min. : 39.00 Min. : 0.2000
## 1st Qu.: 79.75 1st Qu.:44.00 1st Qu.: 71.00 1st Qu.: 0.9775
## Median : 90.00 Median :51.00 Median : 82.00 Median : 1.4750
## Mean : 87.50 Mean :51.14 Mean : 85.39 Mean : 2.1906
## 3rd Qu.: 96.00 3rd Qu.:58.00 3rd Qu.: 97.25 3rd Qu.: 2.6775
## Max. :150.00 Max. :93.00 Max. :222.00 Max. :15.8000
## ast alt wbc hb
## Min. : 10.00 Min. : 7.00 Min. : 1300 Min. : 2.800
## 1st Qu.: 34.00 1st Qu.: 20.00 1st Qu.: 5400 1st Qu.: 7.000
## Median : 58.16 Median : 30.00 Median : 7300 Median : 8.400
## Mean : 85.04 Mean : 43.35 Mean : 8316 Mean : 8.578
## 3rd Qu.: 95.00 3rd Qu.: 47.00 3rd Qu.:10300 3rd Qu.:10.000
## Max. :984.00 Max. :562.00 Max. :37700 Max. :16.500
## plt tp alb eGFR
## Min. : 21.0 Min. :2.200 Min. :1.100 Min. : 4.274
## 1st Qu.: 73.0 1st Qu.:5.500 1st Qu.:2.500 1st Qu.: 48.745
## Median : 98.0 Median :6.200 Median :2.812 Median : 67.746
## Mean :110.6 Mean :6.107 Mean :2.828 Mean : 69.256
## 3rd Qu.:134.2 3rd Qu.:6.635 3rd Qu.:3.200 3rd Qu.: 88.257
## Max. :482.0 Max. :9.100 Max. :4.400 Max. :196.029
## bun cre crp pt
## Min. : 2.90 Min. : 0.330 Min. : 0.0000 Min. : 7.50
## 1st Qu.: 16.10 1st Qu.: 0.670 1st Qu.: 0.1200 1st Qu.: 40.58
## Median : 23.20 Median : 0.860 Median : 0.3268 Median : 52.57
## Mean : 28.34 Mean : 1.061 Mean : 0.7968 Mean : 52.20
## 3rd Qu.: 35.62 3rd Qu.: 1.140 3rd Qu.: 0.8145 3rd Qu.: 63.50
## Max. :124.80 Max. :10.950 Max. :18.6370 Max. :107.90
## aptt los meld
## Min. : 17.60 Min. : 0.00 Min. : 6.00
## 1st Qu.: 26.40 1st Qu.: 6.00 1st Qu.: 7.00
## Median : 28.70 Median : 10.00 Median :11.00
## Mean : 32.27 Mean : 13.77 Mean :12.06
## 3rd Qu.: 33.23 3rd Qu.: 18.00 3rd Qu.:15.00
## Max. :240.00 Max. :159.00 Max. :40.00
md.pattern(imp.mf$ximp)
## /\ /\
## { `---' }
## { O O }
## ==> V <== No need for mice. This data set is completely observed.
## \ \|/ /
## `-----'
## sex barthel child_score pad stroke dimentia ch_lung rheumati pept_ulcer dm
## 536 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0
## dm_compli paralysis malignancy meta_tumor aids eGFR30 hd hcc alcohol
## 536 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0
## past_rupture antiplate anticoag antithro nsaids steroid beta vaso ffp pc
## 536 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0
## albner shock hosp_mortality age bmi smoke child_num gcs cci_num map bt sBP
## 536 1 1 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0 0 0
## dBP hr bil ast alt wbc hb plt tp alb eGFR bun cre crp pt aptt los meld
## 536 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#if exclude ID is necessary add the ID
data_imp <- imp.mf$ximp
data_imp$pt_id <- df_dev$pt_id
data_imp$hosp_num<- df_dev$hosp_num
data_imp$hosp_id<- df_dev$hosp_id
data_imp$year<- df_dev$year
#check
str(data_imp)
## 'data.frame': 536 obs. of 63 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 3 3 1 2 3 1 1 1 3 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 2 2 2 2 2 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
## $ age : num 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num 23.4 25.3 23.5 14.5 21.9 ...
## $ smoke : num 0 0 0 240 0 ...
## $ child_num : num 11 6 8.75 8 7.55 ...
## $ gcs : num 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : num 4 4 3 4 4 3 4 4 4 4 ...
## $ map : num 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : num 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : num 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : num 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : num 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : num 16 11 13 14 6 8 6 15 29 12 ...
## $ pt_id : int 1 2 3 4 5 7 8 9 10 11 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ year : int 2012 2011 2010 2011 2010 2010 2010 2010 2011 2012 ...
#write the csv
#write.csv(imp.mf$ximp, file = "data_after_imputation.csv")
str(data_imp)
## 'data.frame': 536 obs. of 63 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 3 3 1 2 3 1 1 1 3 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 2 2 2 2 2 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
## $ age : num 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num 23.4 25.3 23.5 14.5 21.9 ...
## $ smoke : num 0 0 0 240 0 ...
## $ child_num : num 11 6 8.75 8 7.55 ...
## $ gcs : num 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : num 4 4 3 4 4 3 4 4 4 4 ...
## $ map : num 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : num 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : num 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : num 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : num 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : num 16 11 13 14 6 8 6 15 29 12 ...
## $ pt_id : int 1 2 3 4 5 7 8 9 10 11 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ year : int 2012 2011 2010 2011 2010 2010 2010 2010 2011 2012 ...
data_imp$meld <- round(data_imp$meld)
min(data_imp$meld, na.rm = TRUE)
## [1] 6
max(data_imp$meld, na.rm = TRUE)
## [1] 40
dev_imp <-
data_imp|>
mutate(
hosp_id=as.integer(hosp_id),
pt_id=as.integer(pt_id),
hosp_num=as.integer(hosp_num),
year=as.integer(year),
age=as.integer(age),
sex= factor(sex, levels = c("M", "F")),
smoke= as.integer(smoke),
barthel= factor(barthel, levels = c("0", "1", "2")),
child_num= as.integer(round(data_imp$child_num)),
child_score=factor(child_score, levels = c("0", "1", "2")),
gcs=as.integer(gcs),
cci_num=as.integer(cci_num),
pad=factor(pad),
stroke=factor(stroke),
dimentia=factor(dimentia),
ch_lung=factor(ch_lung),
rheumati=factor(rheumati),
pept_ulcer=factor(pept_ulcer),
dm=factor(dm),
dm_compli=factor(dm_compli),
paralysis=factor(paralysis),
malignancy=factor(malignancy),
meta_tumor=factor(meta_tumor),
aids=factor(aids),
eGFR30=factor(eGFR30),
hd=factor(hd),
hcc=factor(hcc),
alcohol=factor(alcohol),
past_rupture=factor(past_rupture),
antiplate=factor(antiplate),
anticoag=factor(anticoag),
antithro=factor(antithro),
nsaids=factor(nsaids),
steroid=factor(steroid),
beta=factor(beta),
vaso=factor(vaso),
map= as.integer(map),
ffp=factor(ffp),
pc=factor(pc),
albner=factor(albner),
sBP= as.integer(sBP),
dBP= as.integer(dBP),
hr=as.integer(hr),
shock=factor(shock),
los=as.integer(los),
meld=as.integer(meld)
)
table(dev_imp$child_num)
##
## 5 6 7 8 9 10 11 12 13 14 15
## 20 46 73 137 76 71 47 41 18 3 4
dfSummary(dev_imp) %>% view()
## Switching method to 'browser'
## Output file written: /var/folders/n9/tf_wmwpn3gl2t7l1cz4tqk000000gn/T//Rtmp71I39G/file94e627bfe65a.html
str(dev_imp)
## 'data.frame': 536 obs. of 63 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 3 3 1 2 3 1 1 1 3 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 2 2 2 2 2 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
## $ age : int 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num 23.4 25.3 23.5 14.5 21.9 ...
## $ smoke : int 0 0 0 240 0 0 217 1000 0 0 ...
## $ child_num : int 11 6 9 8 8 8 7 9 15 11 ...
## $ gcs : int 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : int 4 4 3 4 4 3 4 4 4 4 ...
## $ map : int 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : int 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : int 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : int 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : int 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : int 16 11 13 14 6 8 6 15 29 12 ...
## $ pt_id : int 1 2 3 4 5 7 8 9 10 11 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ year : int 2012 2011 2010 2011 2010 2010 2010 2010 2011 2012 ...
# Create your table
dev_imp %>%
select(c(col_cont, col_fact)) %>%
CreateTableOne(vars = c(col_cont, col_fact), strata="hosp_mortality",factorVars = col_fact, addOverall = T) -> tableone_dev_imp
# Print your table
print(tableone_dev_imp, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by hosp_mortality
## Overall 0 1
## n 536 463 73
## age (mean (SD)) 61.23 (13.06) 60.82 (13.02) 63.84 (13.09)
## bmi (mean (SD)) 22.90 (3.43) 22.99 (3.48) 22.28 (3.04)
## smoke (mean (SD)) 301.23 (528.30) 285.63 (366.19) 400.16 (1096.34)
## child_num (mean (SD)) 8.81 (2.06) 8.48 (1.87) 10.90 (2.01)
## gcs (mean (SD)) 14.33 (2.20) 14.72 (1.27) 11.90 (4.33)
## cci_num (mean (SD)) 4.44 (1.20) 4.43 (1.08) 4.53 (1.78)
## map (mean (SD)) 3.49 (4.51) 3.10 (4.35) 5.96 (4.71)
## bt (mean (SD)) 36.66 (0.74) 36.68 (0.65) 36.49 (1.16)
## sBP (mean (SD)) 87.48 (15.26) 90.26 (13.37) 69.85 (14.79)
## dBP (mean (SD)) 51.12 (11.71) 52.94 (10.80) 39.56 (10.65)
## hr (mean (SD)) 85.37 (20.73) 82.95 (18.82) 100.68 (25.41)
## bil (mean (SD)) 2.19 (2.03) 1.96 (1.76) 3.66 (2.85)
## ast (mean (SD)) 85.04 (91.05) 79.34 (86.79) 121.21 (108.33)
## alt (mean (SD)) 43.35 (50.11) 41.69 (49.31) 53.91 (54.05)
## wbc (mean (SD)) 8315.81 (4354.87) 8160.66 (4158.83) 9299.86 (5366.73)
## hb (mean (SD)) 8.58 (2.44) 8.65 (2.45) 8.11 (2.38)
## plt (mean (SD)) 110.59 (57.13) 109.02 (51.35) 120.60 (84.92)
## tp (mean (SD)) 6.11 (0.89) 6.16 (0.83) 5.78 (1.15)
## alb (mean (SD)) 2.83 (0.58) 2.91 (0.53) 2.31 (0.62)
## eGFR (mean (SD)) 69.26 (30.44) 72.87 (30.10) 46.36 (21.32)
## bun (mean (SD)) 28.34 (18.43) 27.43 (17.57) 34.11 (22.48)
## cre (mean (SD)) 1.06 (0.91) 1.00 (0.90) 1.46 (0.82)
## crp (mean (SD)) 0.80 (1.61) 0.70 (1.54) 1.44 (1.90)
## pt (mean (SD)) 52.20 (16.66) 53.87 (15.65) 41.59 (18.93)
## aptt (mean (SD)) 32.27 (16.38) 30.66 (11.58) 42.45 (31.81)
## los (mean (SD)) 13.77 (15.28) 14.21 (14.24) 11.01 (20.59)
## meld (mean (SD)) 12.07 (6.01) 10.98 (4.74) 18.93 (8.29)
## sex = F (%) 131 ( 24.4) 111 ( 24.0) 20 ( 27.4)
## barthel (%)
## 0 193 ( 36.0) 186 ( 40.2) 7 ( 9.6)
## 1 154 ( 28.7) 142 ( 30.7) 12 ( 16.4)
## 2 189 ( 35.3) 135 ( 29.2) 54 ( 74.0)
## child_score (%)
## 0 66 ( 12.3) 65 ( 14.0) 1 ( 1.4)
## 1 291 ( 54.3) 271 ( 58.5) 20 ( 27.4)
## 2 179 ( 33.4) 127 ( 27.4) 52 ( 71.2)
## pad = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0)
## stroke = 1 (%) 10 ( 1.9) 10 ( 2.2) 0 ( 0.0)
## dimentia = 1 (%) 4 ( 0.7) 4 ( 0.9) 0 ( 0.0)
## ch_lung = 1 (%) 11 ( 2.1) 9 ( 1.9) 2 ( 2.7)
## rheumati = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0)
## pept_ulcer = 1 (%) 59 ( 11.0) 58 ( 12.5) 1 ( 1.4)
## dm = 1 (%) 106 ( 19.8) 98 ( 21.2) 8 ( 11.0)
## dm_compli = 1 (%) 6 ( 1.1) 6 ( 1.3) 0 ( 0.0)
## paralysis = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0)
## malignancy = 1 (%) 58 ( 10.8) 46 ( 9.9) 12 ( 16.4)
## meta_tumor = 1 (%) 6 ( 1.1) 2 ( 0.4) 4 ( 5.5)
## aids = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0)
## eGFR30 = 1 (%) 51 ( 9.5) 34 ( 7.3) 17 ( 23.3)
## hd = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0)
## hcc = 1 (%) 111 ( 20.7) 95 ( 20.5) 16 ( 21.9)
## alcohol = 1 (%) 231 ( 43.1) 205 ( 44.3) 26 ( 35.6)
## past_rupture = 1 (%) 104 ( 19.4) 96 ( 20.7) 8 ( 11.0)
## antiplate = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4)
## anticoag = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0)
## antithro = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4)
## nsaids = 1 (%) 5 ( 0.9) 5 ( 1.1) 0 ( 0.0)
## steroid = 1 (%) 2 ( 0.4) 1 ( 0.2) 1 ( 1.4)
## beta = 1 (%) 18 ( 3.4) 18 ( 3.9) 0 ( 0.0)
## vaso = 1 (%) 31 ( 5.8) 11 ( 2.4) 20 ( 27.4)
## ffp = 1 (%) 137 ( 25.6) 100 ( 21.6) 37 ( 50.7)
## pc = 1 (%) 6 ( 1.1) 3 ( 0.6) 3 ( 4.1)
## albner = 1 (%) 47 ( 8.8) 32 ( 6.9) 15 ( 20.5)
## shock = 1 (%) 218 ( 40.7) 156 ( 33.7) 62 ( 84.9)
## hosp_mortality = 1 (%) 73 ( 13.6) 0 ( 0.0) 73 (100.0)
## Stratified by hosp_mortality
## p test SMD Missing
## n
## age (mean (SD)) 0.066 0.231 0.0
## bmi (mean (SD)) 0.102 0.216 0.0
## smoke (mean (SD)) 0.085 0.140 0.0
## child_num (mean (SD)) <0.001 1.249 0.0
## gcs (mean (SD)) <0.001 0.882 0.0
## cci_num (mean (SD)) 0.490 0.071 0.0
## map (mean (SD)) <0.001 0.630 0.0
## bt (mean (SD)) 0.041 0.203 0.0
## sBP (mean (SD)) <0.001 1.448 0.0
## dBP (mean (SD)) <0.001 1.247 0.0
## hr (mean (SD)) <0.001 0.793 0.0
## bil (mean (SD)) <0.001 0.717 0.0
## ast (mean (SD)) <0.001 0.427 0.0
## alt (mean (SD)) 0.053 0.236 0.0
## wbc (mean (SD)) 0.038 0.237 0.0
## hb (mean (SD)) 0.078 0.225 0.0
## plt (mean (SD)) 0.107 0.165 0.0
## tp (mean (SD)) 0.001 0.377 0.0
## alb (mean (SD)) <0.001 1.033 0.0
## eGFR (mean (SD)) <0.001 1.016 0.0
## bun (mean (SD)) 0.004 0.331 0.0
## cre (mean (SD)) <0.001 0.541 0.0
## crp (mean (SD)) <0.001 0.431 0.0
## pt (mean (SD)) <0.001 0.707 0.0
## aptt (mean (SD)) <0.001 0.493 0.0
## los (mean (SD)) 0.097 0.180 0.0
## meld (mean (SD)) <0.001 1.177 0.0
## sex = F (%) 0.627 0.078 0.0
## barthel (%) <0.001 1.040 0.0
## 0
## 1
## 2
## child_score (%) <0.001 1.018 0.0
## 0
## 1
## 2
## pad = 1 (%) 1.000 0.066 0.0
## stroke = 1 (%) 0.422 0.210 0.0
## dimentia = 1 (%) 0.948 0.132 0.0
## ch_lung = 1 (%) 0.999 0.053 0.0
## rheumati = 1 (%) 1.000 0.114 0.0
## pept_ulcer = 1 (%) 0.009 0.450 0.0
## dm = 1 (%) 0.061 0.281 0.0
## dm_compli = 1 (%) 0.704 0.162 0.0
## paralysis = 0 (%) NA <0.001 0.0
## malignancy = 1 (%) 0.144 0.193 0.0
## meta_tumor = 1 (%) 0.001 0.301 0.0
## aids = 0 (%) NA <0.001 0.0
## eGFR30 = 1 (%) <0.001 0.454 0.0
## hd = 1 (%) 1.000 0.114 0.0
## hcc = 1 (%) 0.905 0.034 0.0
## alcohol = 1 (%) 0.207 0.178 0.0
## past_rupture = 1 (%) 0.071 0.270 0.0
## antiplate = 1 (%) 1.000 0.072 0.0
## anticoag = 1 (%) 1.000 0.066 0.0
## antithro = 1 (%) 1.000 0.072 0.0
## nsaids = 1 (%) 0.813 0.148 0.0
## steroid = 1 (%) 0.638 0.130 0.0
## beta = 1 (%) 0.173 0.284 0.0
## vaso = 1 (%) <0.001 0.751 0.0
## ffp = 1 (%) <0.001 0.635 0.0
## pc = 1 (%) 0.044 0.229 0.0
## albner = 1 (%) <0.001 0.404 0.0
## shock = 1 (%) <0.001 1.222 0.0
## hosp_mortality = 1 (%) <0.001 NaN 0.0
# specify your data and variables
tbl_summary(data = dev_imp,
by = "hosp_mortality",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | 0, N = 4631 | 1, N = 731 |
|---|---|---|
| sex | ||
| M | 352 (76%) | 53 (73%) |
| F | 111 (24%) | 20 (27%) |
| barthel | ||
| 0 | 186 (40%) | 7 (9.6%) |
| 1 | 142 (31%) | 12 (16%) |
| 2 | 135 (29%) | 54 (74%) |
| child_score | ||
| 0 | 65 (14%) | 1 (1.4%) |
| 1 | 271 (59%) | 20 (27%) |
| 2 | 127 (27%) | 52 (71%) |
| pad | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| stroke | ||
| 0 | 453 (98%) | 73 (100%) |
| 1 | 10 (2.2%) | 0 (0%) |
| dimentia | ||
| 0 | 459 (99%) | 73 (100%) |
| 1 | 4 (0.9%) | 0 (0%) |
| ch_lung | ||
| 0 | 454 (98%) | 71 (97%) |
| 1 | 9 (1.9%) | 2 (2.7%) |
| rheumati | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| pept_ulcer | ||
| 0 | 405 (87%) | 72 (99%) |
| 1 | 58 (13%) | 1 (1.4%) |
| dm | ||
| 0 | 365 (79%) | 65 (89%) |
| 1 | 98 (21%) | 8 (11%) |
| dm_compli | ||
| 0 | 457 (99%) | 73 (100%) |
| 1 | 6 (1.3%) | 0 (0%) |
| paralysis | ||
| 0 | 463 (100%) | 73 (100%) |
| malignancy | ||
| 0 | 417 (90%) | 61 (84%) |
| 1 | 46 (9.9%) | 12 (16%) |
| meta_tumor | ||
| 0 | 461 (100%) | 69 (95%) |
| 1 | 2 (0.4%) | 4 (5.5%) |
| aids | ||
| 0 | 463 (100%) | 73 (100%) |
| eGFR30 | ||
| 0 | 429 (93%) | 56 (77%) |
| 1 | 34 (7.3%) | 17 (23%) |
| hd | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| hcc | ||
| 0 | 368 (79%) | 57 (78%) |
| 1 | 95 (21%) | 16 (22%) |
| alcohol | ||
| 0 | 258 (56%) | 47 (64%) |
| 1 | 205 (44%) | 26 (36%) |
| past_rupture | ||
| 0 | 367 (79%) | 65 (89%) |
| 1 | 96 (21%) | 8 (11%) |
| antiplate | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| anticoag | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| antithro | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| nsaids | ||
| 0 | 458 (99%) | 73 (100%) |
| 1 | 5 (1.1%) | 0 (0%) |
| steroid | ||
| 0 | 462 (100%) | 72 (99%) |
| 1 | 1 (0.2%) | 1 (1.4%) |
| beta | ||
| 0 | 445 (96%) | 73 (100%) |
| 1 | 18 (3.9%) | 0 (0%) |
| vaso | ||
| 0 | 452 (98%) | 53 (73%) |
| 1 | 11 (2.4%) | 20 (27%) |
| ffp | ||
| 0 | 363 (78%) | 36 (49%) |
| 1 | 100 (22%) | 37 (51%) |
| pc | ||
| 0 | 460 (99%) | 70 (96%) |
| 1 | 3 (0.6%) | 3 (4.1%) |
| albner | ||
| 0 | 431 (93%) | 58 (79%) |
| 1 | 32 (6.9%) | 15 (21%) |
| shock | ||
| 0 | 307 (66%) | 11 (15%) |
| 1 | 156 (34%) | 62 (85%) |
| age | 62 (51.00, 70) | 66 (55.00, 74) |
| bmi | 23 (20.81, 25) | 23 (20.96, 24) |
| smoke | 200 (0.00, 413) | 180 (0.00, 400) |
| child_num | 8 (7.00, 10) | 11 (9.00, 12) |
| gcs | 15 (15.00, 15) | 15 (9.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| map | 4 (0.00, 4) | 6 (4.00, 8) |
| bt | 37 (36.30, 37) | 36 (36.00, 37) |
| sBP | 90 (82.00, 98) | 65 (59.00, 79) |
| dBP | 53 (46.00, 59) | 40 (33.00, 46) |
| hr | 80 (70.00, 93) | 101 (89.00, 112) |
| bil | 1 (0.90, 2) | 3 (1.66, 5) |
| ast | 55 (33.00, 90) | 84 (49.00, 153) |
| alt | 29 (20.00, 44) | 33 (25.00, 63) |
| wbc | 7,200 (5,315.00, 10,240) | 7,990 (6,200.00, 10,800) |
| hb | 8 (7.00, 10) | 8 (6.60, 10) |
| plt | 98 (73.00, 135) | 98 (76.00, 130) |
| tp | 6 (5.60, 7) | 6 (5.20, 6) |
| alb | 3 (2.60, 3) | 2 (1.80, 3) |
| eGFR | 71 (52.42, 92) | 44 (30.40, 58) |
| bun | 23 (15.50, 35) | 28 (18.10, 46) |
| cre | 1 (0.66, 1) | 1 (0.99, 2) |
| crp | 0 (0.11, 1) | 1 (0.40, 2) |
| pt | 54 (43.00, 64) | 40 (26.80, 55) |
| aptt | 28 (26.05, 32) | 32 (29.10, 44) |
| los | 10 (7.00, 18) | 4 (1.00, 16) |
| meld | 10 (7.00, 14) | 16 (13.00, 25) |
| pt_id | 359 (149.50, 583) | 426 (235.00, 599) |
| hosp_num | ||
| 1 | 404 (87%) | 68 (93%) |
| 2 | 43 (9.3%) | 5 (6.8%) |
| 3 | 15 (3.2%) | 0 (0%) |
| 4 | 1 (0.2%) | 0 (0%) |
| hosp_id | 1,010 (1,003.00, 1,024) | 1,017 (1,005.00, 1,024) |
| year | ||
| 2010 | 68 (15%) | 8 (11%) |
| 2011 | 70 (15%) | 9 (12%) |
| 2012 | 72 (16%) | 16 (22%) |
| 2013 | 55 (12%) | 15 (21%) |
| 2014 | 69 (15%) | 8 (11%) |
| 2015 | 67 (14%) | 5 (6.8%) |
| 2016 | 62 (13%) | 12 (16%) |
| 1 n (%); Median (IQR) | ||
dev_imp |> #全体
select(col_continuous) |>
pivot_longer(cols = col_continuous, names_to = "name", values_to = "value") |>
ggplot()+
geom_histogram(aes(x = value), color = "black")+
facet_wrap(~ name, scales = "free", ncol = 5) +
theme_bw()+
theme(text = element_text(size = 12))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# 連続変数の変数名をまとめる
con_var <- c("age", "bmi","smoke","child_num","gcs","cci_num","map","bt","sBP","dBP","hr","bil","ast","alt","wbc","hb","plt","tp","alb","eGFR","bun","cre","crp","pt","aptt","meld")
# datadistを計算
ddist <- datadist(dev_imp)
options(datadist='ddist')
# プロット結果をまとめるリストを用意する
plot <- list()
for (x in con_var){
# lrmに投入するformulaを文字列で、for文で順番に指定していく
formula_tmp <- as.formula(paste("hosp_mortality ~ rcs(", x, ", 4)"))
fit_tmp <- lrm(formula_tmp, data = dev_imp)
# Predict関数の呼び出しを文字列として作成し、それをパースして評価する
plot_cmd <- paste("plot(Predict(fit_tmp, ", x, "))")
plot_tmp <- eval(parse(text = plot_cmd))
plot[[x]] <- plot_tmp
}
# 結果をggarrangeでまとめて表示する
logOR_plot <- ggarrange(plotlist = plot, ncol = 1, nrow = 1)
logOR_plot
## $`1`
##
## $`2`
##
## $`3`
##
## $`4`
##
## $`5`
##
## $`6`
##
## $`7`
##
## $`8`
##
## $`9`
##
## $`10`
##
## $`11`
##
## $`12`
##
## $`13`
##
## $`14`
##
## $`15`
##
## $`16`
##
## $`17`
##
## $`18`
##
## $`19`
##
## $`20`
##
## $`21`
##
## $`22`
##
## $`23`
##
## $`24`
##
## $`25`
##
## $`26`
##
## attr(,"class")
## [1] "list" "ggarrange"
以下のCut offを設ける ・age:60以上・未満 60未満:0, 60以上:1 ・bmi:25以上・未満 25未満:0, 25以上:1 ・smoke:cut offなし →むしろ変数から削除 ・child_numl:cut offなし→むしろ変数から削除 ・gcs:12以上・未満 12未満:0, 12以上:1 ・cci:6点以上・未満 6未満:0, 6以上:1 ・bt:37度以上・未満 37度未満:0,37度以上:1 ・sBP:80以上・未満 80以上:0,80未満:1 ・dBP:50以上・未満 50以上:0,50未満:1 ・HR:100以上・未満 100未満:0,100以上:1 ・bil:5以上・未満: 5未満:0,5以上:1 ・ast:200以上・未満 200未満:0, 200以上:1 ・alt:100以上・未満 100未満:0, 100以上:1 ・wbc:12000以上・未満 12000未満:0, 12000以上:1 ・hb:8以上・未満 9以上:0, 8未満:1 ・plt:100以上・未満 100以上:0, 100未満:1 ・tp:6以上・未満 6以上:0, 6未満:1 ・alb:2.8以上・未満 2.8以上:0, 2.8未満:1 ・Cre:1.5以上・未満 1.5未満:0, Cre1.5以上:1 ・CRP:2以上・未満 2未満:0, CRP2以上:1 ・pt:50以上・未満 50以上:0, 50未満:1 ・aptt:50以上・未満 aptt50未満:0,50以上:1
#新規カテゴリ列を作成
dev_imp$age_cate <- ifelse(dev_imp$age >= 60, 1, 0)
dev_imp$bmi_cate <- ifelse(dev_imp$bmi >= 25, 1, 0) # bmiは25以上:1, 25未満:0
dev_imp$gcs_cate <- ifelse(dev_imp$gcs < 12, 1, 0)
dev_imp$cci_cate <- ifelse(dev_imp$cci_num >= 6, 1, 0)
dev_imp$bt_cate <- ifelse(dev_imp$bt >= 37, 1, 0)
dev_imp$sBP_cate <- ifelse(dev_imp$sBP < 80, 1, 0)
dev_imp$dBP_cate <- ifelse(dev_imp$dBP < 50, 1, 0)
dev_imp$hr_cate <- ifelse(dev_imp$hr >= 100, 1, 0)
dev_imp$bil_cate <- ifelse(dev_imp$bil >= 5, 1, 0)
dev_imp$ast_cate <- ifelse(dev_imp$ast >= 200, 1, 0)
dev_imp$alt_cate <- ifelse(dev_imp$alt >= 100, 1, 0)
dev_imp$wbc_cate <- ifelse(dev_imp$wbc >= 12000, 1, 0)
dev_imp$hb_cate <- ifelse(dev_imp$hb < 8, 1, 0)
dev_imp$plt_cate <- ifelse(dev_imp$plt < 100, 1, 0) # pltは100未満:1、100以上:0
dev_imp$tp_cate <- ifelse(dev_imp$tp < 6, 1, 0)
dev_imp$alb_cate <- ifelse(dev_imp$alb < 2.8, 1, 0)
dev_imp$cre_cate <- ifelse(dev_imp$cre >= 1.5, 1, 0)
dev_imp$crp_cate <- ifelse(dev_imp$crp >= 2, 1, 0)
dev_imp$pt_cate <- ifelse(dev_imp$pt < 50, 1, 0)
dev_imp$aptt_cate <- ifelse(dev_imp$aptt >= 50, 1, 0) # apttは50以上:1, 50未満:0
col_fact_cate=c("sex","barthel","child_score","pad","stroke","dimentia","ch_lung","rheumati","pept_ulcer","dm","dm_compli","paralysis","malignancy","meta_tumor","aids","eGFR30","hd","hcc","alcohol","past_rupture","antiplate","anticoag","antithro","nsaids","steroid","beta", "vaso","ffp","pc", "albner","shock","hosp_mortality","age_cate","bmi_cate","gcs_cate","cci_cate","bt_cate","sBP_cate","dBP_cate","hr_cate","bil_cate","ast_cate","alt_cate","wbc_cate","hb_cate","plt_cate","tp_cate","alb_cate","cre_cate","crp_cate","pt_cate","aptt_cate")
# Create your table
dev_imp %>%
select(c(col_fact_cate)) %>%
CreateTableOne(vars = c(col_fact_cate), strata="hosp_mortality",factorVars = col_fact_cate, addOverall = T) -> tableone_dev_imp_cate
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(col_fact_cate)
##
## # Now:
## data %>% select(all_of(col_fact_cate))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Print your table
print(tableone_dev_imp_cate, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by hosp_mortality
## Overall 0 1 p test
## n 536 463 73
## sex = F (%) 131 ( 24.4) 111 ( 24.0) 20 ( 27.4) 0.627
## barthel (%) <0.001
## 0 193 ( 36.0) 186 ( 40.2) 7 ( 9.6)
## 1 154 ( 28.7) 142 ( 30.7) 12 ( 16.4)
## 2 189 ( 35.3) 135 ( 29.2) 54 ( 74.0)
## child_score (%) <0.001
## 0 66 ( 12.3) 65 ( 14.0) 1 ( 1.4)
## 1 291 ( 54.3) 271 ( 58.5) 20 ( 27.4)
## 2 179 ( 33.4) 127 ( 27.4) 52 ( 71.2)
## pad = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0) 1.000
## stroke = 1 (%) 10 ( 1.9) 10 ( 2.2) 0 ( 0.0) 0.422
## dimentia = 1 (%) 4 ( 0.7) 4 ( 0.9) 0 ( 0.0) 0.948
## ch_lung = 1 (%) 11 ( 2.1) 9 ( 1.9) 2 ( 2.7) 0.999
## rheumati = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0) 1.000
## pept_ulcer = 1 (%) 59 ( 11.0) 58 ( 12.5) 1 ( 1.4) 0.009
## dm = 1 (%) 106 ( 19.8) 98 ( 21.2) 8 ( 11.0) 0.061
## dm_compli = 1 (%) 6 ( 1.1) 6 ( 1.3) 0 ( 0.0) 0.704
## paralysis = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0) NA
## malignancy = 1 (%) 58 ( 10.8) 46 ( 9.9) 12 ( 16.4) 0.144
## meta_tumor = 1 (%) 6 ( 1.1) 2 ( 0.4) 4 ( 5.5) 0.001
## aids = 0 (%) 536 (100.0) 463 (100.0) 73 (100.0) NA
## eGFR30 = 1 (%) 51 ( 9.5) 34 ( 7.3) 17 ( 23.3) <0.001
## hd = 1 (%) 3 ( 0.6) 3 ( 0.6) 0 ( 0.0) 1.000
## hcc = 1 (%) 111 ( 20.7) 95 ( 20.5) 16 ( 21.9) 0.905
## alcohol = 1 (%) 231 ( 43.1) 205 ( 44.3) 26 ( 35.6) 0.207
## past_rupture = 1 (%) 104 ( 19.4) 96 ( 20.7) 8 ( 11.0) 0.071
## antiplate = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4) 1.000
## anticoag = 1 (%) 1 ( 0.2) 1 ( 0.2) 0 ( 0.0) 1.000
## antithro = 1 (%) 4 ( 0.7) 3 ( 0.6) 1 ( 1.4) 1.000
## nsaids = 1 (%) 5 ( 0.9) 5 ( 1.1) 0 ( 0.0) 0.813
## steroid = 1 (%) 2 ( 0.4) 1 ( 0.2) 1 ( 1.4) 0.638
## beta = 1 (%) 18 ( 3.4) 18 ( 3.9) 0 ( 0.0) 0.173
## vaso = 1 (%) 31 ( 5.8) 11 ( 2.4) 20 ( 27.4) <0.001
## ffp = 1 (%) 137 ( 25.6) 100 ( 21.6) 37 ( 50.7) <0.001
## pc = 1 (%) 6 ( 1.1) 3 ( 0.6) 3 ( 4.1) 0.044
## albner = 1 (%) 47 ( 8.8) 32 ( 6.9) 15 ( 20.5) <0.001
## shock = 1 (%) 218 ( 40.7) 156 ( 33.7) 62 ( 84.9) <0.001
## hosp_mortality = 1 (%) 73 ( 13.6) 0 ( 0.0) 73 (100.0) <0.001
## age_cate = 1 (%) 303 ( 56.5) 259 ( 55.9) 44 ( 60.3) 0.570
## bmi_cate = 1 (%) 111 ( 20.7) 101 ( 21.8) 10 ( 13.7) 0.151
## gcs_cate = 1 (%) 32 ( 6.0) 11 ( 2.4) 21 ( 28.8) <0.001
## cci_cate = 1 (%) 78 ( 14.6) 65 ( 14.0) 13 ( 17.8) 0.503
## bt_cate = 1 (%) 147 ( 27.4) 131 ( 28.3) 16 ( 21.9) 0.320
## sBP_cate = 1 (%) 134 ( 25.0) 78 ( 16.8) 56 ( 76.7) <0.001
## dBP_cate = 1 (%) 228 ( 42.5) 166 ( 35.9) 62 ( 84.9) <0.001
## hr_cate = 1 (%) 121 ( 22.6) 81 ( 17.5) 40 ( 54.8) <0.001
## bil_cate = 1 (%) 40 ( 7.5) 23 ( 5.0) 17 ( 23.3) <0.001
## ast_cate = 1 (%) 40 ( 7.5) 26 ( 5.6) 14 ( 19.2) <0.001
## alt_cate = 1 (%) 36 ( 6.7) 26 ( 5.6) 10 ( 13.7) 0.021
## wbc_cate = 1 (%) 89 ( 16.6) 73 ( 15.8) 16 ( 21.9) 0.253
## hb_cate = 1 (%) 230 ( 42.9) 193 ( 41.7) 37 ( 50.7) 0.188
## plt_cate = 1 (%) 274 ( 51.1) 236 ( 51.0) 38 ( 52.1) 0.963
## tp_cate = 1 (%) 211 ( 39.4) 175 ( 37.8) 36 ( 49.3) 0.081
## alb_cate = 1 (%) 233 ( 43.5) 175 ( 37.8) 58 ( 79.5) <0.001
## cre_cate = 1 (%) 62 ( 11.6) 37 ( 8.0) 25 ( 34.2) <0.001
## crp_cate = 1 (%) 47 ( 8.8) 30 ( 6.5) 17 ( 23.3) <0.001
## pt_cate = 1 (%) 247 ( 46.1) 200 ( 43.2) 47 ( 64.4) 0.001
## aptt_cate = 1 (%) 22 ( 4.1) 9 ( 1.9) 13 ( 17.8) <0.001
## Stratified by hosp_mortality
## SMD Missing
## n
## sex = F (%) 0.078 0.0
## barthel (%) 1.040 0.0
## 0
## 1
## 2
## child_score (%) 1.018 0.0
## 0
## 1
## 2
## pad = 1 (%) 0.066 0.0
## stroke = 1 (%) 0.210 0.0
## dimentia = 1 (%) 0.132 0.0
## ch_lung = 1 (%) 0.053 0.0
## rheumati = 1 (%) 0.114 0.0
## pept_ulcer = 1 (%) 0.450 0.0
## dm = 1 (%) 0.281 0.0
## dm_compli = 1 (%) 0.162 0.0
## paralysis = 0 (%) <0.001 0.0
## malignancy = 1 (%) 0.193 0.0
## meta_tumor = 1 (%) 0.301 0.0
## aids = 0 (%) <0.001 0.0
## eGFR30 = 1 (%) 0.454 0.0
## hd = 1 (%) 0.114 0.0
## hcc = 1 (%) 0.034 0.0
## alcohol = 1 (%) 0.178 0.0
## past_rupture = 1 (%) 0.270 0.0
## antiplate = 1 (%) 0.072 0.0
## anticoag = 1 (%) 0.066 0.0
## antithro = 1 (%) 0.072 0.0
## nsaids = 1 (%) 0.148 0.0
## steroid = 1 (%) 0.130 0.0
## beta = 1 (%) 0.284 0.0
## vaso = 1 (%) 0.751 0.0
## ffp = 1 (%) 0.635 0.0
## pc = 1 (%) 0.229 0.0
## albner = 1 (%) 0.404 0.0
## shock = 1 (%) 1.222 0.0
## hosp_mortality = 1 (%) NaN 0.0
## age_cate = 1 (%) 0.088 0.0
## bmi_cate = 1 (%) 0.214 0.0
## gcs_cate = 1 (%) 0.781 0.0
## cci_cate = 1 (%) 0.103 0.0
## bt_cate = 1 (%) 0.147 0.0
## sBP_cate = 1 (%) 1.500 0.0
## dBP_cate = 1 (%) 1.160 0.0
## hr_cate = 1 (%) 0.842 0.0
## bil_cate = 1 (%) 0.545 0.0
## ast_cate = 1 (%) 0.421 0.0
## alt_cate = 1 (%) 0.276 0.0
## wbc_cate = 1 (%) 0.158 0.0
## hb_cate = 1 (%) 0.181 0.0
## plt_cate = 1 (%) 0.022 0.0
## tp_cate = 1 (%) 0.234 0.0
## alb_cate = 1 (%) 0.933 0.0
## cre_cate = 1 (%) 0.679 0.0
## crp_cate = 1 (%) 0.486 0.0
## pt_cate = 1 (%) 0.435 0.0
## aptt_cate = 1 (%) 0.552 0.0
# specify your data and variables
tbl_summary(data = dev_imp,
by = "hosp_mortality",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | 0, N = 4631 | 1, N = 731 |
|---|---|---|
| sex | ||
| M | 352 (76%) | 53 (73%) |
| F | 111 (24%) | 20 (27%) |
| barthel | ||
| 0 | 186 (40%) | 7 (9.6%) |
| 1 | 142 (31%) | 12 (16%) |
| 2 | 135 (29%) | 54 (74%) |
| child_score | ||
| 0 | 65 (14%) | 1 (1.4%) |
| 1 | 271 (59%) | 20 (27%) |
| 2 | 127 (27%) | 52 (71%) |
| pad | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| stroke | ||
| 0 | 453 (98%) | 73 (100%) |
| 1 | 10 (2.2%) | 0 (0%) |
| dimentia | ||
| 0 | 459 (99%) | 73 (100%) |
| 1 | 4 (0.9%) | 0 (0%) |
| ch_lung | ||
| 0 | 454 (98%) | 71 (97%) |
| 1 | 9 (1.9%) | 2 (2.7%) |
| rheumati | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| pept_ulcer | ||
| 0 | 405 (87%) | 72 (99%) |
| 1 | 58 (13%) | 1 (1.4%) |
| dm | ||
| 0 | 365 (79%) | 65 (89%) |
| 1 | 98 (21%) | 8 (11%) |
| dm_compli | ||
| 0 | 457 (99%) | 73 (100%) |
| 1 | 6 (1.3%) | 0 (0%) |
| paralysis | ||
| 0 | 463 (100%) | 73 (100%) |
| malignancy | ||
| 0 | 417 (90%) | 61 (84%) |
| 1 | 46 (9.9%) | 12 (16%) |
| meta_tumor | ||
| 0 | 461 (100%) | 69 (95%) |
| 1 | 2 (0.4%) | 4 (5.5%) |
| aids | ||
| 0 | 463 (100%) | 73 (100%) |
| eGFR30 | ||
| 0 | 429 (93%) | 56 (77%) |
| 1 | 34 (7.3%) | 17 (23%) |
| hd | ||
| 0 | 460 (99%) | 73 (100%) |
| 1 | 3 (0.6%) | 0 (0%) |
| hcc | ||
| 0 | 368 (79%) | 57 (78%) |
| 1 | 95 (21%) | 16 (22%) |
| alcohol | ||
| 0 | 258 (56%) | 47 (64%) |
| 1 | 205 (44%) | 26 (36%) |
| past_rupture | ||
| 0 | 367 (79%) | 65 (89%) |
| 1 | 96 (21%) | 8 (11%) |
| antiplate | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| anticoag | ||
| 0 | 462 (100%) | 73 (100%) |
| 1 | 1 (0.2%) | 0 (0%) |
| antithro | ||
| 0 | 460 (99%) | 72 (99%) |
| 1 | 3 (0.6%) | 1 (1.4%) |
| nsaids | ||
| 0 | 458 (99%) | 73 (100%) |
| 1 | 5 (1.1%) | 0 (0%) |
| steroid | ||
| 0 | 462 (100%) | 72 (99%) |
| 1 | 1 (0.2%) | 1 (1.4%) |
| beta | ||
| 0 | 445 (96%) | 73 (100%) |
| 1 | 18 (3.9%) | 0 (0%) |
| vaso | ||
| 0 | 452 (98%) | 53 (73%) |
| 1 | 11 (2.4%) | 20 (27%) |
| ffp | ||
| 0 | 363 (78%) | 36 (49%) |
| 1 | 100 (22%) | 37 (51%) |
| pc | ||
| 0 | 460 (99%) | 70 (96%) |
| 1 | 3 (0.6%) | 3 (4.1%) |
| albner | ||
| 0 | 431 (93%) | 58 (79%) |
| 1 | 32 (6.9%) | 15 (21%) |
| shock | ||
| 0 | 307 (66%) | 11 (15%) |
| 1 | 156 (34%) | 62 (85%) |
| age | 62 (51.00, 70) | 66 (55.00, 74) |
| bmi | 23 (20.81, 25) | 23 (20.96, 24) |
| smoke | 200 (0.00, 413) | 180 (0.00, 400) |
| child_num | 8 (7.00, 10) | 11 (9.00, 12) |
| gcs | 15 (15.00, 15) | 15 (9.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| map | 4 (0.00, 4) | 6 (4.00, 8) |
| bt | 37 (36.30, 37) | 36 (36.00, 37) |
| sBP | 90 (82.00, 98) | 65 (59.00, 79) |
| dBP | 53 (46.00, 59) | 40 (33.00, 46) |
| hr | 80 (70.00, 93) | 101 (89.00, 112) |
| bil | 1 (0.90, 2) | 3 (1.66, 5) |
| ast | 55 (33.00, 90) | 84 (49.00, 153) |
| alt | 29 (20.00, 44) | 33 (25.00, 63) |
| wbc | 7,200 (5,315.00, 10,240) | 7,990 (6,200.00, 10,800) |
| hb | 8 (7.00, 10) | 8 (6.60, 10) |
| plt | 98 (73.00, 135) | 98 (76.00, 130) |
| tp | 6 (5.60, 7) | 6 (5.20, 6) |
| alb | 3 (2.60, 3) | 2 (1.80, 3) |
| eGFR | 71 (52.42, 92) | 44 (30.40, 58) |
| bun | 23 (15.50, 35) | 28 (18.10, 46) |
| cre | 1 (0.66, 1) | 1 (0.99, 2) |
| crp | 0 (0.11, 1) | 1 (0.40, 2) |
| pt | 54 (43.00, 64) | 40 (26.80, 55) |
| aptt | 28 (26.05, 32) | 32 (29.10, 44) |
| los | 10 (7.00, 18) | 4 (1.00, 16) |
| meld | 10 (7.00, 14) | 16 (13.00, 25) |
| pt_id | 359 (149.50, 583) | 426 (235.00, 599) |
| hosp_num | ||
| 1 | 404 (87%) | 68 (93%) |
| 2 | 43 (9.3%) | 5 (6.8%) |
| 3 | 15 (3.2%) | 0 (0%) |
| 4 | 1 (0.2%) | 0 (0%) |
| hosp_id | 1,010 (1,003.00, 1,024) | 1,017 (1,005.00, 1,024) |
| year | ||
| 2010 | 68 (15%) | 8 (11%) |
| 2011 | 70 (15%) | 9 (12%) |
| 2012 | 72 (16%) | 16 (22%) |
| 2013 | 55 (12%) | 15 (21%) |
| 2014 | 69 (15%) | 8 (11%) |
| 2015 | 67 (14%) | 5 (6.8%) |
| 2016 | 62 (13%) | 12 (16%) |
| age_cate | 259 (56%) | 44 (60%) |
| bmi_cate | 101 (22%) | 10 (14%) |
| gcs_cate | 11 (2.4%) | 21 (29%) |
| cci_cate | 65 (14%) | 13 (18%) |
| bt_cate | 131 (28%) | 16 (22%) |
| sBP_cate | 78 (17%) | 56 (77%) |
| dBP_cate | 166 (36%) | 62 (85%) |
| hr_cate | 81 (17%) | 40 (55%) |
| bil_cate | 23 (5.0%) | 17 (23%) |
| ast_cate | 26 (5.6%) | 14 (19%) |
| alt_cate | 26 (5.6%) | 10 (14%) |
| wbc_cate | 73 (16%) | 16 (22%) |
| hb_cate | 193 (42%) | 37 (51%) |
| plt_cate | 236 (51%) | 38 (52%) |
| tp_cate | 175 (38%) | 36 (49%) |
| alb_cate | 175 (38%) | 58 (79%) |
| cre_cate | 37 (8.0%) | 25 (34%) |
| crp_cate | 30 (6.5%) | 17 (23%) |
| pt_cate | 200 (43%) | 47 (64%) |
| aptt_cate | 9 (1.9%) | 13 (18%) |
| 1 n (%); Median (IQR) | ||
# "initial_vars" vector containing the names of variables
initial_vars <- c("sex", "barthel", "pept_ulcer", "dm", "malignancy", "hcc", "alcohol",
"past_rupture", "antithro", "steroid", "beta", "sBP_cate",
"age_cate", "bmi_cate", "gcs_cate", "bt_cate", "bil_cate", "ast_cate", "alt_cate",
"wbc_cate", "hb_cate", "plt_cate", "alb_cate", "cre_cate",
"crp_cate", "pt_cate","aptt_cate")
# Loop through each variable in "initial_vars" and print its class
for (var in initial_vars) {
print(paste(var, ": ", class(dev_imp[[var]]), sep=""))
}
## [1] "sex: factor"
## [1] "barthel: factor"
## [1] "pept_ulcer: factor"
## [1] "dm: factor"
## [1] "malignancy: factor"
## [1] "hcc: factor"
## [1] "alcohol: factor"
## [1] "past_rupture: factor"
## [1] "antithro: factor"
## [1] "steroid: factor"
## [1] "beta: factor"
## [1] "sBP_cate: numeric"
## [1] "age_cate: numeric"
## [1] "bmi_cate: numeric"
## [1] "gcs_cate: numeric"
## [1] "bt_cate: numeric"
## [1] "bil_cate: numeric"
## [1] "ast_cate: numeric"
## [1] "alt_cate: numeric"
## [1] "wbc_cate: numeric"
## [1] "hb_cate: numeric"
## [1] "plt_cate: numeric"
## [1] "alb_cate: numeric"
## [1] "cre_cate: numeric"
## [1] "crp_cate: numeric"
## [1] "pt_cate: numeric"
## [1] "aptt_cate: numeric"
# 変数リストの設定(応答変数を除外)
initial_vars <- c("sex", "barthel", "pept_ulcer", "dm", "malignancy", "hcc", "alcohol",
"past_rupture", "antithro", "steroid", "beta", "sBP_cate",
"age_cate", "bmi_cate", "gcs_cate", "bt_cate", "bil_cate", "ast_cate", "alt_cate",
"wbc_cate", "hb_cate", "plt_cate", "alb_cate", "cre_cate",
"crp_cate", "pt_cate","aptt_cate")
# one-hot encoding を行う
x <- model.matrix(~.-1, dev_imp[initial_vars])
# y のデータ型変換
y <- as.numeric(as.character(dev_imp$hosp_mortality))
# 乱数のシードを設定
set.seed(2023)
# cv.glmnetを用いた1SE ruleによるLasso
cvfit <- cv.glmnet(x, y, family = "binomial")
# lambda.1seを用いての最適モデルの選択
lasso_model <- glmnet(x, y, family = "binomial", alpha = 1, lambda = cvfit$lambda.1se)
# 変数の重要度の表示
coef(lasso_model)
## 30 x 1 sparse Matrix of class "dgCMatrix"
## s0
## (Intercept) -3.1080828
## sexM .
## sexF .
## barthel1 .
## barthel2 0.3591292
## pept_ulcer1 .
## dm1 .
## malignancy1 .
## hcc1 .
## alcohol1 .
## past_rupture1 .
## antithro1 .
## steroid1 .
## beta1 .
## sBP_cate 1.6587327
## age_cate .
## bmi_cate .
## gcs_cate 0.9321486
## bt_cate .
## bil_cate 0.5057012
## ast_cate 0.3036268
## alt_cate .
## wbc_cate .
## hb_cate .
## plt_cate .
## alb_cate 0.3194390
## cre_cate 0.5613715
## crp_cate .
## pt_cate .
## aptt_cate .
# hosp_mortalityを数値に変換
dev_imp$hosp_mortality <- as.numeric(as.character(dev_imp$hosp_mortality))
# 予測変数として選択された変数を使って新たにモデルを作成
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp)
# 予測確率を計算
dev_imp$fitted <- predict(fit_reduced_model, type="fitted")
# Calibration in large
calibration <- mean(dev_imp$hosp_mortality) - mean(dev_imp$fitted)
fitstat <- data.frame(Name = "Calibration in the large", Value = calibration)
# Brier Score
dev_imp$diff2 <- (dev_imp$fitted - dev_imp$hosp_mortality)^2
brier_score <- mean(dev_imp$diff2)
fitstat <- rbind(fitstat, data.frame(Name = "Brier score", Value = brier_score))
# Pseudo R-square
pseudo_r2 <- fit_reduced_model$stats["R2"]
fitstat <- rbind(fitstat, data.frame(Name = "R2", Value = pseudo_r2))
# AIC
aic <- AIC(fit_reduced_model)
fitstat <- rbind(fitstat, data.frame(Name = "AIC", Value = aic))
# Change the display option
options(scipen = 999)
# Display the final table
fitstat
## Name Value
## 1 Calibration in the large -0.000000000000006550316
## 2 Brier score 0.073454728134995303512
## R2 R2 0.475050602314298686668
## 11 AIC 276.721995401118419977138
# Load necessary libraries
library(pROC)
library(ggplot2)
# Re-run the model using the selected variables from earlier
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp)
# Calculate fitted probabilities
dev_imp$fitted <- predict(fit_reduced_model, type="fitted")
# Create ROC object, setting the response variable and predictor
roc_obj <- roc(dev_imp$hosp_mortality ~ dev_imp$fitted, ci=TRUE, direction="auto")
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# Plot ROC curve
roc_plot <- ggroc(roc_obj)
# Add the theme you used before. For example, if you used theme_minimal:
roc_plot <- roc_plot + theme_minimal()
# Calculate AUC and its confidence interval
auc_roc <- auc(roc_obj)
ci <- ci.auc(roc_obj)
# Calculate the upper bound of the CI
upper_bound <- 2*auc_roc - ci[1]
# Print the AUC and its confidence interval
cat("AUC for the development logistic model: ", auc_roc, "\n")
## AUC for the development logistic model: 0.8929702
cat("95% CI for AUC: (", ci[1], ",", upper_bound, ")\n")
## 95% CI for AUC: ( 0.8517855 , 0.9341549 )
# Load necessary libraries
library(pROC)
library(ggplot2)
# Re-run the model using the selected variables from earlier
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp)
# Calculate fitted probabilities
dev_imp$fitted <- predict(fit_reduced_model, type="fitted")
# Create ROC object, setting the response variable and predictor
roc_obj <- roc(dev_imp$hosp_mortality ~ dev_imp$fitted, ci=TRUE, direction="auto")
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# Plot ROC curve
plot(roc_obj, main="ROC curve for the development logistic model")
cat("AUC for the development logistic mode: ", auc(roc_obj), "\n")
## AUC for the development logistic mode: 0.8929702
# Create calibration plot
val.prob(dev_imp$fitted, dev_imp$hosp_mortality, g=10, cex=.5)
## Dxy C (ROC) R2
## 0.785940412438237868 0.892970206219118934 0.475050602314298687
## D D:Chi-sq D:p
## 0.300237863386685511 161.927494775263426163 NA
## U U:Chi-sq U:p
## -0.003731343283587074 -0.000000000002671641 1.000000000000000000
## Q Brier Intercept
## 0.303969206670272607 0.073454728134995304 -0.000000017419766933
## Slope Emax E90
## 0.999999955867797774 0.048121596917522713 0.032431296179175229
## Eavg S:z S:p
## 0.011111481083250529 0.104868317048665949 0.916480299643699703
# Re-run the model using the selected variables from earlier
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp, x = TRUE, y = TRUE)
# RMSの関数を使用してブートストラップによる内的検証を実行
cv <- validate(fit_reduced_model, bw = FALSE, B = 1000, method = "boot", seed = 2023)
# Corrected AUCの計算
corrected_AUC <- cv[1, 5] * 0.5 + 0.5
# 結果の表示
cv
## index.orig training test optimism index.corrected n
## Dxy 0.7859 0.7885 0.7799 0.0086 0.7773 1000
## R2 0.4751 0.4858 0.4649 0.0209 0.4541 1000
## Intercept 0.0000 0.0000 -0.0332 0.0332 -0.0332 1000
## Slope 1.0000 1.0000 0.9575 0.0425 0.9575 1000
## Emax 0.0000 0.0000 0.0153 0.0153 0.0153 1000
## D 0.3002 0.3082 0.2927 0.0155 0.2847 1000
## U -0.0037 -0.0037 0.0008 -0.0045 0.0008 1000
## Q 0.3040 0.3119 0.2919 0.0200 0.2839 1000
## B 0.0735 0.0716 0.0752 -0.0036 0.0771 1000
## g 1.7729 1.8310 1.7336 0.0974 1.6755 1000
## gp 0.1830 0.1837 0.1809 0.0028 0.1802 1000
print("corrected_AUC")
## [1] "corrected_AUC"
print(corrected_AUC)
## [1] 0.8886563
信頼区間も出す
# 必要なパッケージの読み込み
library(pROC)
# 各ブートストラップサンプルでAUCを保存するためのベクトルの初期化
aucs <- numeric(1000)
# ブートストラップ検証
set.seed(2023) # 再現性のための固定シード
for(i in 1:1000) {
# ブートストラップサンプルの作成
sample_rows <- sample(nrow(dev_imp), replace = TRUE)
boot_data <- dev_imp[sample_rows, ]
# モデルのフィット
fit <- lrm(hosp_mortality ~ sBP_cate + gcs_cate + bil_cate + cre_cate + alb_cate, data = boot_data)
# 予測値の計算とAUCの保存
predictions <- predict(fit, type = "fitted")
aucs[i] <- auc(roc(response = boot_data$hosp_mortality, predictor = predictions))
}
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# 信頼区間の計算と表示
ci <- quantile(aucs, c(0.025, 0.975))
cat("Bootstrap 95% CI for AUC: (", ci[1], ",", ci[2], ")\n")
## Bootstrap 95% CI for AUC: ( 0.8511255 , 0.9336095 )
# Load necessary library
library(boot)
##
## 次のパッケージを付け加えます: 'boot'
## 以下のオブジェクトは 'package:car' からマスクされています:
##
## logit
# Define a function to calculate the metrics
calc_metrics <- function(data, indices) {
data_boot <- data[indices, ]
fit_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = data_boot, x = TRUE, y = TRUE)
predicted <- predict(fit_model, type="fitted")
calibration <- mean(data_boot$hosp_mortality) - mean(predicted)
brier_score <- mean((predicted - data_boot$hosp_mortality)^2)
pseudo_r2 <- fit_model$stats["R2"]
aic <- AIC(fit_model)
return(c(calibration, brier_score, pseudo_r2, aic))
}
# Bootstrap resampling
set.seed(2023)
results <- boot(data = dev_imp, statistic = calc_metrics, R = 1000)
# Display the results
print(results)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = dev_imp, statistic = calc_metrics, R = 1000)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* -0.000000000000006550316 -0.0000000002632681 0.000000000832181
## t2* 0.073454728134995303512 -0.0018562953655518 0.007852877871734
## t3* 0.475050602314298686668 0.0111910058009889 0.053665254793312
## t4* 276.721995401118419977138 -6.4009702886535820 26.279785715103650
###準備
# vari_cat.f (defined as above) in the data_original is changed to factor type and set into data_factor_for_imp
data_factor_for_imp_val <- as.data.frame(lapply(df_val[vari_cat.f],as.factor))
#check all the variable is factor
str(data_factor_for_imp_val)
## 'data.frame': 444 obs. of 32 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": NA 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 NA 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
#summary numeric type
data_numeric_for_imp_val <- as.data.frame(lapply(df_val[vari_numeric],as.numeric))
# check all the variable is numeric
str(data_numeric_for_imp_val)
## 'data.frame': 444 obs. of 27 variables:
## $ age : num 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : num 270 0 0 0 0 135 NA 0 0 0 ...
## $ child_num: num 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : num 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : num 4 4 4 3 6 5 4 4 5 5 ...
## $ map : num 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 NA 36.9 37.1 37.2 36.1 36.5 37 37 36 ...
## $ sBP : num 102 NA 95 111 125 116 102 96 97 71 ...
## $ dBP : num 67 NA 49 68 70 84 88 55 54 49 ...
## $ hr : num 83 NA 60 101 121 56 79 72 75 56 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 NA 5.9 6.1 7 6.8 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 NA 29.1 30.2 33.1 30.2 ...
## $ los : num 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : num 20 6 10 9 10 6 10 7 6 17 ...
# combine the factor type and numeric type
data_for_imp_val <- cbind(data_factor_for_imp_val, data_numeric_for_imp_val)
#check all the variable type
str(data_for_imp_val)
## 'data.frame': 444 obs. of 59 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": NA 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 NA 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ age : num 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : num 270 0 0 0 0 135 NA 0 0 0 ...
## $ child_num : num 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : num 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : num 4 4 4 3 6 5 4 4 5 5 ...
## $ map : num 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 NA 36.9 37.1 37.2 36.1 36.5 37 37 36 ...
## $ sBP : num 102 NA 95 111 125 116 102 96 97 71 ...
## $ dBP : num 67 NA 49 68 70 84 88 55 54 49 ...
## $ hr : num 83 NA 60 101 121 56 79 72 75 56 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 NA 5.9 6.1 7 6.8 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 NA 29.1 30.2 33.1 30.2 ...
## $ los : num 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : num 20 6 10 9 10 6 10 7 6 17 ...
###実行
cores <- detectCores(logical = FALSE) ###並列化処理
registerDoParallel(cores = cores) ###並列化処理
set.seed(2023)
md.pattern(data_for_imp_val) #see patern the missing
## sex pad stroke dimentia ch_lung rheumati pept_ulcer dm dm_compli paralysis
## 269 1 1 1 1 1 1 1 1 1 1
## 13 1 1 1 1 1 1 1 1 1 1
## 9 1 1 1 1 1 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1 0 1 1 1 1 3
## 2 0 1 1 1 1 0 1 1 1 1 1 1 2
## 1 0 1 0 1 1 0 1 1 0 1 0 1 5
## 1 1 1 0 1 1 0 1 1 1 0 1 1 4
## 1 1 0 1 1 1 0 1 0 1 1 1 1 4
## 6 0 0 0 0 1 0 1 0 1 1 1 0 16
## 1 0 0 0 0 1 0 1 0 0 1 0 0 18
## 2 1 1 1 1 1 1 0 1 1 1 1 1 2
## 1 1 1 1 1 0 1 1 1 1 1 1 1 3
## 1 1 1 1 1 1 1 1 1 1 0 1 1 4
## 1 1 1 1 1 1 1 1 0 1 1 1 1 4
## 1 1 1 1 1 1 1 1 1 1 1 1 1 5
## 10 12 15 20 24 26 30 32 35 42 48 49 423
imp.mf_val <- missForest(data_for_imp_val,
maxiter = 10,
ntree = 100,
mtry = floor(sqrt(ncol(data_for_imp_val))),
parallelize = "variables",
verbose = TRUE)
## parallelizing over the variables of the input data matrix 'xmis'
## missForest iteration 1 in progress...done!
## estimated error(s): 0.453138 0.02131973
## difference(s): 0.00009726191 0.001618806
## time: 1.056 seconds
##
## missForest iteration 2 in progress...done!
## estimated error(s): 0.4419382 0.0192313
## difference(s): 0.0001107889 0.0004222973
## time: 0.934 seconds
##
## missForest iteration 3 in progress...done!
## estimated error(s): 0.4409547 0.0197921
## difference(s): 0.0000704322 0.0005630631
## time: 0.93 seconds
##
## missForest iteration 4 in progress...done!
## estimated error(s): 0.4446167 0.02060827
## difference(s): 0.00007781678 0.0004222973
## time: 0.912 seconds
##
## missForest iteration 5 in progress...done!
## estimated error(s): 0.4480345 0.01957716
## difference(s): 0.00005413141 0.0005630631
## time: 0.89 seconds
##
## missForest iteration 6 in progress...done!
## estimated error(s): 0.4424111 0.01935843
## difference(s): 0.00005504244 0.0003519144
## time: 0.937 seconds
##
## missForest iteration 7 in progress...done!
## estimated error(s): 0.44556 0.01935092
## difference(s): 0.00008066198 0.0004222973
## time: 0.952 seconds
summary(imp.mf_val$ximp)
## sex barthel child_score pad stroke dimentia ch_lung rheumati
## M:329 0:174 0: 83 0:443 0:433 0:438 0:440 0:444
## F:115 1:141 1:240 1: 1 1: 11 1: 6 1: 4 1: 0
## 2:129 2:121
##
##
##
## pept_ulcer dm dm_compli paralysis malignancy meta_tumor aids eGFR30
## 0:402 0:340 0:437 0:444 0:387 0:433 0:444 0:408
## 1: 42 1:104 1: 7 1: 57 1: 11 1: 36
##
##
##
##
## hd hcc alcohol past_rupture antiplate anticoag antithro nsaids
## 0:434 0:380 0:203 0:323 0:441 0:441 0:438 0:440
## 1: 10 1: 64 1:241 1:121 1: 3 1: 3 1: 6 1: 4
##
##
##
##
## steroid beta vaso ffp pc albner shock hosp_mortality
## 0:441 0:404 0:417 0:290 0:433 0:411 0:248 0:399
## 1: 3 1: 40 1: 27 1:154 1: 11 1: 33 1:196 1: 45
##
##
##
##
## age bmi smoke child_num
## Min. :24.00 Min. : 15.28 Min. : 0.0 Min. : 5.000
## 1st Qu.:50.00 1st Qu.: 20.76 1st Qu.: 0.0 1st Qu.: 7.000
## Median :60.00 Median : 23.11 Median : 0.0 Median : 8.000
## Mean :60.42 Mean : 24.37 Mean : 228.5 Mean : 8.426
## 3rd Qu.:70.00 3rd Qu.: 25.99 3rd Qu.: 320.0 3rd Qu.:10.000
## Max. :93.00 Max. :339.76 Max. :2100.0 Max. :14.000
## gcs cci_num map bt
## Min. : 3.00 Min. : 3.000 Min. : 0.000 Min. :33.90
## 1st Qu.:15.00 1st Qu.: 4.000 1st Qu.: 0.000 1st Qu.:36.50
## Median :15.00 Median : 4.000 Median : 4.000 Median :36.80
## Mean :14.61 Mean : 4.505 Mean : 3.214 Mean :36.81
## 3rd Qu.:15.00 3rd Qu.: 5.000 3rd Qu.: 4.000 3rd Qu.:37.10
## Max. :15.00 Max. :13.000 Max. :20.000 Max. :40.20
## sBP dBP hr bil
## Min. : 50.00 Min. :22.00 Min. : 41.00 Min. : 0.200
## 1st Qu.: 80.00 1st Qu.:46.00 1st Qu.: 73.00 1st Qu.: 1.000
## Median : 91.08 Median :54.00 Median : 85.00 Median : 1.660
## Mean : 89.96 Mean :54.84 Mean : 88.46 Mean : 2.415
## 3rd Qu.:100.00 3rd Qu.:63.00 3rd Qu.:101.00 3rd Qu.: 2.993
## Max. :149.00 Max. :92.00 Max. :160.00 Max. :16.180
## ast alt wbc hb
## Min. : 13.00 Min. : 7.00 Min. : 2100 Min. : 2.100
## 1st Qu.: 32.00 1st Qu.: 19.00 1st Qu.: 5800 1st Qu.: 7.200
## Median : 50.00 Median : 29.00 Median : 8215 Median : 8.800
## Mean : 82.03 Mean : 39.96 Mean : 9046 Mean : 8.952
## 3rd Qu.: 88.25 3rd Qu.: 44.00 3rd Qu.:11070 3rd Qu.:10.500
## Max. :1122.00 Max. :462.00 Max. :58400 Max. :16.500
## plt tp alb eGFR
## Min. : 16.00 Min. :3.000 Min. :1.400 Min. : 5.057
## 1st Qu.: 75.75 1st Qu.:5.600 1st Qu.:2.500 1st Qu.: 49.568
## Median : 103.00 Median :6.100 Median :2.900 Median : 67.749
## Mean : 117.56 Mean :6.149 Mean :2.911 Mean : 70.869
## 3rd Qu.: 140.25 3rd Qu.:6.700 3rd Qu.:3.400 3rd Qu.: 90.404
## Max. :1073.00 Max. :9.000 Max. :4.900 Max. :186.229
## bun cre crp pt
## Min. : 3.50 Min. :0.300 Min. : 0.0000 Min. : 9.99
## 1st Qu.: 16.48 1st Qu.:0.650 1st Qu.: 0.1195 1st Qu.: 46.20
## Median : 24.90 Median :0.820 Median : 0.2890 Median : 59.41
## Mean : 28.51 Mean :1.046 Mean : 0.8568 Mean : 59.11
## 3rd Qu.: 36.40 3rd Qu.:1.110 3rd Qu.: 0.7615 3rd Qu.: 72.00
## Max. :107.80 Max. :9.080 Max. :18.9370 Max. :100.20
## aptt los meld
## Min. : 18.90 Min. : 0.00 Min. : 6.00
## 1st Qu.: 29.84 1st Qu.: 5.00 1st Qu.: 6.00
## Median : 32.40 Median : 7.00 Median :10.00
## Mean : 35.85 Mean : 10.67 Mean :11.57
## 3rd Qu.: 37.18 3rd Qu.: 13.00 3rd Qu.:15.00
## Max. :200.01 Max. :217.00 Max. :40.00
md.pattern(imp.mf_val$ximp)
## /\ /\
## { `---' }
## { O O }
## ==> V <== No need for mice. This data set is completely observed.
## \ \|/ /
## `-----'
## sex barthel child_score pad stroke dimentia ch_lung rheumati pept_ulcer dm
## 444 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0
## dm_compli paralysis malignancy meta_tumor aids eGFR30 hd hcc alcohol
## 444 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0
## past_rupture antiplate anticoag antithro nsaids steroid beta vaso ffp pc
## 444 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0
## albner shock hosp_mortality age bmi smoke child_num gcs cci_num map bt sBP
## 444 1 1 1 1 1 1 1 1 1 1 1 1
## 0 0 0 0 0 0 0 0 0 0 0 0
## dBP hr bil ast alt wbc hb plt tp alb eGFR bun cre crp pt aptt los meld
## 444 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#if exclude ID is necessary add the ID
data_imp_val <- imp.mf_val$ximp
data_imp_val$pt_id <- df_val$pt_id
data_imp_val$hosp_num<- df_val$hosp_num
data_imp_val$hosp_id<- df_val$hosp_id
data_imp_val$year<- df_val$year
#check
str(data_imp_val)
## 'data.frame': 444 obs. of 63 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 2 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ age : num 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : num 270 0 0 0 0 ...
## $ child_num : num 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : num 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : num 4 4 4 3 6 5 4 4 5 5 ...
## $ map : num 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 36.8 36.9 37.1 37.2 ...
## $ sBP : num 102 91.2 95 111 125 ...
## $ dBP : num 67 54.3 49 68 70 ...
## $ hr : num 83 82.3 60 101 121 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 ...
## $ los : num 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : num 20 6 10 9 10 6 10 7 6 17 ...
## $ pt_id : int 6 17 24 32 33 37 38 40 42 44 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1002 1002 1003 1003 1003 1003 1003 1003 ...
## $ year : int 2017 2019 2022 2022 2022 2017 2022 2020 2021 2022 ...
#write the csv
#write.csv(imp.mf$ximp, file = "data_after_imputation.csv")
str(data_imp_val)
## 'data.frame': 444 obs. of 63 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 2 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ age : num 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : num 270 0 0 0 0 ...
## $ child_num : num 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : num 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : num 4 4 4 3 6 5 4 4 5 5 ...
## $ map : num 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 36.8 36.9 37.1 37.2 ...
## $ sBP : num 102 91.2 95 111 125 ...
## $ dBP : num 67 54.3 49 68 70 ...
## $ hr : num 83 82.3 60 101 121 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 ...
## $ los : num 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : num 20 6 10 9 10 6 10 7 6 17 ...
## $ pt_id : int 6 17 24 32 33 37 38 40 42 44 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1002 1002 1003 1003 1003 1003 1003 1003 ...
## $ year : int 2017 2019 2022 2022 2022 2017 2022 2020 2021 2022 ...
data_imp_val$meld
## [1] 20.000000 6.000000 10.000000 9.000000 10.000000 6.000000 10.000000
## [8] 7.000000 6.000000 17.000000 11.000000 14.000000 10.284000 13.000000
## [15] 16.000000 16.000000 30.000000 6.000000 13.000000 40.000000 15.000000
## [22] 12.000000 15.000000 6.000000 13.000000 6.000000 9.000000 12.000000
## [29] 9.000000 8.000000 17.000000 7.000000 13.000000 15.000000 6.000000
## [36] 9.000000 6.000000 11.000000 7.000000 6.000000 11.000000 14.000000
## [43] 24.000000 16.000000 14.000000 15.000000 17.000000 6.000000 15.000000
## [50] 12.000000 20.000000 11.000000 8.000000 13.000000 10.000000 9.000000
## [57] 10.000000 6.000000 6.000000 17.000000 6.000000 14.000000 15.000000
## [64] 6.000000 11.000000 15.000000 13.270000 10.000000 12.000000 10.000000
## [71] 10.000000 8.000000 23.000000 16.000000 17.510000 15.000000 15.000000
## [78] 14.000000 6.000000 14.000000 11.000000 10.000000 6.000000 6.000000
## [85] 15.000000 12.000000 10.000000 6.000000 6.000000 6.000000 10.000000
## [92] 18.000000 13.000000 6.000000 6.000000 11.000000 6.000000 11.000000
## [99] 19.000000 6.000000 13.000000 13.000000 13.000000 6.000000 15.876667
## [106] 10.270000 8.760000 10.000000 11.000000 16.000000 18.000000 6.000000
## [113] 6.000000 17.000000 24.000000 8.000000 22.000000 26.000000 15.000000
## [120] 8.000000 14.000000 12.000000 6.000000 16.000000 9.000000 14.000000
## [127] 6.000000 23.000000 8.000000 11.000000 6.000000 6.000000 9.000000
## [134] 12.000000 7.000000 24.000000 26.000000 13.720000 6.000000 23.000000
## [141] 7.000000 13.000000 17.000000 16.000000 6.000000 6.000000 7.000000
## [148] 33.000000 6.000000 11.000000 11.000000 6.000000 15.000000 6.000000
## [155] 26.000000 14.100000 8.754286 6.000000 7.000000 6.000000 6.886667
## [162] 6.670000 9.000000 6.000000 9.000000 12.000000 16.000000 12.000000
## [169] 6.000000 12.000000 6.000000 6.000000 6.000000 6.000000 12.000000
## [176] 20.000000 22.000000 6.000000 11.000000 7.000000 10.000000 8.000000
## [183] 6.000000 7.000000 6.000000 14.000000 14.000000 27.000000 14.000000
## [190] 6.000000 14.000000 10.000000 6.000000 6.000000 7.000000 13.000000
## [197] 23.000000 7.000000 6.000000 12.000000 6.000000 32.000000 15.000000
## [204] 6.000000 19.000000 6.000000 8.000000 15.000000 6.000000 18.000000
## [211] 8.180000 9.000000 6.000000 7.000000 17.000000 13.000000 6.000000
## [218] 9.000000 8.000000 8.000000 9.000000 24.000000 7.000000 9.000000
## [225] 12.000000 6.000000 6.000000 13.000000 6.000000 8.000000 12.000000
## [232] 12.000000 15.000000 29.000000 33.000000 8.000000 8.000000 23.000000
## [239] 22.000000 12.000000 12.000000 12.000000 7.000000 6.000000 8.000000
## [246] 6.000000 7.000000 8.000000 19.000000 15.000000 20.000000 14.000000
## [253] 12.000000 16.000000 15.000000 6.000000 6.364286 6.484286 6.000000
## [260] 6.754286 6.754286 6.854286 16.000000 6.000000 16.000000 6.000000
## [267] 6.000000 14.000000 8.942000 12.000000 22.000000 12.000000 10.000000
## [274] 19.000000 6.000000 8.000000 8.000000 11.000000 11.000000 8.000000
## [281] 7.134286 6.000000 6.000000 16.000000 18.000000 8.000000 8.000000
## [288] 8.000000 7.000000 8.000000 14.000000 10.000000 10.000000 11.000000
## [295] 6.000000 8.000000 9.000000 11.000000 8.000000 17.000000 6.000000
## [302] 6.000000 6.000000 6.000000 14.000000 15.000000 12.000000 13.000000
## [309] 9.750000 19.000000 11.000000 15.000000 20.000000 6.000000 21.000000
## [316] 11.000000 16.000000 13.000000 6.000000 6.000000 15.000000 18.000000
## [323] 10.000000 17.000000 12.000000 6.000000 12.000000 15.000000 16.000000
## [330] 6.000000 6.000000 7.000000 7.000000 32.000000 9.000000 24.000000
## [337] 15.000000 6.000000 11.000000 6.000000 6.000000 6.000000 6.000000
## [344] 6.000000 7.000000 25.000000 10.000000 7.000000 9.000000 26.000000
## [351] 19.000000 10.390000 14.610000 6.700000 9.000000 14.000000 11.000000
## [358] 8.000000 6.000000 6.000000 24.000000 15.000000 14.000000 11.000000
## [365] 8.000000 8.000000 7.000000 13.000000 20.000000 15.000000 8.000000
## [372] 6.000000 11.000000 14.000000 11.000000 11.000000 6.000000 6.000000
## [379] 6.000000 23.000000 20.000000 9.000000 29.000000 6.000000 6.000000
## [386] 11.000000 6.000000 8.000000 8.000000 6.000000 6.000000 13.000000
## [393] 19.000000 10.000000 6.000000 15.000000 6.000000 18.000000 21.000000
## [400] 6.000000 10.000000 19.000000 26.000000 6.000000 19.000000 23.000000
## [407] 16.000000 6.000000 8.000000 6.000000 14.000000 19.000000 15.000000
## [414] 14.000000 22.000000 11.000000 11.000000 7.000000 19.730000 15.000000
## [421] 11.000000 18.000000 20.000000 6.000000 6.000000 8.510000 6.000000
## [428] 6.000000 6.000000 15.000000 6.000000 6.000000 16.000000 6.000000
## [435] 11.000000 22.000000 20.000000 7.000000 6.000000 9.000000 6.000000
## [442] 6.000000 12.000000 10.000000
data_imp_val$meld <- round(data_imp_val$meld)
val_imp <-
data_imp_val|>
mutate(
hosp_id=as.integer(hosp_id),
pt_id=as.integer(pt_id),
hosp_num=as.integer(hosp_num),
year=as.integer(year),
age=as.integer(age),
sex= factor(sex, levels = c("M", "F")),
smoke= as.integer(smoke),
barthel= factor(barthel, levels = c("0", "1", "2")),
child_num= as.integer(round(data_imp_val$child_num)),
child_score=factor(child_score, levels = c("0", "1", "2")),
gcs=as.integer(gcs),
cci_num=as.integer(cci_num),
pad=factor(pad),
stroke=factor(stroke),
dimentia=factor(dimentia),
ch_lung=factor(ch_lung),
rheumati=factor(rheumati),
pept_ulcer=factor(pept_ulcer),
dm=factor(dm),
dm_compli=factor(dm_compli),
paralysis=factor(paralysis),
malignancy=factor(malignancy),
meta_tumor=factor(meta_tumor),
aids=factor(aids),
eGFR30=factor(eGFR30),
hd=factor(hd),
hcc=factor(hcc),
alcohol=factor(alcohol),
past_rupture=factor(past_rupture),
antiplate=factor(antiplate),
anticoag=factor(anticoag),
antithro=factor(antithro),
nsaids=factor(nsaids),
steroid=factor(steroid),
beta=factor(beta),
vaso=factor(vaso),
map= as.integer(map),
ffp=factor(ffp),
pc=factor(pc),
albner=factor(albner),
sBP= as.integer(sBP),
dBP= as.integer(dBP),
hr=as.integer(hr),
shock=factor(shock),
los=as.integer(los),
meld=as.integer(meld)
)
#新規カテゴリ列を作成
val_imp$age_cate <- ifelse(val_imp$age >= 60, 1, 0)
val_imp$bmi_cate <- ifelse(val_imp$bmi >= 25, 1, 0) # bmiは25以上:1, 25未満:0
val_imp$gcs_cate <- ifelse(val_imp$gcs < 12, 1, 0)
val_imp$cci_cate <- ifelse(val_imp$cci_num >= 6, 1, 0)
val_imp$bt_cate <- ifelse(val_imp$bt >= 37, 1, 0)
val_imp$sBP_cate <- ifelse(val_imp$sBP < 80, 1, 0)
val_imp$dBP_cate <- ifelse(val_imp$dBP < 50, 1, 0)
val_imp$hr_cate <- ifelse(val_imp$hr >= 100, 1, 0)
val_imp$bil_cate <- ifelse(val_imp$bil >= 5, 1, 0)
val_imp$ast_cate <- ifelse(val_imp$ast >= 200, 1, 0)
val_imp$alt_cate <- ifelse(val_imp$alt >= 100, 1, 0)
val_imp$wbc_cate <- ifelse(val_imp$wbc >= 12000, 1, 0)
val_imp$hb_cate <- ifelse(val_imp$hb < 8, 1, 0)
val_imp$plt_cate <- ifelse(val_imp$plt < 100, 1, 0) # pltは100未満:1、100以上:0
val_imp$tp_cate <- ifelse(val_imp$tp < 6, 1, 0)
val_imp$alb_cate <- ifelse(val_imp$alb < 2.8, 1, 0)
val_imp$cre_cate <- ifelse(val_imp$cre >= 1.5, 1, 0)
val_imp$crp_cate <- ifelse(val_imp$crp >= 2, 1, 0)
val_imp$pt_cate <- ifelse(val_imp$pt < 50, 1, 0)
val_imp$aptt_cate <- ifelse(val_imp$aptt >= 50, 1, 0) # apttは50以上:1, 50未満:0
str(val_imp)
## 'data.frame': 444 obs. of 83 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 2 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ age : int 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : int 270 0 0 0 0 135 435 0 0 0 ...
## $ child_num : int 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : int 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : int 4 4 4 3 6 5 4 4 5 5 ...
## $ map : int 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 36.8 36.9 37.1 37.2 ...
## $ sBP : int 102 91 95 111 125 116 102 96 97 71 ...
## $ dBP : int 67 54 49 68 70 84 88 55 54 49 ...
## $ hr : int 83 82 60 101 121 56 79 72 75 56 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 ...
## $ los : int 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : int 20 6 10 9 10 6 10 7 6 17 ...
## $ pt_id : int 6 17 24 32 33 37 38 40 42 44 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1002 1002 1003 1003 1003 1003 1003 1003 ...
## $ year : int 2017 2019 2022 2022 2022 2017 2022 2020 2021 2022 ...
## $ age_cate : num 0 1 1 0 1 0 0 1 1 0 ...
## $ bmi_cate : num 0 0 1 0 0 1 1 1 0 1 ...
## $ gcs_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ cci_cate : num 0 0 0 0 1 0 0 0 0 0 ...
## $ bt_cate : num 0 0 0 1 1 0 0 1 1 0 ...
## $ sBP_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ dBP_cate : num 0 0 1 0 0 0 0 0 0 1 ...
## $ hr_cate : num 0 0 0 1 1 0 0 0 0 0 ...
## $ bil_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ ast_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ alt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ wbc_cate : num 0 1 0 1 0 0 0 0 0 0 ...
## $ hb_cate : num 0 1 1 0 0 0 1 0 0 1 ...
## $ plt_cate : num 1 0 0 0 0 1 0 1 0 0 ...
## $ tp_cate : num 1 1 1 1 1 0 1 0 0 0 ...
## $ alb_cate : num 1 1 0 0 0 0 0 0 0 1 ...
## $ cre_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ crp_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ pt_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ aptt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
col_fact_cate=c("sex","barthel","child_score","pad","stroke","dimentia","ch_lung","rheumati","pept_ulcer","dm","dm_compli","paralysis","malignancy","meta_tumor","aids","eGFR30","hd","hcc","alcohol","past_rupture","antiplate","anticoag","antithro","nsaids","steroid","beta", "vaso","ffp","pc", "albner","shock","hosp_mortality","age_cate","bmi_cate","gcs_cate","cci_cate","bt_cate","sBP_cate","dBP_cate","hr_cate","bil_cate","ast_cate","alt_cate","wbc_cate","hb_cate","plt_cate","tp_cate","alb_cate","cre_cate","crp_cate","pt_cate","aptt_cate")
# Create your table
val_imp %>%
select(c(col_fact_cate)) %>%
CreateTableOne(vars = c(col_fact_cate), strata="hosp_mortality",factorVars = col_fact_cate, addOverall = T) -> tableone_dev_imp_cate
# Print your table
print(tableone_dev_imp_cate, smd = TRUE, missing = TRUE, test = TRUE, explain = TRUE)
## Stratified by hosp_mortality
## Overall 0 1 p test
## n 444 399 45
## sex = F (%) 115 ( 25.9) 103 ( 25.8) 12 ( 26.7) 1.000
## barthel (%) <0.001
## 0 174 ( 39.2) 170 ( 42.6) 4 ( 8.9)
## 1 141 ( 31.8) 130 ( 32.6) 11 ( 24.4)
## 2 129 ( 29.1) 99 ( 24.8) 30 ( 66.7)
## child_score (%) <0.001
## 0 83 ( 18.7) 81 ( 20.3) 2 ( 4.4)
## 1 240 ( 54.1) 227 ( 56.9) 13 ( 28.9)
## 2 121 ( 27.3) 91 ( 22.8) 30 ( 66.7)
## pad = 1 (%) 1 ( 0.2) 1 ( 0.3) 0 ( 0.0) 1.000
## stroke = 1 (%) 11 ( 2.5) 8 ( 2.0) 3 ( 6.7) 0.161
## dimentia = 1 (%) 6 ( 1.4) 5 ( 1.3) 1 ( 2.2) 1.000
## ch_lung = 1 (%) 4 ( 0.9) 3 ( 0.8) 1 ( 2.2) 0.875
## rheumati = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0) NA
## pept_ulcer = 1 (%) 42 ( 9.5) 40 ( 10.0) 2 ( 4.4) 0.345
## dm = 1 (%) 104 ( 23.4) 96 ( 24.1) 8 ( 17.8) 0.449
## dm_compli = 1 (%) 7 ( 1.6) 6 ( 1.5) 1 ( 2.2) 1.000
## paralysis = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0) NA
## malignancy = 1 (%) 57 ( 12.8) 50 ( 12.5) 7 ( 15.6) 0.734
## meta_tumor = 1 (%) 11 ( 2.5) 7 ( 1.8) 4 ( 8.9) 0.016
## aids = 0 (%) 444 (100.0) 399 (100.0) 45 (100.0) NA
## eGFR30 = 1 (%) 36 ( 8.1) 22 ( 5.5) 14 ( 31.1) <0.001
## hd = 1 (%) 10 ( 2.3) 7 ( 1.8) 3 ( 6.7) 0.115
## hcc = 1 (%) 64 ( 14.4) 56 ( 14.0) 8 ( 17.8) 0.650
## alcohol = 1 (%) 241 ( 54.3) 212 ( 53.1) 29 ( 64.4) 0.198
## past_rupture = 1 (%) 121 ( 27.3) 115 ( 28.8) 6 ( 13.3) 0.042
## antiplate = 1 (%) 3 ( 0.7) 2 ( 0.5) 1 ( 2.2) 0.707
## anticoag = 1 (%) 3 ( 0.7) 3 ( 0.8) 0 ( 0.0) 1.000
## antithro = 1 (%) 6 ( 1.4) 5 ( 1.3) 1 ( 2.2) 1.000
## nsaids = 1 (%) 4 ( 0.9) 4 ( 1.0) 0 ( 0.0) 1.000
## steroid = 1 (%) 3 ( 0.7) 3 ( 0.8) 0 ( 0.0) 1.000
## beta = 1 (%) 40 ( 9.0) 40 ( 10.0) 0 ( 0.0) 0.051
## vaso = 1 (%) 27 ( 6.1) 18 ( 4.5) 9 ( 20.0) <0.001
## ffp = 1 (%) 154 ( 34.7) 126 ( 31.6) 28 ( 62.2) <0.001
## pc = 1 (%) 11 ( 2.5) 6 ( 1.5) 5 ( 11.1) 0.001
## albner = 1 (%) 33 ( 7.4) 26 ( 6.5) 7 ( 15.6) 0.059
## shock = 1 (%) 196 ( 44.1) 153 ( 38.3) 43 ( 95.6) <0.001
## hosp_mortality = 1 (%) 45 ( 10.1) 0 ( 0.0) 45 (100.0) <0.001
## age_cate = 1 (%) 226 ( 50.9) 200 ( 50.1) 26 ( 57.8) 0.414
## bmi_cate = 1 (%) 135 ( 30.4) 124 ( 31.1) 11 ( 24.4) 0.456
## gcs_cate = 1 (%) 10 ( 2.3) 8 ( 2.0) 2 ( 4.4) 0.606
## cci_cate = 1 (%) 71 ( 16.0) 62 ( 15.5) 9 ( 20.0) 0.576
## bt_cate = 1 (%) 150 ( 33.8) 135 ( 33.8) 15 ( 33.3) 1.000
## sBP_cate = 1 (%) 102 ( 23.0) 68 ( 17.0) 34 ( 75.6) <0.001
## dBP_cate = 1 (%) 152 ( 34.2) 118 ( 29.6) 34 ( 75.6) <0.001
## hr_cate = 1 (%) 128 ( 28.8) 102 ( 25.6) 26 ( 57.8) <0.001
## bil_cate = 1 (%) 50 ( 11.3) 38 ( 9.5) 12 ( 26.7) 0.001
## ast_cate = 1 (%) 30 ( 6.8) 21 ( 5.3) 9 ( 20.0) 0.001
## alt_cate = 1 (%) 25 ( 5.6) 18 ( 4.5) 7 ( 15.6) 0.007
## wbc_cate = 1 (%) 91 ( 20.5) 75 ( 18.8) 16 ( 35.6) 0.014
## hb_cate = 1 (%) 164 ( 36.9) 138 ( 34.6) 26 ( 57.8) 0.004
## plt_cate = 1 (%) 207 ( 46.6) 186 ( 46.6) 21 ( 46.7) 1.000
## tp_cate = 1 (%) 185 ( 41.7) 155 ( 38.8) 30 ( 66.7) 0.001
## alb_cate = 1 (%) 176 ( 39.6) 140 ( 35.1) 36 ( 80.0) <0.001
## cre_cate = 1 (%) 51 ( 11.5) 33 ( 8.3) 18 ( 40.0) <0.001
## crp_cate = 1 (%) 47 ( 10.6) 34 ( 8.5) 13 ( 28.9) <0.001
## pt_cate = 1 (%) 138 ( 31.1) 107 ( 26.8) 31 ( 68.9) <0.001
## aptt_cate = 1 (%) 27 ( 6.1) 11 ( 2.8) 16 ( 35.6) <0.001
## Stratified by hosp_mortality
## SMD Missing
## n
## sex = F (%) 0.019 0.0
## barthel (%) 1.037 0.0
## 0
## 1
## 2
## child_score (%) 1.013 0.0
## 0
## 1
## 2
## pad = 1 (%) 0.071 0.0
## stroke = 1 (%) 0.230 0.0
## dimentia = 1 (%) 0.074 0.0
## ch_lung = 1 (%) 0.122 0.0
## rheumati = 0 (%) <0.001 0.0
## pept_ulcer = 1 (%) 0.217 0.0
## dm = 1 (%) 0.155 0.0
## dm_compli = 1 (%) 0.053 0.0
## paralysis = 0 (%) <0.001 0.0
## malignancy = 1 (%) 0.087 0.0
## meta_tumor = 1 (%) 0.322 0.0
## aids = 0 (%) <0.001 0.0
## eGFR30 = 1 (%) 0.701 0.0
## hd = 1 (%) 0.246 0.0
## hcc = 1 (%) 0.102 0.0
## alcohol = 1 (%) 0.231 0.0
## past_rupture = 1 (%) 0.387 0.0
## antiplate = 1 (%) 0.149 0.0
## anticoag = 1 (%) 0.123 0.0
## antithro = 1 (%) 0.074 0.0
## nsaids = 1 (%) 0.142 0.0
## steroid = 1 (%) 0.123 0.0
## beta = 1 (%) 0.472 0.0
## vaso = 1 (%) 0.486 0.0
## ffp = 1 (%) 0.645 0.0
## pc = 1 (%) 0.403 0.0
## albner = 1 (%) 0.292 0.0
## shock = 1 (%) 1.532 0.0
## hosp_mortality = 1 (%) NaN 0.0
## age_cate = 1 (%) 0.154 0.0
## bmi_cate = 1 (%) 0.149 0.0
## gcs_cate = 1 (%) 0.138 0.0
## cci_cate = 1 (%) 0.117 0.0
## bt_cate = 1 (%) 0.011 0.0
## sBP_cate = 1 (%) 1.449 0.0
## dBP_cate = 1 (%) 1.037 0.0
## hr_cate = 1 (%) 0.691 0.0
## bil_cate = 1 (%) 0.457 0.0
## ast_cate = 1 (%) 0.455 0.0
## alt_cate = 1 (%) 0.374 0.0
## wbc_cate = 1 (%) 0.384 0.0
## hb_cate = 1 (%) 0.478 0.0
## plt_cate = 1 (%) 0.001 0.0
## tp_cate = 1 (%) 0.580 0.0
## alb_cate = 1 (%) 1.020 0.0
## cre_cate = 1 (%) 0.798 0.0
## crp_cate = 1 (%) 0.541 0.0
## pt_cate = 1 (%) 0.929 0.0
## aptt_cate = 1 (%) 0.917 0.0
# specify your data and variables
tbl_summary(data = val_imp,
by = "hosp_mortality",
type = list(gcs ~ "continuous", year ~ "categorical"),
statistic = all_continuous() ~ "{median} ({p25}, {p75})",
digits = all_continuous() ~ c(0, 2))
| Characteristic | 0, N = 3991 | 1, N = 451 |
|---|---|---|
| sex | ||
| M | 296 (74%) | 33 (73%) |
| F | 103 (26%) | 12 (27%) |
| barthel | ||
| 0 | 170 (43%) | 4 (8.9%) |
| 1 | 130 (33%) | 11 (24%) |
| 2 | 99 (25%) | 30 (67%) |
| child_score | ||
| 0 | 81 (20%) | 2 (4.4%) |
| 1 | 227 (57%) | 13 (29%) |
| 2 | 91 (23%) | 30 (67%) |
| pad | ||
| 0 | 398 (100%) | 45 (100%) |
| 1 | 1 (0.3%) | 0 (0%) |
| stroke | ||
| 0 | 391 (98%) | 42 (93%) |
| 1 | 8 (2.0%) | 3 (6.7%) |
| dimentia | ||
| 0 | 394 (99%) | 44 (98%) |
| 1 | 5 (1.3%) | 1 (2.2%) |
| ch_lung | ||
| 0 | 396 (99%) | 44 (98%) |
| 1 | 3 (0.8%) | 1 (2.2%) |
| rheumati | ||
| 0 | 399 (100%) | 45 (100%) |
| pept_ulcer | ||
| 0 | 359 (90%) | 43 (96%) |
| 1 | 40 (10%) | 2 (4.4%) |
| dm | ||
| 0 | 303 (76%) | 37 (82%) |
| 1 | 96 (24%) | 8 (18%) |
| dm_compli | ||
| 0 | 393 (98%) | 44 (98%) |
| 1 | 6 (1.5%) | 1 (2.2%) |
| paralysis | ||
| 0 | 399 (100%) | 45 (100%) |
| malignancy | ||
| 0 | 349 (87%) | 38 (84%) |
| 1 | 50 (13%) | 7 (16%) |
| meta_tumor | ||
| 0 | 392 (98%) | 41 (91%) |
| 1 | 7 (1.8%) | 4 (8.9%) |
| aids | ||
| 0 | 399 (100%) | 45 (100%) |
| eGFR30 | ||
| 0 | 377 (94%) | 31 (69%) |
| 1 | 22 (5.5%) | 14 (31%) |
| hd | ||
| 0 | 392 (98%) | 42 (93%) |
| 1 | 7 (1.8%) | 3 (6.7%) |
| hcc | ||
| 0 | 343 (86%) | 37 (82%) |
| 1 | 56 (14%) | 8 (18%) |
| alcohol | ||
| 0 | 187 (47%) | 16 (36%) |
| 1 | 212 (53%) | 29 (64%) |
| past_rupture | ||
| 0 | 284 (71%) | 39 (87%) |
| 1 | 115 (29%) | 6 (13%) |
| antiplate | ||
| 0 | 397 (99%) | 44 (98%) |
| 1 | 2 (0.5%) | 1 (2.2%) |
| anticoag | ||
| 0 | 396 (99%) | 45 (100%) |
| 1 | 3 (0.8%) | 0 (0%) |
| antithro | ||
| 0 | 394 (99%) | 44 (98%) |
| 1 | 5 (1.3%) | 1 (2.2%) |
| nsaids | ||
| 0 | 395 (99%) | 45 (100%) |
| 1 | 4 (1.0%) | 0 (0%) |
| steroid | ||
| 0 | 396 (99%) | 45 (100%) |
| 1 | 3 (0.8%) | 0 (0%) |
| beta | ||
| 0 | 359 (90%) | 45 (100%) |
| 1 | 40 (10%) | 0 (0%) |
| vaso | ||
| 0 | 381 (95%) | 36 (80%) |
| 1 | 18 (4.5%) | 9 (20%) |
| ffp | ||
| 0 | 273 (68%) | 17 (38%) |
| 1 | 126 (32%) | 28 (62%) |
| pc | ||
| 0 | 393 (98%) | 40 (89%) |
| 1 | 6 (1.5%) | 5 (11%) |
| albner | ||
| 0 | 373 (93%) | 38 (84%) |
| 1 | 26 (6.5%) | 7 (16%) |
| shock | ||
| 0 | 246 (62%) | 2 (4.4%) |
| 1 | 153 (38%) | 43 (96%) |
| age | 60 (50.00, 70) | 64 (52.00, 70) |
| bmi | 23 (20.68, 26) | 23 (22.15, 25) |
| smoke | 0 (0.00, 326) | 0 (0.00, 274) |
| child_num | 8 (7.00, 9) | 11 (9.00, 12) |
| gcs | 15 (15.00, 15) | 15 (14.00, 15) |
| cci_num | 4 (4.00, 5) | 4 (4.00, 5) |
| map | 2 (0.00, 4) | 4 (4.00, 8) |
| bt | 37 (36.50, 37) | 37 (36.30, 37) |
| sBP | 93 (82.50, 101) | 68 (56.00, 79) |
| dBP | 56 (48.00, 64) | 43 (34.00, 49) |
| hr | 83 (72.00, 100) | 105 (91.00, 117) |
| bil | 2 (1.00, 3) | 3 (1.70, 5) |
| ast | 48 (31.50, 84) | 81 (40.00, 171) |
| alt | 29 (19.00, 42) | 34 (19.00, 69) |
| wbc | 7,960 (5,700.00, 10,760) | 10,000 (8,900.00, 13,800) |
| hb | 9 (7.30, 11) | 8 (6.90, 9) |
| plt | 102 (76.00, 140) | 109 (56.00, 146) |
| tp | 6 (5.70, 7) | 6 (5.00, 6) |
| alb | 3 (2.55, 3) | 2 (1.80, 3) |
| eGFR | 72 (54.21, 93) | 42 (28.38, 57) |
| bun | 24 (16.37, 36) | 33 (20.20, 47) |
| cre | 1 (0.64, 1) | 1 (0.94, 2) |
| crp | 0 (0.12, 1) | 1 (0.19, 2) |
| pt | 61 (49.00, 73) | 40 (31.00, 53) |
| aptt | 32 (29.70, 36) | 43 (35.50, 56) |
| los | 7 (5.00, 13) | 6 (2.00, 12) |
| meld | 9 (6.00, 14) | 20 (14.00, 24) |
| pt_id | 488 (232.50, 640) | 510 (299.00, 738) |
| hosp_num | ||
| 1 | 326 (82%) | 39 (87%) |
| 2 | 46 (12%) | 4 (8.9%) |
| 3 | 12 (3.0%) | 1 (2.2%) |
| 4 | 10 (2.5%) | 0 (0%) |
| 5 | 3 (0.8%) | 1 (2.2%) |
| 6 | 2 (0.5%) | 0 (0%) |
| hosp_id | 1,022 (1,005.00, 1,024) | 1,022 (1,006.00, 1,062) |
| year | ||
| 2017 | 57 (14%) | 7 (16%) |
| 2018 | 53 (13%) | 9 (20%) |
| 2019 | 63 (16%) | 9 (20%) |
| 2020 | 74 (19%) | 8 (18%) |
| 2021 | 76 (19%) | 7 (16%) |
| 2022 | 76 (19%) | 5 (11%) |
| age_cate | 200 (50%) | 26 (58%) |
| bmi_cate | 124 (31%) | 11 (24%) |
| gcs_cate | 8 (2.0%) | 2 (4.4%) |
| cci_cate | 62 (16%) | 9 (20%) |
| bt_cate | 135 (34%) | 15 (33%) |
| sBP_cate | 68 (17%) | 34 (76%) |
| dBP_cate | 118 (30%) | 34 (76%) |
| hr_cate | 102 (26%) | 26 (58%) |
| bil_cate | 38 (9.5%) | 12 (27%) |
| ast_cate | 21 (5.3%) | 9 (20%) |
| alt_cate | 18 (4.5%) | 7 (16%) |
| wbc_cate | 75 (19%) | 16 (36%) |
| hb_cate | 138 (35%) | 26 (58%) |
| plt_cate | 186 (47%) | 21 (47%) |
| tp_cate | 155 (39%) | 30 (67%) |
| alb_cate | 140 (35%) | 36 (80%) |
| cre_cate | 33 (8.3%) | 18 (40%) |
| crp_cate | 34 (8.5%) | 13 (29%) |
| pt_cate | 107 (27%) | 31 (69%) |
| aptt_cate | 11 (2.8%) | 16 (36%) |
| 1 n (%); Median (IQR) | ||
# ダミー変数を作成
dummy_vars_val <- model.matrix(~barthel, data = val_imp)
# データフレームに追加
val_imp <- cbind(val_imp, dummy_vars_val)
val_imp <- val_imp[ , !(names(val_imp) %in% "(Intercept)")]
確認
str(val_imp)
## 'data.frame': 444 obs. of 85 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 2 1 1 1 2 1 2 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 2 3 2 1 3 1 2 1 1 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 2 2 2 2 1 2 2 2 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 2 2 2 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 2 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 2 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
## $ shock : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_mortality: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ age : int 47 62 82 57 69 47 50 68 75 53 ...
## $ bmi : num 21 20.8 26.9 23.2 23.6 ...
## $ smoke : int 270 0 0 0 0 135 435 0 0 0 ...
## $ child_num : int 11 9 8 8 8 6 7 7 8 14 ...
## $ gcs : int 15 13 15 15 15 15 15 15 15 3 ...
## $ cci_num : int 4 4 4 3 6 5 4 4 5 5 ...
## $ map : int 0 8 6 2 4 0 2 4 4 4 ...
## $ bt : num 36.4 36.8 36.9 37.1 37.2 ...
## $ sBP : int 102 91 95 111 125 116 102 96 97 71 ...
## $ dBP : int 67 54 49 68 70 84 88 55 54 49 ...
## $ hr : int 83 82 60 101 121 56 79 72 75 56 ...
## $ bil : num 7.5 0.5 0.91 2.35 2.49 0.76 1.84 2.18 1.13 3.88 ...
## $ ast : num 112 56 37 42 74 18 19 24 31 62 ...
## $ alt : num 53 30 19 35 43 13 18 16 25 44 ...
## $ wbc : num 9800 14600 3350 12030 6800 ...
## $ hb : num 12.2 3.7 7.7 9.8 11.2 10.7 6.6 12.9 10.4 7.7 ...
## $ plt : num 69 437 109 107 107 60 140 84 152 178 ...
## $ tp : num 5.7 5.6 5.8 5.4 5.9 ...
## $ alb : num 2.6 2.1 2.8 3.4 3 3.7 3.4 3.7 3.3 2.7 ...
## $ eGFR : num 89.3 65.8 46.6 94.2 90.7 ...
## $ bun : num 13.7 42.8 24.2 26.9 7.9 7.6 35 24.9 35.3 23.9 ...
## $ cre : num 0.74 0.69 1.16 0.67 0.66 0.54 0.97 0.59 0.66 1.43 ...
## $ crp : num 0.1 0.17 0.22 0.04 0.111 ...
## $ pt : num 28.5 51.3 60.4 54.8 54 80 70 68 78 69 ...
## $ aptt : num 37.8 30.9 30.2 33.4 34.5 ...
## $ los : int 6 2 14 5 12 4 1 6 9 16 ...
## $ meld : int 20 6 10 9 10 6 10 7 6 17 ...
## $ pt_id : int 6 17 24 32 33 37 38 40 42 44 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1002 1002 1003 1003 1003 1003 1003 1003 ...
## $ year : int 2017 2019 2022 2022 2022 2017 2022 2020 2021 2022 ...
## $ age_cate : num 0 1 1 0 1 0 0 1 1 0 ...
## $ bmi_cate : num 0 0 1 0 0 1 1 1 0 1 ...
## $ gcs_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ cci_cate : num 0 0 0 0 1 0 0 0 0 0 ...
## $ bt_cate : num 0 0 0 1 1 0 0 1 1 0 ...
## $ sBP_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ dBP_cate : num 0 0 1 0 0 0 0 0 0 1 ...
## $ hr_cate : num 0 0 0 1 1 0 0 0 0 0 ...
## $ bil_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ ast_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ alt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ wbc_cate : num 0 1 0 1 0 0 0 0 0 0 ...
## $ hb_cate : num 0 1 1 0 0 0 1 0 0 1 ...
## $ plt_cate : num 1 0 0 0 0 1 0 1 0 0 ...
## $ tp_cate : num 1 1 1 1 1 0 1 0 0 0 ...
## $ alb_cate : num 1 1 0 0 0 0 0 0 0 1 ...
## $ cre_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ crp_cate : num 0 0 0 0 0 0 0 0 0 1 ...
## $ pt_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ aptt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ barthel1 : num 1 0 1 0 0 0 1 0 0 0 ...
## $ barthel2 : num 0 1 0 0 1 0 0 0 0 1 ...
# ダミー変数を作成
dummy_vars <- model.matrix(~barthel, data = dev_imp)
# データフレームに追加
dev_imp <- cbind(dev_imp, dummy_vars)
確認
str(dev_imp)
## 'data.frame': 536 obs. of 88 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 3 3 1 2 3 1 1 1 3 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 2 2 2 2 2 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: num 0 0 0 0 0 0 0 0 1 1 ...
## $ age : int 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num 23.4 25.3 23.5 14.5 21.9 ...
## $ smoke : int 0 0 0 240 0 0 217 1000 0 0 ...
## $ child_num : int 11 6 9 8 8 8 7 9 15 11 ...
## $ gcs : int 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : int 4 4 3 4 4 3 4 4 4 4 ...
## $ map : int 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : int 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : int 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : int 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : int 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : int 16 11 13 14 6 8 6 15 29 12 ...
## $ pt_id : int 1 2 3 4 5 7 8 9 10 11 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ year : int 2012 2011 2010 2011 2010 2010 2010 2010 2011 2012 ...
## $ age_cate : num 0 1 0 0 1 1 0 1 1 1 ...
## $ bmi_cate : num 0 1 0 0 0 0 0 0 0 0 ...
## $ gcs_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ cci_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ bt_cate : num 0 0 0 0 0 1 1 1 0 0 ...
## $ sBP_cate : num 1 0 0 1 1 0 0 0 1 1 ...
## $ dBP_cate : num 1 1 0 1 1 1 0 0 1 1 ...
## $ hr_cate : num 1 0 1 1 0 1 0 1 0 1 ...
## $ bil_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ ast_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ alt_cate : num 0 0 0 0 0 0 1 0 0 0 ...
## $ wbc_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ hb_cate : num 1 0 0 0 1 0 0 1 1 0 ...
## $ plt_cate : num 0 1 1 0 1 1 0 0 0 1 ...
## $ tp_cate : num 0 1 0 0 1 0 0 1 1 0 ...
## $ alb_cate : num 1 0 0 0 0 0 0 1 1 1 ...
## $ cre_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ crp_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ pt_cate : num 1 0 1 1 0 1 1 1 1 0 ...
## $ aptt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ fitted : num 0.3461 0.0147 0.0147 0.1436 0.1436 ...
## $ diff2 : num 0.119789 0.000216 0.000216 0.020628 0.020628 ...
## $ (Intercept) : num 1 1 1 1 1 1 1 1 1 1 ...
## $ barthel1 : num 0 0 0 1 0 0 0 0 0 0 ...
## $ barthel2 : num 1 1 0 0 1 0 0 0 1 1 ...
dev_imp <- dev_imp[ , !(names(dev_imp) %in% "(Intercept)")]
dev_imp <- dev_imp[ , !(names(dev_imp) %in% "fitted")]
dev_imp <- dev_imp[ , !(names(dev_imp) %in% "diff2")]
確認
str(dev_imp)
## 'data.frame': 536 obs. of 85 variables:
## $ sex : Factor w/ 2 levels "M","F": 1 1 2 1 2 1 2 1 2 1 ...
## $ barthel : Factor w/ 3 levels "0","1","2": 3 3 1 2 3 1 1 1 3 3 ...
## $ child_score : Factor w/ 3 levels "0","1","2": 3 1 2 2 2 2 2 2 3 3 ...
## $ pad : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ stroke : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dimentia : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ ch_lung : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ rheumati : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ pept_ulcer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ dm : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
## $ dm_compli : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ paralysis : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ malignancy : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ meta_tumor : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ aids : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
## $ eGFR30 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ hd : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ hcc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ alcohol : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 2 1 1 ...
## $ past_rupture : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antiplate : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ anticoag : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ antithro : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ nsaids : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ steroid : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ beta : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ vaso : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ ffp : Factor w/ 2 levels "0","1": 1 2 1 1 2 2 1 2 2 2 ...
## $ pc : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
## $ albner : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ...
## $ shock : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1 2 2 2 ...
## $ hosp_mortality: num 0 0 0 0 0 0 0 0 1 1 ...
## $ age : int 50 80 59 44 67 65 49 73 69 62 ...
## $ bmi : num 23.4 25.3 23.5 14.5 21.9 ...
## $ smoke : int 0 0 0 240 0 0 217 1000 0 0 ...
## $ child_num : int 11 6 9 8 8 8 7 9 15 11 ...
## $ gcs : int 15 15 15 15 15 15 15 15 6 15 ...
## $ cci_num : int 4 4 3 4 4 3 4 4 4 4 ...
## $ map : int 0 2 0 6 2 2 0 4 14 6 ...
## $ bt : num 36.4 36.8 35.9 36 36.6 38.4 37 37 35.5 36.6 ...
## $ sBP : int 78 88 100 69 66 84 132 90 52 58 ...
## $ dBP : int 48 49 56 44 40 46 69 54 37 37 ...
## $ hr : int 118 72 110 104 72 127 83 114 98 106 ...
## $ bil : num 2.2 1.2 3.1 3.4 1.2 2.4 1.2 2.2 8.7 2.1 ...
## $ ast : num 217 31 60 129 52 90 154 55 96 121 ...
## $ alt : num 63 22 40 46 36 19 109 20 87 63 ...
## $ wbc : num 7400 5000 7800 9100 3900 8000 7900 11100 12800 8300 ...
## $ hb : num 6.9 10.8 9.7 10.7 6.3 9.8 13.5 5.6 6 9.8 ...
## $ plt : num 115 77 74 162 63 93 132 124 168 84 ...
## $ tp : num 6.3 5.6 6.4 6.1 5.1 7.2 7.6 4.9 5.3 6.3 ...
## $ alb : num 2.2 3.2 2.8 2.9 2.8 3.2 4 2.3 1.2 2.5 ...
## $ eGFR : num 58 57.7 63.7 112.4 123.6 ...
## $ bun : num 13.2 41.5 26.3 2.9 27.4 15.8 15.5 27 63.2 13.8 ...
## $ cre : num 1.08 0.96 0.72 0.61 0.38 0.44 0.4 0.97 2.07 0.87 ...
## $ crp : num 0.92 0.29 0.68 0.29 0.29 ...
## $ pt : num 37.8 55 46.7 37.8 74.6 45.9 49.7 45.9 37.2 54 ...
## $ aptt : num 29.4 29 27.2 35.3 30.1 27.6 32.6 27.5 36 29.1 ...
## $ los : int 12 7 0 10 3 2 1 8 0 16 ...
## $ meld : int 16 11 13 14 6 8 6 15 29 12 ...
## $ pt_id : int 1 2 3 4 5 7 8 9 10 11 ...
## $ hosp_num : int 1 1 1 1 1 1 1 1 1 1 ...
## $ hosp_id : int 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 ...
## $ year : int 2012 2011 2010 2011 2010 2010 2010 2010 2011 2012 ...
## $ age_cate : num 0 1 0 0 1 1 0 1 1 1 ...
## $ bmi_cate : num 0 1 0 0 0 0 0 0 0 0 ...
## $ gcs_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ cci_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ bt_cate : num 0 0 0 0 0 1 1 1 0 0 ...
## $ sBP_cate : num 1 0 0 1 1 0 0 0 1 1 ...
## $ dBP_cate : num 1 1 0 1 1 1 0 0 1 1 ...
## $ hr_cate : num 1 0 1 1 0 1 0 1 0 1 ...
## $ bil_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ ast_cate : num 1 0 0 0 0 0 0 0 0 0 ...
## $ alt_cate : num 0 0 0 0 0 0 1 0 0 0 ...
## $ wbc_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ hb_cate : num 1 0 0 0 1 0 0 1 1 0 ...
## $ plt_cate : num 0 1 1 0 1 1 0 0 0 1 ...
## $ tp_cate : num 0 1 0 0 1 0 0 1 1 0 ...
## $ alb_cate : num 1 0 0 0 0 0 0 1 1 1 ...
## $ cre_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ crp_cate : num 0 0 0 0 0 0 0 0 1 0 ...
## $ pt_cate : num 1 0 1 1 0 1 1 1 1 0 ...
## $ aptt_cate : num 0 0 0 0 0 0 0 0 0 0 ...
## $ barthel1 : num 0 0 0 1 0 0 0 0 0 0 ...
## $ barthel2 : num 1 1 0 0 1 0 0 0 1 1 ...
# モデルのサマリーを表示
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp)
# モデルの係数を表示
coefficients(fit_reduced_model)
## Intercept sBP_cate gcs_cate bil_cate cre_cate alb_cate
## -4.204521 2.419024 1.421173 1.454871 1.351461 1.149297
# datadistを設定
ddist <- datadist(dev_imp)
options(datadist='ddist')
# モデルのサマリーを表示
fit_reduced_model <- lrm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp)
summary(fit_reduced_model)
## Effects Response : hosp_mortality
##
## Factor Low High Diff. Effect S.E. Lower 0.95 Upper 0.95
## sBP_cate 0 1 1 2.4190 0.34442 1.74400 3.0941
## Odds Ratio 0 1 1 11.2350 NA 5.72000 22.0670
## gcs_cate 0 1 1 1.4212 0.48989 0.46101 2.3813
## Odds Ratio 0 1 1 4.1420 NA 1.58570 10.8190
## bil_cate 0 1 1 1.4549 0.48356 0.50712 2.4026
## Odds Ratio 0 1 1 4.2839 NA 1.66050 11.0520
## cre_cate 0 1 1 1.3515 0.41180 0.54434 2.1586
## Odds Ratio 0 1 1 3.8631 NA 1.72350 8.6589
## alb_cate 0 1 1 1.1493 0.34970 0.46390 1.8347
## Odds Ratio 0 1 1 3.1560 NA 1.59030 6.2632
dev_imp$alb_score <- ifelse(dev_imp$alb_cate == 1, 1, 0)
dev_imp$sBP_score <- ifelse(dev_imp$sBP_cate == 1, 2, 0)
dev_imp$gcs_score <- ifelse(dev_imp$gcs_cate == 1, 1, 0)
dev_imp$bil_score <- ifelse(dev_imp$bil_cate == 1, 1, 0)
dev_imp$cre_score <- ifelse(dev_imp$cre_cate == 1, 1, 0)
dev_imp$sum_score <- dev_imp$alb_score + dev_imp$sBP_score + dev_imp$gcs_score + dev_imp$bil_score + dev_imp$cre_score
val_imp$alb_score <- ifelse(val_imp$alb_cate == 1, 1, 0)
val_imp$sBP_score <- ifelse(val_imp$sBP_cate == 1, 2, 0)
val_imp$gcs_score <- ifelse(val_imp$gcs_cate == 1, 1, 0)
val_imp$bil_score <- ifelse(val_imp$bil_cate == 1, 1, 0)
val_imp$cre_score <- ifelse(val_imp$cre_cate == 1, 1, 0)
val_imp$sum_score <- val_imp$alb_score + val_imp$sBP_score + val_imp$gcs_score + val_imp$bil_score + val_imp$cre_score
# 開発データセットのROCカーブとAUC
roc_obj_dev <- roc(dev_imp$hosp_mortality, dev_imp$sum_score)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
plot(roc_obj_dev, main="ROC curve for the development data")
# Calculate AUC and its confidence interval for development data
auc_roc_dev <- auc(roc_obj_dev)
ci_dev <- ci.auc(roc_obj_dev)
# Calculate the upper bound of the CI
upper_bound_dev <- 2*auc_roc_dev - ci_dev[1]
# Print the AUC and its confidence interval for development data
cat("AUC for the development data: ", auc_roc_dev, "\n")
## AUC for the development data: 0.8896269
cat("95% CI for AUC (development): (", ci_dev[1], ",", upper_bound_dev, ")\n")
## 95% CI for AUC (development): ( 0.8482092 , 0.9310446 )
# 検証データセットのROCカーブとAUC
roc_obj_val <- roc(val_imp$hosp_mortality, val_imp$sum_score)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
plot(roc_obj_val, main="ROC curve for the validation data")
# Calculate AUC and its confidence interval for validation data
auc_roc_val <- auc(roc_obj_val)
ci_val <- ci.auc(roc_obj_val)
# Calculate the upper bound of the CI for validation data
upper_bound_val <- 2*auc_roc_val - ci_val[1]
# Print the AUC and its confidence interval for validation data
cat("AUC for the validation data: ", auc_roc_val, "\n")
## AUC for the validation data: 0.8845447
cat("95% CI for AUC (validation): (", ci_val[1], ",", upper_bound_val, ")\n")
## 95% CI for AUC (validation): ( 0.842406 , 0.9266834 )
# 開発データと検証データのROCオブジェクトの計算
roc_obj_dev <- roc(dev_imp$hosp_mortality, dev_imp$sum_score)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
roc_obj_val <- roc(val_imp$hosp_mortality, val_imp$sum_score)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# 開発データと検証データのAUCの計算
auc_dev <- auc(roc_obj_dev)
auc_val <- auc(roc_obj_val)
# ROC dataをデータフレームに変換
roc_data <- data.frame(
Specificity = c(roc_obj_dev$specificities, roc_obj_val$specificities),
Sensitivity = c(roc_obj_dev$sensitivities, roc_obj_val$sensitivities),
ROC = c(rep("Development", length(roc_obj_dev$sensitivities)), rep("Validation", length(roc_obj_val$sensitivities)))
)
# Plot ROC curve
library(ggplot2)
ggplot(data = roc_data, aes(x = Specificity, y = Sensitivity, color = ROC)) +
geom_line() +
scale_x_reverse(limits = c(1, 0)) +
labs(x = "Specificity", y = "Sensitivity") +
theme_minimal() +
scale_color_manual(values = c("Development" = "blue", "Validation" = "red")) +
annotate("text", x = 0.75, y = 0.25, label = paste("AUC for Development = ", round(auc_dev, 3)), color="blue") +
annotate("text", x = 0.75, y = 0.15, label = paste("AUC for Validation = ", round(auc_val, 3)), color="red")
# child_numのみを用いたモデル
model_child_num <- glm(hosp_mortality ~ child_num, data = dev_imp, family = binomial())
pred_child_num_dev <- predict(model_child_num, dev_imp, type = "response")
# ageのみを用いたモデル
model_age <- glm(hosp_mortality ~ age, data = dev_imp, family = binomial())
pred_age_dev <- predict(model_age, dev_imp, type = "response")
# MELDスコアのみを用いたモデル
model_meld <- glm(hosp_mortality ~ meld, data = dev_imp, family = binomial())
pred_meld_dev <- predict(model_meld, dev_imp, type = "response")
# ROC curveとAUCの計算
roc_obj_child_num_dev <- roc(dev_imp$hosp_mortality, pred_child_num_dev)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
roc_obj_age_dev <- roc(dev_imp$hosp_mortality, pred_age_dev)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# AUCの計算
auc_child_num_dev <- auc(roc_obj_child_num_dev)
auc_age_dev <- auc(roc_obj_age_dev)
# ROC curveをデータフレームに変換
roc_data <- data.frame(
Specificity = c(roc_obj_dev$specificities, roc_obj_child_num_dev$specificities, roc_obj_age_dev$specificities),
Sensitivity = c(roc_obj_dev$sensitivities, roc_obj_child_num_dev$sensitivities, roc_obj_age_dev$sensitivities),
ROC = c(rep("HOPE-EVL score", length(roc_obj_dev$sensitivities)),
rep("Child-Pugh score", length(roc_obj_child_num_dev$sensitivities)),
rep("Age", length(roc_obj_age_dev$sensitivities)))
)
# MELDスコアのみを用いたモデル
model_meld <- glm(hosp_mortality ~ meld, data = dev_imp, family = binomial())
pred_meld_dev <- predict(model_meld, dev_imp, type = "response")
# ROC curveとAUCの計算
roc_obj_meld_dev <- roc(dev_imp$hosp_mortality, pred_meld_dev)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# AUCの計算
auc_meld_dev <- auc(roc_obj_meld_dev)
# ROC curveをデータフレームに追加
roc_data <- rbind(roc_data,
data.frame(Specificity = roc_obj_meld_dev$specificities,
Sensitivity = roc_obj_meld_dev$sensitivities,
ROC = rep("MELD score", length(roc_obj_meld_dev$sensitivities))))
# ROCカラムのファクターレベルを調整
roc_data$ROC <- factor(roc_data$ROC, levels = c("HOPE-EVL score", "MELD score", "Child-Pugh score", "Age"))
# Plot ROC curve
ggplot(data = roc_data, aes(x = Specificity, y = Sensitivity, color = ROC)) +
geom_line() +
scale_x_reverse(limits = c(1, 0)) +
labs(x = "Specificity", y = "Sensitivity") +
theme_minimal() +
scale_color_manual(values = c("HOPE-EVL score" = "red",
"MELD score" = "green3",
"Child-Pugh score" = "cyan",
"Age" = "purple3")) +
annotate("text", x = 0.75, y = 0.25, label = paste("HOPE-EVL score = ", round(auc_dev, 3)), color="red") +
annotate("text", x = 0.75, y = 0.20, label = paste("MELD score = ", round(auc_meld_dev, 3)), color="green3") +
annotate("text", x = 0.75, y = 0.15, label = paste("Child-Pugh score = ", round(auc_child_num_dev, 3)), color="cyan") +
annotate("text", x = 0.75, y = 0.10, label = paste("Age = ", round(auc_age_dev, 3)), color="purple3")
### 開発データ各スコアでの信頼区間
# Compute CI for Child-Pugh score
ci_child_num_dev <- ci.auc(roc_obj_child_num_dev)
ci_child_num_dev_upper <- 2*auc_child_num_dev - ci_child_num_dev[1]
cat("AUC for Child-Pugh score: ", auc_child_num_dev, "\n")
## AUC for Child-Pugh score: 0.8069913
cat("95% CI for AUC (Child-Pugh score): (", ci_child_num_dev[1], ",", ci_child_num_dev_upper, ")\n")
## 95% CI for AUC (Child-Pugh score): ( 0.7525509 , 0.8614318 )
# Compute CI for Age
ci_age_dev <- ci.auc(roc_obj_age_dev)
ci_age_dev_upper <- 2*auc_age_dev - ci_age_dev[1]
cat("AUC for Age: ", auc_age_dev, "\n")
## AUC for Age: 0.5713335
cat("95% CI for AUC (Age): (", ci_age_dev[1], ",", ci_age_dev_upper, ")\n")
## 95% CI for AUC (Age): ( 0.4999139 , 0.6427531 )
# Compute CI for MELD score
ci_meld_dev <- ci.auc(roc_obj_meld_dev)
ci_meld_dev_upper <- 2*auc_meld_dev - ci_meld_dev[1]
cat("AUC for MELD score: ", auc_meld_dev, "\n")
## AUC for MELD score: 0.8087517
cat("95% CI for AUC (MELD score): (", ci_meld_dev[1], ",", ci_meld_dev_upper, ")\n")
## 95% CI for AUC (MELD score): ( 0.757591 , 0.8599124 )
# 検証データセットでの予測
pred_child_num_val <- predict(model_child_num, val_imp, type = "response")
pred_age_val <- predict(model_age, val_imp, type = "response")
# 検証データセットでのROC curveとAUCの計算
roc_obj_child_num_val <- roc(val_imp$hosp_mortality, pred_child_num_val)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
roc_obj_age_val <- roc(val_imp$hosp_mortality, pred_age_val)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# 検証データセットでのAUCの計算
auc_child_num_val <- auc(roc_obj_child_num_val)
auc_age_val <- auc(roc_obj_age_val)
# ROC curveをデータフレームに変換
roc_data <- data.frame(
Specificity = c(roc_obj_val$specificities, roc_obj_child_num_val$specificities, roc_obj_age_val$specificities),
Sensitivity = c(roc_obj_val$sensitivities, roc_obj_child_num_val$sensitivities, roc_obj_age_val$sensitivities),
ROC = c(rep("HOPE-EVL score", length(roc_obj_val$sensitivities)),
rep("Child-Pugh score", length(roc_obj_child_num_val$sensitivities)),
rep("Age", length(roc_obj_age_val$sensitivities)))
)
# MELDスコアのみを用いたモデルで予測
pred_meld_val <- predict(model_meld, val_imp, type = "response")
# 検証データセットでのROC curveとAUCの計算
roc_obj_meld_val <- roc(val_imp$hosp_mortality, pred_meld_val)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
# 検証データセットでのAUCの計算
auc_meld_val <- auc(roc_obj_meld_val)
# ROC curveをデータフレームに変換
roc_data <- rbind(roc_data,
data.frame(Specificity = roc_obj_meld_val$specificities,
Sensitivity = roc_obj_meld_val$sensitivities,
ROC = rep("MELD score", length(roc_obj_meld_val$sensitivities))))
# ROCカラムのファクターレベルを調整
roc_data$ROC <- factor(roc_data$ROC, levels = c("HOPE-EVL score", "MELD score", "Child-Pugh score", "Age"))
# Plot ROC curve
ggplot(data = roc_data, aes(x = Specificity, y = Sensitivity, color = ROC)) +
geom_line() +
scale_x_reverse(limits = c(1, 0)) +
labs(x = "Specificity", y = "Sensitivity") +
theme_minimal() +
scale_color_manual(values = c("HOPE-EVL score" = "red",
"MELD score" = "green3",
"Child-Pugh score" = "cyan",
"Age" = "purple3")) +
annotate("text", x = 0.75, y = 0.25, label = paste("HOPE-EVL score = ", round(auc_val, 3)), color="red") +
annotate("text", x = 0.75, y = 0.20, label = paste("MELD score = ", round(auc_meld_val, 3)), color="green3") +
annotate("text", x = 0.75, y = 0.15, label = paste("Child-Pugh score = ", round(auc_child_num_val, 3)), color="cyan") +
annotate("text", x = 0.75, y = 0.10, label = paste("Age = ", round(auc_age_val, 3)), color="purple3")
# Compute CI for Child-Pugh score
ci_child_num_val <- ci.auc(roc_obj_child_num_val)
ci_child_num_val_upper <- 2*auc_child_num_val - ci_child_num_val[1]
cat("AUC for Child-Pugh score: ", auc_child_num_val, "\n")
## AUC for Child-Pugh score: 0.797995
cat("95% CI for AUC (Child-Pugh score): (", ci_child_num_val[1], ",", ci_child_num_val_upper, ")\n")
## 95% CI for AUC (Child-Pugh score): ( 0.7269886 , 0.8690014 )
# Compute CI for Age
ci_age_val <- ci.auc(roc_obj_age_val)
ci_age_val_upper <- 2*auc_age_val - ci_age_val[1]
cat("AUC for Age: ", auc_age_val, "\n")
## AUC for Age: 0.5504595
cat("95% CI for AUC (Age): (", ci_age_val[1], ",", ci_age_val_upper, ")\n")
## 95% CI for AUC (Age): ( 0.4638899 , 0.6370291 )
# Compute CI for MELD score
ci_meld_val <- ci.auc(roc_obj_meld_val)
ci_meld_val_upper <- 2*auc_meld_val - ci_meld_val[1]
cat("AUC for MELD score: ", auc_meld_val, "\n")
## AUC for MELD score: 0.8529936
cat("95% CI for AUC (MELD score): (", ci_meld_val[1], ",", ci_meld_val_upper, ")\n")
## 95% CI for AUC (MELD score): ( 0.7942431 , 0.9117441 )
# dev_impデータセットのsum_scoreのヒストグラム
hist(dev_imp$sum_score, main = "Histogram of total score for development data", xlab = "sum_score")
# val_impデータセットのsum_scoreのヒストグラム
hist(val_imp$sum_score, main = "Histogram of total score for validation data", xlab = "sum_score")
## calibration
#モデルの構築
dev_imp <-
dev_imp|>
mutate(hosp_mortality=as.numeric(hosp_mortality)) #numericにしないと回帰が回らない
val_imp <- val_imp |>
mutate(hosp_mortality = as.numeric(hosp_mortality)-1) #valは1,2になってしまっているため対処
model <- glm(hosp_mortality ~ sBP_cate +gcs_cate + bil_cate + cre_cate + alb_cate, data = dev_imp, family = binomial())
# サマリー統計量の取得
summary_stats <- summary(model)
# 係数(coefficient)、標準誤差(SE)、およびp値の取得
coefficients <- summary_stats$coefficients
# 各項目の結果を表示
print(coefficients)
## Estimate Std. Error z value
## (Intercept) -4.204521 0.3711430 -11.328575
## sBP_cate 2.419024 0.3444232 7.023405
## gcs_cate 1.421173 0.4898875 2.901018
## bil_cate 1.454871 0.4835560 3.008693
## cre_cate 1.351461 0.4118037 3.281810
## alb_cate 1.149297 0.3496991 3.286532
## Pr(>|z|)
## (Intercept) 0.000000000000000000000000000009473317
## sBP_cate 0.000000000002165250556983710824803936
## gcs_cate 0.003719525200079498543359601825386562
## bil_cate 0.002623741738911175049031587747094818
## cre_cate 0.001031431974685207949085641310205119
## alb_cate 0.001014293592030986830218597383179713
# 変数リストの設定(応答変数を除外)
initial_vars_dammy <- c("sex","barthel1","barthel2", "pept_ulcer", "dm", "malignancy", "hcc", "alcohol",
"past_rupture", "antithro", "steroid", "beta", "sBP_cate",
"age_cate", "bmi_cate", "gcs_cate", "bt_cate", "bil_cate", "ast_cate", "alt_cate",
"wbc_cate", "hb_cate", "plt_cate", "alb_cate", "cre_cate",
"crp_cate", "aptt_cate","pt_cate" )
# Initialize an empty data frame for results
results <- data.frame()
# Loop through each variable in the list
for (var in initial_vars_dammy) {
# Perform logistic regression
model_crude <- glm(formula(paste("hosp_mortality ~", var)), data = dev_imp, family = "binomial")
# Calculate odds ratio, 95% CI, and p-value
coefs <- coef(summary(model_crude))
OR <- round(exp(coefs[2, "Estimate"]), 2)
lower <- round(exp(coefs[2, "Estimate"] - 1.96 * coefs[2, "Std. Error"]), 2)
upper <- round(exp(coefs[2, "Estimate"] + 1.96 * coefs[2, "Std. Error"]), 2)
p_value <- round(coefs[2, "Pr(>|z|)"], 3)
# Add results to the data frame
results <- rbind(results, data.frame(Variable = var, OR = OR, Lower = lower, Upper = upper, P_value = p_value))
}
# Show the results
print(results)
## Variable OR Lower Upper P_value
## 1 sex 1.20 0.69 2.09 0.527
## 2 barthel1 0.44 0.23 0.85 0.015
## 3 barthel2 6.91 3.94 12.09 0.000
## 4 pept_ulcer 0.10 0.01 0.71 0.022
## 5 dm 0.46 0.21 0.99 0.046
## 6 malignancy 1.78 0.89 3.55 0.100
## 7 hcc 1.09 0.60 1.98 0.784
## 8 alcohol 0.70 0.42 1.16 0.166
## 9 past_rupture 0.47 0.22 1.01 0.054
## 10 antithro 2.13 0.22 20.75 0.515
## 11 steroid 6.42 0.40 103.74 0.190
## 12 beta 0.00 0.00 Inf 0.979
## 13 sBP_cate 16.26 8.97 29.47 0.000
## 14 age_cate 1.20 0.72 1.98 0.488
## 15 bmi_cate 0.57 0.28 1.15 0.116
## 16 gcs_cate 16.59 7.58 36.34 0.000
## 17 bt_cate 0.71 0.39 1.28 0.258
## 18 bil_cate 5.81 2.93 11.53 0.000
## 19 ast_cate 3.99 1.97 8.07 0.000
## 20 alt_cate 2.67 1.23 5.79 0.013
## 21 wbc_cate 1.50 0.82 2.76 0.192
## 22 hb_cate 1.44 0.88 2.36 0.150
## 23 plt_cate 1.04 0.64 1.71 0.863
## 24 alb_cate 6.36 3.50 11.57 0.000
## 25 cre_cate 6.00 3.33 10.80 0.000
## 26 crp_cate 4.38 2.27 8.45 0.000
## 27 aptt_cate 10.93 4.48 26.66 0.000
## 28 pt_cate 2.38 1.42 3.97 0.001
# 予測確率の計算
pred_dev <- predict(model, data = dev_imp, type = "response")
dev_imp$predicted <- pred_dev
# スコアごとに要約
dev_by <- dplyr::group_by(dev_imp, sum_score)
table_dev <- dplyr::summarize(dev_by,
hosp_mortality = sum(hosp_mortality), # outcomeは1/0
n = n(),
mortality_rate = round(hosp_mortality / n, 3),
prediction = round(mean(predicted), 3)
)
table_dev
## # A tibble: 7 × 5
## sum_score hosp_mortality n mortality_rate prediction
## <dbl> <dbl> <int> <dbl> <dbl>
## 1 0 3 224 0.013 0.015
## 2 1 7 153 0.046 0.047
## 3 2 7 51 0.137 0.152
## 4 3 28 70 0.4 0.361
## 5 4 16 24 0.667 0.689
## 6 5 8 10 0.8 0.896
## 7 6 4 4 1 0.973
# 予測確率の計算
pred_val <- predict(model, newdata = val_imp, type = "response")
val_imp$predicted <- pred_val
# スコアごとに要約
val_by <- dplyr::group_by(val_imp, sum_score)
table_val <- dplyr::summarize(val_by,
hosp_mortality = sum(hosp_mortality), # outcomeは1/0
n = n(),
mortality_rate = round(hosp_mortality / n, 3),
prediction = round(mean(predicted), 3)
)
table_val
## # A tibble: 6 × 5
## sum_score hosp_mortality n mortality_rate prediction
## <dbl> <dbl> <int> <dbl> <dbl>
## 1 0 0 199 0 0.015
## 2 1 8 112 0.071 0.048
## 3 2 6 58 0.103 0.154
## 4 3 13 45 0.289 0.356
## 5 4 13 22 0.591 0.688
## 6 5 5 8 0.625 0.898
# For each cut-off point, calculate the metrics
for (cut_off in 0:6) {
# Create a binary variable to separate the group from the others
dev_imp$group_binary_dev <- ifelse(dev_imp$sum_score >= cut_off, 1, 0)
# Calculate confusion matrix
CM_dev <- table(Predicted = dev_imp$group_binary_dev, Actual = dev_imp$hosp_mortality)
# If confusion matrix is not 2x2, adjust it
if (any(dim(CM_dev) != c(2, 2))) {
levels_factor_dev <- levels(as.factor(dev_imp$hosp_mortality))
CM_dev <- matrix(c(CM_dev, rep(0, 4 - length(CM_dev))), nrow = 2,
dimnames = list(Predicted = c(0, 1), Actual = levels_factor_dev))
}
# Values from confusion matrix
TP_dev <- ifelse(is.na(CM_dev[2, 2]), 0, CM_dev[2, 2])
FP_dev <- ifelse(is.na(CM_dev[2, 1]), 0, CM_dev[2, 1])
TN_dev <- ifelse(is.na(CM_dev[1, 1]), 0, CM_dev[1, 1])
FN_dev <- ifelse(is.na(CM_dev[1, 2]), 0, CM_dev[1, 2])
# Calculate metrics
if ((FP_dev + TN_dev) != 0) {Sp_dev <- TN_dev / (FP_dev + TN_dev)} else {Sp_dev <- NA}
if ((TP_dev + FN_dev) != 0) {Se_dev <- TP_dev / (TP_dev + FN_dev)} else {Se_dev <- NA}
if ((1 - Sp_dev) != 0) {LR_plus_dev <- Se_dev / (1 - Sp_dev)} else {LR_plus_dev <- NA}
if (Sp_dev != 0) {LR_minus_dev <- (1 - Se_dev) / Sp_dev} else {LR_minus_dev <- NA}
# Print results
cat("Cut-off: ≥", cut_off, "\n")
print(CM_dev) # Added here to print the confusion matrix
cat("特異度(Sp): ", Sp_dev, "\n")
cat("感度(Se): ", Se_dev, "\n")
cat("陽性尤度比(LR+): ", LR_plus_dev, "\n")
cat("陰性尤度比(LR-): ", LR_minus_dev, "\n")
cat("真陽性数(TP): ", TP_dev, "\n")
cat("真陰性数(TN): ", TN_dev, "\n")
cat("偽陽性数(FP): ", FP_dev, "\n")
cat("偽陰性数(FN): ", FN_dev, "\n\n")
}
## Cut-off: ≥ 0
## Actual
## Predicted 0 1
## 0 463 0
## 1 73 0
## 特異度(Sp): 0.863806
## 感度(Se): NA
## 陽性尤度比(LR+): NA
## 陰性尤度比(LR-): NA
## 真陽性数(TP): 0
## 真陰性数(TN): 463
## 偽陽性数(FP): 73
## 偽陰性数(FN): 0
##
## Cut-off: ≥ 1
## Actual
## Predicted 0 1
## 0 221 3
## 1 242 70
## 特異度(Sp): 0.4773218
## 感度(Se): 0.9589041
## 陽性尤度比(LR+): 1.834598
## 陰性尤度比(LR-): 0.08609682
## 真陽性数(TP): 70
## 真陰性数(TN): 221
## 偽陽性数(FP): 242
## 偽陰性数(FN): 3
##
## Cut-off: ≥ 2
## Actual
## Predicted 0 1
## 0 367 10
## 1 96 63
## 特異度(Sp): 0.7926566
## 感度(Se): 0.8630137
## 陽性尤度比(LR+): 4.162243
## 陰性尤度比(LR-): 0.1728192
## 真陽性数(TP): 63
## 真陰性数(TN): 367
## 偽陽性数(FP): 96
## 偽陰性数(FN): 10
##
## Cut-off: ≥ 3
## Actual
## Predicted 0 1
## 0 411 17
## 1 52 56
## 特異度(Sp): 0.887689
## 感度(Se): 0.7671233
## 陽性尤度比(LR+): 6.830348
## 陰性尤度比(LR-): 0.2623404
## 真陽性数(TP): 56
## 真陰性数(TN): 411
## 偽陽性数(FP): 52
## 偽陰性数(FN): 17
##
## Cut-off: ≥ 4
## Actual
## Predicted 0 1
## 0 453 45
## 1 10 28
## 特異度(Sp): 0.9784017
## 感度(Se): 0.3835616
## 陽性尤度比(LR+): 17.7589
## 陰性尤度比(LR-): 0.6300463
## 真陽性数(TP): 28
## 真陰性数(TN): 453
## 偽陽性数(FP): 10
## 偽陰性数(FN): 45
##
## Cut-off: ≥ 5
## Actual
## Predicted 0 1
## 0 461 61
## 1 2 12
## 特異度(Sp): 0.9956803
## 感度(Se): 0.1643836
## 陽性尤度比(LR+): 38.05479
## 陰性尤度比(LR-): 0.8392417
## 真陽性数(TP): 12
## 真陰性数(TN): 461
## 偽陽性数(FP): 2
## 偽陰性数(FN): 61
##
## Cut-off: ≥ 6
## Actual
## Predicted 0 1
## 0 463 69
## 1 0 4
## 特異度(Sp): 1
## 感度(Se): 0.05479452
## 陽性尤度比(LR+): NA
## 陰性尤度比(LR-): 0.9452055
## 真陽性数(TP): 4
## 真陰性数(TN): 463
## 偽陽性数(FP): 0
## 偽陰性数(FN): 69
#### 注意 cut-off≥0のみ誤って記載される。真陽性:73,偽陽性:463が正しい。感度・特異度・尤度比の数値は注意
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "0 to 1",
sum_score >= 2 & sum_score <= 3 ~ "2 to 3",
sum_score == 4 ~ "4",
sum_score == 5 ~ "5",
sum_score == 6 ~ "6"
))
# 'sum_score_group'を順序付きの因子として扱う
dev_imp$sum_score_group <- factor(dev_imp$sum_score_group, levels = c("0 to 1", "2 to 3", "4", "5", "6"), ordered = TRUE)
# 'predicted'列の名前を'prediction'に変更します
names(dev_imp)[names(dev_imp) == "predicted"] <- "prediction"
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table <- dev_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), prediction = mean(prediction, na.rm = TRUE)) %>%
mutate(mortality_rate = hosp_mortality / n)
# pivot_longerを使って長い形式に変換
summary_table_long <- summary_table %>%
pivot_longer(c(mortality_rate, prediction), names_to = "variable", values_to = "value")
# 新しい形式で棒グラフをプロット
ggplot(summary_table_long, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Sum Score Group", fill = "Variable") +
scale_fill_manual(values = c("mortality_rate" = "blue", "prediction" = "red")) +
theme_minimal()
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "0 to 1",
sum_score >= 2 & sum_score <= 3 ~ "2 to 3",
sum_score == 4 ~ "4",
sum_score == 5 ~ "5",
sum_score == 6 ~ "6"
))
# 'sum_score_group'を順序付きの因子として扱う
val_imp$sum_score_group <- factor(val_imp$sum_score_group, levels = c("0 to 1", "2 to 3", "4", "5", "6"), ordered = TRUE)
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val <- val_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), prediction = mean(predicted)) %>%
mutate(mortality_rate = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_val <- summary_table_val %>%
pivot_longer(c(mortality_rate, prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_val, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Sum Score Group", fill = "Variable") +
scale_fill_manual(values = c("mortality_rate" = "blue", "prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 手動で予測値を計算します
liner_predict_manual <- -4.204521 + 2.5 * dev_imp$sBP_cate + 1.25 * dev_imp$gcs_cate + 1.25 * dev_imp$bil_cate + 1.25 * dev_imp$cre_cate + 1.25 * dev_imp$alb_cate
pred_manual <- exp(liner_predict_manual) / (exp(liner_predict_manual) + 1)
# 新しい予測値でテーブルを作成します
dev_imp$predicted_manual <- pred_manual
dev_by_manual <- dplyr::group_by(dev_imp, sum_score)
table_dev_manual <- dplyr::summarize(dev_by_manual,
hosp_mortality = sum(hosp_mortality),
n = n(),
mortality_rate = round(hosp_mortality / n, 3),
prediction_manual = round(mean(predicted_manual), 3)
)
table_dev_manual
## # A tibble: 7 × 5
## sum_score hosp_mortality n mortality_rate prediction_manual
## <dbl> <dbl> <int> <dbl> <dbl>
## 1 0 3 224 0.013 0.015
## 2 1 7 153 0.046 0.05
## 3 2 7 51 0.137 0.154
## 4 3 28 70 0.4 0.388
## 5 4 16 24 0.667 0.689
## 6 5 8 10 0.8 0.885
## 7 6 4 4 1 0.964
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "0 to 1",
sum_score >= 2 & sum_score <= 3 ~ "2 to 3",
sum_score == 4 ~ "4",
sum_score == 5 ~ "5",
sum_score == 6 ~ "6"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_dev_manual <- dev_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_dev_manual <- summary_table_dev_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_dev_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Sum Score Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk (Score 0,1)",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk (Score 2,3)",
sum_score >= 4 & sum_score <= 5 ~ "High risk (Score 4,5)",
sum_score == 6 ~ "Very high risk (Score 6)"
))
# 因子として定義し、レベルを指定します
dev_imp$sum_score_group <- factor(dev_imp$sum_score_group,
levels = c("Low risk (Score 0,1)", "Middle risk (Score 2,3)",
"High risk (Score 4,5)", "Very high risk (Score 6)"))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_dev_manual <- dev_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_dev_manual <- summary_table_dev_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_dev_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk (Score 0,1)",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk (Score 2,3)",
sum_score >= 4 & sum_score <= 6 ~ "High risk (Score ≥4)"
))
# 因子として定義し、レベルを指定します
dev_imp$sum_score_group <- factor(dev_imp$sum_score_group,
levels = c("Low risk (Score 0,1)", "Middle risk (Score 2,3)",
"High risk (Score ≥4)"))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_dev_manual <- dev_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_dev_manual <- summary_table_dev_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_dev_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(risk_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk",
sum_score >= 4 & sum_score <= 5 ~ "High risk",
sum_score == 6 ~ "Very high risk"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_dev_manual <- dev_imp %>%
group_by(risk_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# 各リスクグループのObservedとPredictionの具体的な数値を表示します
summary_table_dev_manual %>% select(risk_group, Observed, Prediction)
## # A tibble: 4 × 3
## risk_group Observed Prediction
## <chr> <dbl> <dbl>
## 1 High risk 0.706 0.747
## 2 Low risk 0.0265 0.0288
## 3 Middle risk 0.289 0.289
## 4 Very high risk 1 0.964
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
dev_imp <- dev_imp %>%
mutate(risk_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk",
sum_score >= 4 & sum_score <= 6 ~ "High risk"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_dev_manual <- dev_imp %>%
group_by(risk_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# 各リスクグループのObservedとPredictionの具体的な数値を表示します
summary_table_dev_manual %>% select(risk_group, Observed, Prediction)
## # A tibble: 3 × 3
## risk_group Observed Prediction
## <chr> <dbl> <dbl>
## 1 High risk 0.737 0.770
## 2 Low risk 0.0265 0.0288
## 3 Middle risk 0.289 0.289
# Load necessary library
library(Hmisc)
# Add standard error and confidence intervals
summary_table_dev_manual <- summary_table_dev_manual %>%
group_by(risk_group) %>%
mutate(
se = sqrt((Prediction * (1 - Prediction)) / n),
ci_lower = Prediction - qt(1 - (0.05 / 2), df = n - 1) * se,
ci_upper = Prediction + qt(1 - (0.05 / 2), df = n - 1) * se
)
summary_table_dev_manual
## # A tibble: 3 × 8
## # Groups: risk_group [3]
## risk_group hosp_mortality n Prediction Observed se ci_lower ci_upper
## <chr> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 High risk 28 38 0.770 0.737 0.0683 0.631 0.908
## 2 Low risk 10 377 0.0288 0.0265 0.00862 0.0119 0.0458
## 3 Middle risk 35 121 0.289 0.289 0.0412 0.208 0.371
# 手動で予測値を計算します
liner_predict_manual_val <- -4.204521 + 2.5 * val_imp$sBP_cate + 1.25 * val_imp$gcs_cate + 1.25 * val_imp$bil_cate + 1.25 * val_imp$cre_cate + 1.25 * val_imp$alb_cate
pred_manual_val <- exp(liner_predict_manual_val) / (exp(liner_predict_manual_val) + 1)
# 新しい予測値でテーブルを作成します
val_imp$predicted_manual <- pred_manual_val
val_by_manual <- dplyr::group_by(val_imp, sum_score)
table_val_manual <- dplyr::summarize(val_by_manual,
hosp_mortality = sum(hosp_mortality),
n = n(),
mortality_rate = round(hosp_mortality / n, 3),
prediction_manual = round(mean(predicted_manual), 3)
)
table_val_manual
## # A tibble: 6 × 5
## sum_score hosp_mortality n mortality_rate prediction_manual
## <dbl> <dbl> <int> <dbl> <dbl>
## 1 0 0 199 0 0.015
## 2 1 8 112 0.071 0.05
## 3 2 6 58 0.103 0.154
## 4 3 13 45 0.289 0.388
## 5 4 13 22 0.591 0.689
## 6 5 5 8 0.625 0.885
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "0 to 1",
sum_score >= 2 & sum_score <= 3 ~ "2 to 3",
sum_score == 4 ~ "4",
sum_score == 5 ~ "5",
sum_score == 6 ~ "6"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val_manual <- val_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_val_manual <- summary_table_val_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_val_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Sum Score Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk (Score 0,1)",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk (Score 2,3)",
sum_score >= 4 & sum_score <= 5 ~ "High risk (Score 4,5)",
sum_score == 6 ~ "6"
))
# 因子として定義し、レベルを指定します
val_imp$sum_score_group <- factor(val_imp$sum_score_group,
levels = c("Low risk (Score 0,1)", "Middle risk (Score 2,3)",
"High risk (Score 4,5)", "6"))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val_manual <- val_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_val_manual <- summary_table_val_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_val_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(sum_score_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk (Score 0,1)",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk (Score 2,3)",
sum_score >= 4 & sum_score <= 6 ~ "High risk (Score ≥4)"
))
# 因子として定義し、レベルを指定します
val_imp$sum_score_group <- factor(val_imp$sum_score_group,
levels = c("Low risk (Score 0,1)", "Middle risk (Score 2,3)",
"High risk (Score ≥4)"))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val_manual <- val_imp %>%
group_by(sum_score_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# データを長い形式に変換します
summary_table_long_val_manual <- summary_table_val_manual %>%
pivot_longer(c(Observed, Prediction), names_to = "variable", values_to = "value")
# 棒グラフをプロットします
ggplot(summary_table_long_val_manual, aes(x = sum_score_group, y = value*100, fill = variable)) +
geom_col(position = "dodge", width = 0.6) +
labs(y = "Percentage (%)", x = "Group", fill = "Variable") +
scale_fill_manual(values = c("Observed" = "blue", "Prediction" = "red")) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(risk_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk",
sum_score >= 4 & sum_score <= 5 ~ "High risk",
sum_score == 6 ~ "Very high risk"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val_manual <- val_imp %>%
group_by(risk_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# 各リスクグループのObservedとPredictionの具体的な数値を表示します
summary_table_val_manual %>% select(risk_group, Observed, Prediction)
## # A tibble: 3 × 3
## risk_group Observed Prediction
## <chr> <dbl> <dbl>
## 1 High risk 0.6 0.741
## 2 Low risk 0.0257 0.0272
## 3 Middle risk 0.184 0.256
# 'sum_score' の範囲に基づいて新しいカテゴリ列を作成します
val_imp <- val_imp %>%
mutate(risk_group = case_when(
sum_score >= 0 & sum_score <= 1 ~ "Low risk",
sum_score >= 2 & sum_score <= 3 ~ "Middle risk",
sum_score >= 4 & sum_score <= 6 ~ "High risk"
))
# グループごとの 'hosp_mortality' の合計と 'n' の合計を計算します
summary_table_val_manual <- val_imp %>%
group_by(risk_group) %>%
summarise(hosp_mortality = sum(hosp_mortality), n = n(), Prediction = mean(predicted_manual)) %>%
mutate(Observed = hosp_mortality / n)
# 各リスクグループのObservedとPredictionの具体的な数値を表示します
summary_table_val_manual %>% select(risk_group, Observed, Prediction)
## # A tibble: 3 × 3
## risk_group Observed Prediction
## <chr> <dbl> <dbl>
## 1 High risk 0.6 0.741
## 2 Low risk 0.0257 0.0272
## 3 Middle risk 0.184 0.256
# Load necessary library
library(Hmisc)
# Add standard error and confidence intervals
summary_table_val_manual <- summary_table_val_manual %>%
group_by(risk_group) %>%
mutate(
se = sqrt((Prediction * (1 - Prediction)) / n),
ci_lower = Prediction - qt(1 - (0.05 / 2), df = n - 1) * se,
ci_upper = Prediction + qt(1 - (0.05 / 2), df = n - 1) * se
)
summary_table_val_manual
## # A tibble: 3 × 8
## # Groups: risk_group [3]
## risk_group hosp_mortality n Prediction Observed se ci_lower ci_upper
## <chr> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 High risk 18 30 0.741 0.6 0.0799 0.578 0.905
## 2 Low risk 8 311 0.0272 0.0257 0.00923 0.00908 0.0454
## 3 Middle risk 19 103 0.256 0.184 0.0430 0.171 0.342
# For each cut-off point, calculate the metrics
for (cut_off in 0:5) {
# Create a binary variable to separate the group from the others
val_imp$group_binary <- ifelse(val_imp$sum_score >= cut_off, 1, 0)
# Calculate confusion matrix
CM <- table(Predicted = val_imp$group_binary, Actual = val_imp$hosp_mortality)
# If confusion matrix is not 2x2, adjust it
if (any(dim(CM) != c(2, 2))) {
levels_factor <- levels(as.factor(val_imp$hosp_mortality))
CM <- matrix(c(CM, rep(0, 4 - length(CM))), nrow = 2,
dimnames = list(Predicted = c(0, 1), Actual = levels_factor))
}
# Values from confusion matrix
TP <- ifelse(is.na(CM[2, 2]), 0, CM[2, 2])
FP <- ifelse(is.na(CM[2, 1]), 0, CM[2, 1])
TN <- ifelse(is.na(CM[1, 1]), 0, CM[1, 1])
FN <- ifelse(is.na(CM[1, 2]), 0, CM[1, 2])
# Calculate metrics
if ((FP + TN) != 0) {Sp <- TN / (FP + TN)} else {Sp <- NA}
if ((TP + FN) != 0) {Se <- TP / (TP + FN)} else {Se <- NA}
if ((1 - Sp) != 0) {LR_plus <- Se / (1 - Sp)} else {LR_plus <- NA}
if (Sp != 0) {LR_minus <- (1 - Se) / Sp} else {LR_minus <- NA}
# Print results
cat("Cut-off: ≥", cut_off, "\n")
print(CM) # Added here to print the confusion matrix
cat("特異度(Sp): ", Sp, "\n")
cat("感度(Se): ", Se, "\n")
cat("陽性尤度比(LR+): ", LR_plus, "\n")
cat("陰性尤度比(LR-): ", LR_minus, "\n")
cat("真陽性数(TP): ", TP, "\n")
cat("真陰性数(TN): ", TN, "\n")
cat("偽陽性数(FP): ", FP, "\n")
cat("偽陰性数(FN): ", FN, "\n\n")
}
## Cut-off: ≥ 0
## Actual
## Predicted 0 1
## 0 399 0
## 1 45 0
## 特異度(Sp): 0.8986486
## 感度(Se): NA
## 陽性尤度比(LR+): NA
## 陰性尤度比(LR-): NA
## 真陽性数(TP): 0
## 真陰性数(TN): 399
## 偽陽性数(FP): 45
## 偽陰性数(FN): 0
##
## Cut-off: ≥ 1
## Actual
## Predicted 0 1
## 0 199 0
## 1 200 45
## 特異度(Sp): 0.4987469
## 感度(Se): 1
## 陽性尤度比(LR+): 1.995
## 陰性尤度比(LR-): 0
## 真陽性数(TP): 45
## 真陰性数(TN): 199
## 偽陽性数(FP): 200
## 偽陰性数(FN): 0
##
## Cut-off: ≥ 2
## Actual
## Predicted 0 1
## 0 303 8
## 1 96 37
## 特異度(Sp): 0.7593985
## 感度(Se): 0.8222222
## 陽性尤度比(LR+): 3.417361
## 陰性尤度比(LR-): 0.2341034
## 真陽性数(TP): 37
## 真陰性数(TN): 303
## 偽陽性数(FP): 96
## 偽陰性数(FN): 8
##
## Cut-off: ≥ 3
## Actual
## Predicted 0 1
## 0 355 14
## 1 44 31
## 特異度(Sp): 0.8897243
## 感度(Se): 0.6888889
## 陽性尤度比(LR+): 6.24697
## 陰性尤度比(LR-): 0.3496714
## 真陽性数(TP): 31
## 真陰性数(TN): 355
## 偽陽性数(FP): 44
## 偽陰性数(FN): 14
##
## Cut-off: ≥ 4
## Actual
## Predicted 0 1
## 0 387 27
## 1 12 18
## 特異度(Sp): 0.9699248
## 感度(Se): 0.4
## 陽性尤度比(LR+): 13.3
## 陰性尤度比(LR-): 0.6186047
## 真陽性数(TP): 18
## 真陰性数(TN): 387
## 偽陽性数(FP): 12
## 偽陰性数(FN): 27
##
## Cut-off: ≥ 5
## Actual
## Predicted 0 1
## 0 396 40
## 1 3 5
## 特異度(Sp): 0.9924812
## 感度(Se): 0.1111111
## 陽性尤度比(LR+): 14.77778
## 陰性尤度比(LR-): 0.8956229
## 真陽性数(TP): 5
## 真陰性数(TN): 396
## 偽陽性数(FP): 3
## 偽陰性数(FN): 40
dca_optin <-
decision_curve(hosp_mortality ~ predicted_manual,
data = dev_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# データをプロット
plot_decision_curve(dca_optin,
curve.names = "Model",
legend.position = "topright",
confidence.intervals = F,
standardize = F)
# 初期のモデルのDCAを計算
dca_optin <- decision_curve(hosp_mortality ~ predicted_manual,
data = dev_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# 年齢に基づくロジスティック回帰モデルを作成
age_model <- glm(hosp_mortality ~ age, data = dev_imp, family = binomial)
# 予測値(予測確率)を取得
dev_imp$age_predicted <- predict(age_model, newdata = dev_imp, type = "response")
# 年齢に基づくモデルのDCAを計算
dca_age <- decision_curve(hosp_mortality ~ age_predicted,
data = dev_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# child_numに基づくロジスティック回帰モデルを作成
child_num_model <- glm(hosp_mortality ~ child_num, data = dev_imp, family = binomial)
# 予測値(予測確率)を取得
dev_imp$child_num_predicted <- predict(child_num_model, newdata = dev_imp, type = "response")
# child_numに基づくモデルのDCAを計算
dca_child_num <- decision_curve(hosp_mortality ~ child_num_predicted,
data = dev_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# MELDに基づくロジスティック回帰モデルを作成
meld_model <- glm(hosp_mortality ~ meld, data = dev_imp, family = binomial)
# 予測値(予測確率)を取得
dev_imp$meld_predicted <- predict(meld_model, newdata = dev_imp, type = "response")
# MELDに基づくモデルのDCAを計算
dca_meld <- decision_curve(hosp_mortality ~ meld_predicted,
data = dev_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# すべてのモデルをプロット
plot_decision_curve(list(dca_optin, dca_meld, dca_child_num, dca_age),
curve.names = c("HOPE-EVL score", "MELD score", "Child-Pugh score","Age"),
legend.position = "topright",
confidence.intervals = F,
standardize = F)
## Note: When multiple decision curves are plotted, decision curves for 'All' are calculated using the prevalence from the first DecisionCurve object in the list provided.
# 初期のモデルのDCAを計算
dca_optin_val <- decision_curve(hosp_mortality ~ predicted_manual,
data = val_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# 年齢に基づくロジスティック回帰モデルを作成
age_model_val <- glm(hosp_mortality ~ age, data = val_imp, family = binomial)
# 予測値(予測確率)を取得
val_imp$age_predicted <- predict(age_model_val, newdata = val_imp, type = "response")
# 年齢に基づくモデルのDCAを計算
dca_age_val <- decision_curve(hosp_mortality ~ age_predicted,
data = val_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# child_numに基づくロジスティック回帰モデルを作成
child_num_model_val <- glm(hosp_mortality ~ child_num, data = val_imp, family = binomial)
# 予測値(予測確率)を取得
val_imp$child_num_predicted <- predict(child_num_model_val, newdata = val_imp, type = "response")
# child_numに基づくモデルのDCAを計算
dca_child_num_val <- decision_curve(hosp_mortality ~ child_num_predicted,
data = val_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# MELDに基づくロジスティック回帰モデルを作成
meld_model_val <- glm(hosp_mortality ~ meld, data = val_imp, family = binomial)
# 予測値(予測確率)を取得
val_imp$meld_predicted <- predict(meld_model_val, newdata = val_imp, type = "response")
# MELDに基づくモデルのDCAを計算
dca_meld_val <- decision_curve(hosp_mortality ~ meld_predicted,
data = val_imp,
policy = "opt-in",
fitted.risk = T,
thresholds = seq(0, 0.5 ,by = 0.05))
# すべてのモデルをプロット
plot_decision_curve(list(dca_optin_val, dca_meld_val, dca_child_num_val, dca_age_val),
curve.names = c("HOPE-EVL score", "MELD score", "Child-Pugh score","Age"),
legend.position = "topright",
confidence.intervals = F,
standardize = F)
## Note: When multiple decision curves are plotted, decision curves for 'All' are calculated using the prevalence from the first DecisionCurve object in the list provided.