A rare, yet potentially life-threatening, disease associated with red blood cell (RBC) transfusion. A prior Transfusion-associated hyperkalemia (TAH) study reported total 35 pediatric patients who had hyperkalemia during or within 12 hours after the RBC transfusion from four facilities in 1-year period (2015-2016). The researchers examined the overall prevalence of TAH in pediatric population is 0.93%, 1-days mortality after TAH is as high as 20% in such patients, all patients who experienced TAH were severely ill with multiple comorbidities, transfused volume within 12 hours before the TAH occurrence was 24%, but infusion rate was high (19.57 ml/Kg/hour).

In this new research, we collected data from the pediatric patients with RBC transfusion without TAH serving as a control group to contrast patients with TAH and without TAH. We performed model-based and model-free multivariable analyses to predict TAH.

1 Background

This is a pediatric study of Transfusion Associated Hyperkalemia (TAH). The multi-institutional and retrospective study is trying to examine the risk factors associated with fatal hyperkalemia following RBC transfusion in pediatric population (<18 years old). A prior study is already published in 2021.

This follow up study aims to investigate the differences between a control group (\(n=60\)) and the TAH group (\(n=35\)). We would like to:

  • Compare the two cohorts and quantify their differences determine which factors play a key role in discriminating the populations,
  • Identify risk factors associated with TAH (e.g., age, body weight, transfusion volume, infusion rate, irradiation of the unit, etc).

2 Data Import

Using the latest dataset: rev8_Data_N_95_TransfusionHyperkalemia.csv.

setwd(file.path("C:/Users/dinov/Desktop/Ivo.dir/Research/UMichigan/Collaborations/2021/Chisa_Yamada_Pediatric_Pathology_Hyperkalemia_Study/TAH_Paper_2022/R3/"))
TAH_data <- read.csv("rev8_Data_N_95_TransfusionHyperkalemia.csv", head=T)

factorVarNames <- c('Case' ,'Group', 'TAH_occurrence', 'Mortality1Day', 'Sex', 'Race', 'Access', 'Dialysis', 'Cardiac_dysf', 
           'Respiratory_dysf', 'Kidney_dysf', 'Liver_dysf', 'Intracranial_diso', 'Orthopedics', 'Anemia',
           'Hemoglobinopathy', 'Sepsis', 'ECMO', 'CPB', 'Prematurity',  'RBC_Unit_type',
           'Leukoreduction', 'Irradiation', 'Washed', 'Plasma_reduction')
TAH_data[ , factorVarNames] <- lapply(TAH_data[ , factorVarNames] , factor)

# Impute the missing data
summary(TAH_data)
##       Case    Group  TAH_occurrence  Mortality1Day Sex         Race   
##  1      : 2   1:22   0:60           0       :87    1:43   1      :33  
##  2      : 2   2:17   1:35           1       : 7    2:52   2      :21  
##  3      : 2   3:24                  missing : 1           3      : 6  
##  4      : 2   4:13                                        4      : 1  
##  5      : 2   5:19                                        5      :27  
##  6      : 2                                               Missing: 7  
##  (Other):83                                                           
##      Access      Age_days        Weight           eTBV       
##  1      :26   Min.   :   1   Min.   : 0.63   Min.   :  63.0  
##  2      :36   1st Qu.:  43   1st Qu.: 3.48   1st Qu.: 284.5  
##  Missing:33   Median : 723   Median :11.00   Median : 735.0  
##               Mean   :1784   Mean   :18.22   Mean   :1254.6  
##               3rd Qu.:3264   3rd Qu.:27.25   3rd Qu.:1848.0  
##               Max.   :6346   Max.   :74.40   Max.   :4836.0  
##                                                              
##  Pre_transfusion_K  Cr_at_transfusion  Cardiac_dysf Respiratory_dysf
##  Length:95          Length:95          0:74         0:60            
##  Class :character   Class :character   1:21         1:35            
##  Mode  :character   Mode  :character                                
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##  Kidney_dysf Liver_dysf Intracranial_diso Orthopedics Anemia Hemoglobinopathy
##  0:71        0:82       0:84              0:91        0:47   0:86            
##  1:24        1:13       1:11              1: 4        1:48   1: 9            
##                                                                              
##                                                                              
##                                                                              
##                                                                              
##                                                                              
##  Sepsis ECMO   CPB    Prematurity Dialysis RBC_Unit_type Age_of_RBC_unit
##  0:87   0:85   0:91   0:71        0:89     1      :29    Min.   : 1.00  
##  1: 8   1:10   1: 4   1:24        1: 6     2      :62    1st Qu.: 6.00  
##                                            3      : 3    Median :10.00  
##                                            Missing: 1    Mean   :12.97  
##                                                          3rd Qu.:17.00  
##                                                          Max.   :42.00  
##                                                                         
##  Leukoreduction Irradiation Washed Plasma_reduction tV_12_weight_ml_Kg
##  0: 3           0:29        0:93   0:94             Min.   :  4.39    
##  1:92           1:66        1: 2   1: 1             1st Qu.: 10.54    
##                                                     Median : 15.22    
##                                                     Mean   : 27.58    
##                                                     3rd Qu.: 21.81    
##                                                     Max.   :283.65    
##                                                                       
##    tV_12_eTBV     Infusion_rate_hour_Pt_weight Infusion_rate_hour_eTBV
##  Min.   :0.0600   Length:95                    Length:95              
##  1st Qu.:0.1450   Class :character             Class :character       
##  Median :0.2100   Mode  :character             Mode  :character       
##  Mean   :0.3802                                                       
##  3rd Qu.:0.2800                                                       
##  Max.   :4.3600                                                       
##                                                                       
##  Time_from_irradition_to_transfusion_min
##  Length:95                              
##  Class :character                       
##  Mode  :character                       
##                                         
##                                         
##                                         
## 
# Quick code to replace missing values with the mean
df_TAH_data_NA <- data.frame(sapply(TAH_data[ , -1], function(x) ifelse(x=="Missing", "NA",x)))
df_TAH_data_numeric <- as.data.frame(sapply(df_TAH_data_NA, as.numeric)) 
df_TAH_data_impute_mean <- data.frame(sapply(df_TAH_data_numeric, function(x) ifelse(is.na(x), as.integer(median(x, na.rm = TRUE)), x)))

df_TAH_data_impute_mean <- subset(df_TAH_data_impute_mean, 
                                   # select = -c(tV_12_weight_ml_Kg, Infusion_rate_hour_Pt_weight, eTBV))
                                   select = -c(eTBV))

Note: Make a separate chi-square test for access, to address the significant missingness…

3 Summary Statystics (Collective and Grouping by Age and Cohort)

library(DT)
# Round a single data-frame
round_df <- function(x, digits) {
    # round all numeric variables
    # x: data frame 
    # digits: number of digits to round
    numeric_columns <- sapply(x, mode) == 'numeric'
    x[numeric_columns] <-  round(x[numeric_columns], digits)
    x
}

# Round a list of data-frames
round_list_df <- function(x, digits) {
    # round all numeric variables
    # x: data frame 
    # digits: number of digits to round
    n <- length(x)
    for (i in 1:n) {
      numeric_columns <- sapply(x[[i]], mode) == 'numeric'
      x[[i]][numeric_columns] <-  round(x[[i]][numeric_columns], digits)
    }
    x
}

3.1 Multivariate Relations and Variable Inflation Factors (VIF)

VIF of \(1.5\) indicates that the variance of a particular coefficient is \(50\%\) bigger than the expected variance when there is no multicollinearity, i.e., when there is no correlation with other predictors. Interpreting the (raw) variance inflation factor (VIF) values is based on:

  • \(VIF\sim 1\), not correlated.
  • \(1\leq VIF\leq 5\), moderately correlated.
  • \(VIF > 5\), highly correlated.

The adjusted general VIF estimates account for the dimension of the confidence ellipsoid, \(GVIF^{\frac{1}{2*df}}\), where \(df\) is the degrees of freedom associated with the variable.

car::vif(glm(as.factor(TAH_occurrence) ~ ., data=df_TAH_data_impute_mean, family = "binomial")) 
##                                   Group                           Mortality1Day 
##                             7016.936412                               15.415438 
##                                     Sex                                    Race 
##                               23.687356                               46.961407 
##                                  Access                                Age_days 
##                              226.662073                             1202.468822 
##                                  Weight                       Pre_transfusion_K 
##                              637.752284                                7.334058 
##                       Cr_at_transfusion                            Cardiac_dysf 
##                              364.329292                              121.928097 
##                        Respiratory_dysf                             Kidney_dysf 
##                              277.336190                               97.775334 
##                              Liver_dysf                       Intracranial_diso 
##                                3.950198                               91.769367 
##                             Orthopedics                                  Anemia 
##                              180.362740                              240.307225 
##                        Hemoglobinopathy                                  Sepsis 
##                                2.299605                               52.395145 
##                                    ECMO                                     CPB 
##                                9.779380                              293.258070 
##                             Prematurity                                Dialysis 
##                              545.239945                              157.676999 
##                           RBC_Unit_type                         Age_of_RBC_unit 
##                              458.436895                              329.331761 
##                          Leukoreduction                             Irradiation 
##                               11.196305                              228.718812 
##                                  Washed                        Plasma_reduction 
##                                2.547648                                1.160800 
##                      tV_12_weight_ml_Kg                              tV_12_eTBV 
##                             3090.332264                             2113.421848 
##            Infusion_rate_hour_Pt_weight                 Infusion_rate_hour_eTBV 
##                             4058.700623                             5543.985431 
## Time_from_irradition_to_transfusion_min 
##                               15.430141

3.2 Complete Sample Statistics

data_tbl <- round_df(psych::describe(df_TAH_data_impute_mean), 3)
datatable(data_tbl, caption="Overall Study Descriptive Statistics")

3.3 Grouping by Age and Diagnosis

3.3.1 Grouping Solely by Diagnosis

# Group by df_TAH_data_impute_mean ~ Group
# Compute the descriptive statistics for each of the 2 TAH_occurrence groups (Dx)
data_tbls <- round_list_df(psych::describe(df_TAH_data_impute_mean ~ TAH_occurrence), 3)
titleDF   <- list()
df_list   <- list()

for (trait in 1:2) {
    if (trait==1) {
      titleDF[[trait]] <- paste0("Descriptive Statistics (Dx Cohort=Controls)")
    } else {
      titleDF[[trait]] <- paste0("Descriptive Statistics (Dx Cohort=TAH Patients)")
    }
    df_list[[ trait]] <- datatable(data_tbls[[trait]], caption=titleDF[[trait]])
}

df_list[[1]]
df_list[[2]]

3.3.2 Grouping by \(Age\times Diagnosis\)

# Group by df_TAH_data_impute_mean ~ Group + TAH_occurrence
# Compute the descriptive statistics for each of the 10 = 5*2 (Group * TAH_occurrence) data-frames
data_tbls <- round_list_df(psych::describe(df_TAH_data_impute_mean ~ Group + TAH_occurrence), 3)
titleDF   <- list()
df_list   <- list()

for (gr in 1:5) {
  for (trait in 1:2)  {
    if (trait==1) {
      titleDF[[(trait-1)*5 + gr]] <- paste0("Descriptive Statistics (Age Group=", gr, ", Dx Cohort=Controls)")
    } else {
      titleDF[[(trait-1)*5 + gr]] <- paste0("Descriptive Statistics (Age Group=", gr, ", Dx Cohort=TAH Patients)")
    }
    df_list[[(trait-1)*5 + gr]] <- 
      datatable(data_tbls[[(trait-1)*5 + gr]], caption=titleDF[[(trait-1)*5 + gr]])
    # data_tbls[[(trait-1)*5 + gr]]
  }
}

df_list[[1]]
df_list[[2]]
df_list[[3]]
df_list[[4]]
df_list[[5]]
df_list[[6]]
df_list[[7]]
df_list[[8]]
df_list[[9]]
df_list[[10]]

3.4 Other Statistics

aggregate(cbind(Group,TAH_occurrence) ~ Sex + Race, df_TAH_data_impute_mean, sum)
##   Sex Race Group TAH_occurrence
## 1   1    1    54             26
## 2   2    1    41             20
## 3   1    2    26             12
## 4   2    2    57             27
## 5   1    3     6              2
## 6   2    3    10              5
## 7   1    4     2              2
## 8   1    5    39             21
## 9   2    5    40             15
with(df_TAH_data_impute_mean, tapply(Sex, list(group=Group,TAH=TAH_occurrence), sum))
##      TAH
## group  1  2
##     1 19 15
##     2 21  7
##     3 20 16
##     4 19  1
##     5 18 11
library(dplyr)
# df_TAH_data_impute_mean %>% group_by(as.factor(Group), as.factor(TAH_occurrence)) %>%  summarize(sum)

library(reshape2)
dcast(df_TAH_data_impute_mean, Group ~ TAH_occurrence, fun.aggregate = length)
##   Group  1  2
## 1     1 12 10
## 2     2 12  5
## 3     3 12 12
## 4     4 12  1
## 5     5 12  7
# dplyr::count(df_TAH_data_impute_mean, c(Group,TAH_occurrence))

cross <- table(Group=df_TAH_data_impute_mean$Group, TAH=df_TAH_data_impute_mean$TAH_occurrence) 
addmargins(cross)
##      TAH
## Group  1  2 Sum
##   1   12 10  22
##   2   12  5  17
##   3   12 12  24
##   4   12  1  13
##   5   12  7  19
##   Sum 60 35  95
cross <- prop.table(cross, 2) 
addmargins(cross)
##      TAH
## Group          1          2        Sum
##   1   0.20000000 0.28571429 0.48571429
##   2   0.20000000 0.14285714 0.34285714
##   3   0.20000000 0.34285714 0.54285714
##   4   0.20000000 0.02857143 0.22857143
##   5   0.20000000 0.20000000 0.40000000
##   Sum 1.00000000 1.00000000 2.00000000
group_by(df_TAH_data_impute_mean, TAH_occurrence) %>%
  summarise(
    count = n(),
    Irradiation_mean = mean(Irradiation, na.rm = TRUE),
    Irradiation_sd = sd(Irradiation, na.rm = TRUE)
  )
## # A tibble: 2 × 4
##   TAH_occurrence count Irradiation_mean Irradiation_sd
##            <dbl> <int>            <dbl>          <dbl>
## 1              1    60             1.68          0.469
## 2              2    35             1.71          0.458
group_by(df_TAH_data_impute_mean, Group) %>%
  summarise(
    count = n(),
    Irradiation_mean = mean(Irradiation, na.rm = TRUE),
    Irradiation_sd = sd(Irradiation, na.rm = TRUE),
    tV_12_weight_ml_Kg_mean = mean(tV_12_weight_ml_Kg, na.rm = TRUE),
    tV_12_weight_ml_Kg_sd = sd(tV_12_weight_ml_Kg, na.rm = TRUE)
  )
## # A tibble: 5 × 6
##   Group count Irradiation_mean Irradiation_sd tV_12_weight_ml_Kg_mean tV_12_we…¹
##   <dbl> <int>            <dbl>          <dbl>                   <dbl>      <dbl>
## 1     1    22             1.64          0.492                    33.5      30.3 
## 2     2    17             1.82          0.393                    33.5      57.3 
## 3     3    24             1.75          0.442                    36.1      59.0 
## 4     4    13             1.54          0.519                    12.0       4.53
## 5     5    19             1.68          0.478                    15.4      16.9 
## # … with abbreviated variable name ¹​tV_12_weight_ml_Kg_sd

4 TAH Analysis

4.1 Table 2

4.1.1 Factor Variables (Chi-Square Test)

library(tidyverse)

for (i in 1:length(colnames(df_TAH_data_impute_mean))){
  print (colnames(df_TAH_data_impute_mean)[i])
  ifelse (colnames(df_TAH_data_impute_mean)[i] %in% 
            c("Age_days",
              "Weight",
              "Pre_transfusion_K",
              "Cr_at_transfusion", 
              "Age_of_RBC_unit",
              "tV_12_weight_ml_Kg",
              "tV_12_eTBV", 
              "Infusion_rate_hour_Pt_weight",
              "Infusion_rate_hour_eTBV", 
              "Time_from_irradition_to_transfusion_min"), 
          df_TAH_data_impute_mean[,i] <- as.numeric(df_TAH_data_impute_mean[,i]), 
          df_TAH_data_impute_mean[,i] <- as.factor(df_TAH_data_impute_mean[,i])) 
}
## [1] "Group"
## [1] "TAH_occurrence"
## [1] "Mortality1Day"
## [1] "Sex"
## [1] "Race"
## [1] "Access"
## [1] "Age_days"
## [1] "Weight"
## [1] "Pre_transfusion_K"
## [1] "Cr_at_transfusion"
## [1] "Cardiac_dysf"
## [1] "Respiratory_dysf"
## [1] "Kidney_dysf"
## [1] "Liver_dysf"
## [1] "Intracranial_diso"
## [1] "Orthopedics"
## [1] "Anemia"
## [1] "Hemoglobinopathy"
## [1] "Sepsis"
## [1] "ECMO"
## [1] "CPB"
## [1] "Prematurity"
## [1] "Dialysis"
## [1] "RBC_Unit_type"
## [1] "Age_of_RBC_unit"
## [1] "Leukoreduction"
## [1] "Irradiation"
## [1] "Washed"
## [1] "Plasma_reduction"
## [1] "tV_12_weight_ml_Kg"
## [1] "tV_12_eTBV"
## [1] "Infusion_rate_hour_Pt_weight"
## [1] "Infusion_rate_hour_eTBV"
## [1] "Time_from_irradition_to_transfusion_min"
indFactor <- sapply(df_TAH_data_impute_mean, is.factor)
table(indFactor)
## indFactor
## FALSE  TRUE 
##    10    24
# Contingency Table - TAH vs. Kidney-dysfunction, e.g., 
# table(df_TAH_data_impute_mean$TAH_occurrence, df_TAH_data_impute_mean$Kidney_dysf)

contTable <- list()
for (var in c(4:length(factorVarNames))) {
  print(paste0("TAH_occurrence vs ", factorVarNames[var]))
  contTable[[var-3]] <- table(df_TAH_data_impute_mean$TAH_occurrence,
        df_TAH_data_impute_mean[[factorVarNames[var]]],
        dnn = list("TAH_occurrence", factorVarNames[var]))
}
## [1] "TAH_occurrence vs Mortality1Day"
## [1] "TAH_occurrence vs Sex"
## [1] "TAH_occurrence vs Race"
## [1] "TAH_occurrence vs Access"
## [1] "TAH_occurrence vs Dialysis"
## [1] "TAH_occurrence vs Cardiac_dysf"
## [1] "TAH_occurrence vs Respiratory_dysf"
## [1] "TAH_occurrence vs Kidney_dysf"
## [1] "TAH_occurrence vs Liver_dysf"
## [1] "TAH_occurrence vs Intracranial_diso"
## [1] "TAH_occurrence vs Orthopedics"
## [1] "TAH_occurrence vs Anemia"
## [1] "TAH_occurrence vs Hemoglobinopathy"
## [1] "TAH_occurrence vs Sepsis"
## [1] "TAH_occurrence vs ECMO"
## [1] "TAH_occurrence vs CPB"
## [1] "TAH_occurrence vs Prematurity"
## [1] "TAH_occurrence vs RBC_Unit_type"
## [1] "TAH_occurrence vs Leukoreduction"
## [1] "TAH_occurrence vs Irradiation"
## [1] "TAH_occurrence vs Washed"
## [1] "TAH_occurrence vs Plasma_reduction"
# addmargins(contTable[[8]])   # "Kidney_dysf"
# prop.table(contTable[[8]])   # "Kidney_dysf"
# chisq.test(contTable[[8]])   # "Kidney_dysf"
# fisher.test(contTable[[8]])

for (var in c(4:length(factorVarNames))) {
  print(addmargins(contTable[[var-3]]))   
  print(prop.table(contTable[[var-3]]))   
  print(chisq.test(contTable[[var-3]]))
  ### Adjust p-values for multiple comparison
  factorPvalueResults_adj <-
    p.adjust(chisq.test(contTable[[var-3]])$p.value, method = 'fdr')
  print(paste0("Adjusted p-value: ", factorPvalueResults_adj))
}
##               Mortality1Day
## TAH_occurrence  1  2  3 Sum
##            1   59  0  1  60
##            2   28  7  0  35
##            Sum 87  7  1  95
##               Mortality1Day
## TAH_occurrence          1          2          3
##              1 0.62105263 0.00000000 0.01052632
##              2 0.29473684 0.07368421 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 3]]
## X-squared = 13.395, df = 2, p-value = 0.001234
## 
## [1] "Adjusted p-value: 0.00123421762995026"
##               Sex
## TAH_occurrence  1  2 Sum
##            1   23 37  60
##            2   20 15  35
##            Sum 43 52  95
##               Sex
## TAH_occurrence         1         2
##              1 0.2421053 0.3894737
##              2 0.2105263 0.1578947
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 2.4431, df = 1, p-value = 0.118
## 
## [1] "Adjusted p-value: 0.118042363651031"
##               Race
## TAH_occurrence  1  2  3  4  5 Sum
##            1   20 17  5  0 18  60
##            2   13 11  1  1  9  35
##            Sum 33 28  6  1 27  95
##               Race
## TAH_occurrence          1          2          3          4          5
##              1 0.21052632 0.17894737 0.05263158 0.00000000 0.18947368
##              2 0.13684211 0.11578947 0.01052632 0.01052632 0.09473684
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 3]]
## X-squared = 3.071, df = 4, p-value = 0.546
## 
## [1] "Adjusted p-value: 0.546022787542228"
##               Access
## TAH_occurrence  1  2 Sum
##            1   18 42  60
##            2    8 27  35
##            Sum 26 69  95
##               Access
## TAH_occurrence          1          2
##              1 0.18947368 0.44210526
##              2 0.08421053 0.28421053
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.26493, df = 1, p-value = 0.6068
## 
## [1] "Adjusted p-value: 0.606753866064084"
##               Dialysis
## TAH_occurrence  1  2 Sum
##            1   57  3  60
##            2   32  3  35
##            Sum 89  6  95
##               Dialysis
## TAH_occurrence          1          2
##              1 0.60000000 0.03157895
##              2 0.33684211 0.03157895
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.064066, df = 1, p-value = 0.8002
## 
## [1] "Adjusted p-value: 0.800180997258303"
##               Cardiac_dysf
## TAH_occurrence  1  2 Sum
##            1   47 13  60
##            2   27  8  35
##            Sum 74 21  95
##               Cardiac_dysf
## TAH_occurrence          1          2
##              1 0.49473684 0.13684211
##              2 0.28421053 0.08421053
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0, df = 1, p-value = 1
## 
## [1] "Adjusted p-value: 1"
##               Respiratory_dysf
## TAH_occurrence  1  2 Sum
##            1   35 25  60
##            2   25 10  35
##            Sum 60 35  95
##               Respiratory_dysf
## TAH_occurrence         1         2
##              1 0.3684211 0.2631579
##              2 0.2631579 0.1052632
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 1.1149, df = 1, p-value = 0.291
## 
## [1] "Adjusted p-value: 0.291012661013251"
##               Kidney_dysf
## TAH_occurrence  1  2 Sum
##            1   53  7  60
##            2   18 17  35
##            Sum 71 24  95
##               Kidney_dysf
## TAH_occurrence          1          2
##              1 0.55789474 0.07368421
##              2 0.18947368 0.17894737
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 14.051, df = 1, p-value = 0.0001779
## 
## [1] "Adjusted p-value: 0.000177939153222725"
##               Liver_dysf
## TAH_occurrence  1  2 Sum
##            1   56  4  60
##            2   26  9  35
##            Sum 82 13  95
##               Liver_dysf
## TAH_occurrence          1          2
##              1 0.58947368 0.04210526
##              2 0.27368421 0.09473684
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 5.2731, df = 1, p-value = 0.02166
## 
## [1] "Adjusted p-value: 0.0216575110494646"
##               Intracranial_diso
## TAH_occurrence  1  2 Sum
##            1   55  5  60
##            2   29  6  35
##            Sum 84 11  95
##               Intracranial_diso
## TAH_occurrence          1          2
##              1 0.57894737 0.05263158
##              2 0.30526316 0.06315789
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.92563, df = 1, p-value = 0.336
## 
## [1] "Adjusted p-value: 0.336000872717627"
##               Orthopedics
## TAH_occurrence  1  2 Sum
##            1   57  3  60
##            2   34  1  35
##            Sum 91  4  95
##               Orthopedics
## TAH_occurrence          1          2
##              1 0.60000000 0.03157895
##              2 0.35789474 0.01052632
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 6.1336e-31, df = 1, p-value = 1
## 
## [1] "Adjusted p-value: 0.999999999999999"
##               Anemia
## TAH_occurrence  1  2 Sum
##            1   24 36  60
##            2   23 12  35
##            Sum 47 48  95
##               Anemia
## TAH_occurrence         1         2
##              1 0.2526316 0.3789474
##              2 0.2421053 0.1263158
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 4.8638, df = 1, p-value = 0.02743
## 
## [1] "Adjusted p-value: 0.0274255139026991"
##               Hemoglobinopathy
## TAH_occurrence  1  2 Sum
##            1   52  8  60
##            2   34  1  35
##            Sum 86  9  95
##               Hemoglobinopathy
## TAH_occurrence          1          2
##              1 0.54736842 0.08421053
##              2 0.35789474 0.01052632
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 1.7392, df = 1, p-value = 0.1872
## 
## [1] "Adjusted p-value: 0.187244274713748"
##               Sepsis
## TAH_occurrence  1  2 Sum
##            1   57  3  60
##            2   30  5  35
##            Sum 87  8  95
##               Sepsis
## TAH_occurrence          1          2
##              1 0.60000000 0.03157895
##              2 0.31578947 0.05263158
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 1.4141, df = 1, p-value = 0.2344
## 
## [1] "Adjusted p-value: 0.23437750497731"
##               ECMO
## TAH_occurrence  1  2 Sum
##            1   56  4  60
##            2   29  6  35
##            Sum 85 10  95
##               ECMO
## TAH_occurrence          1          2
##              1 0.58947368 0.04210526
##              2 0.30526316 0.06315789
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 1.5837, df = 1, p-value = 0.2082
## 
## [1] "Adjusted p-value: 0.208233429915851"
##               CPB
## TAH_occurrence  1  2 Sum
##            1   58  2  60
##            2   33  2  35
##            Sum 91  4  95
##               CPB
## TAH_occurrence          1          2
##              1 0.61052632 0.02105263
##              2 0.34736842 0.02105263
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.00077675, df = 1, p-value = 0.9778
## 
## [1] "Adjusted p-value: 0.977765605178571"
##               Prematurity
## TAH_occurrence  1  2 Sum
##            1   46 14  60
##            2   25 10  35
##            Sum 71 24  95
##               Prematurity
## TAH_occurrence         1         2
##              1 0.4842105 0.1473684
##              2 0.2631579 0.1052632
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.1037, df = 1, p-value = 0.7474
## 
## [1] "Adjusted p-value: 0.747429380160965"
##               RBC_Unit_type
## TAH_occurrence  1  2  3 Sum
##            1   17 40  3  60
##            2   12 23  0  35
##            Sum 29 63  3  95
##               RBC_Unit_type
## TAH_occurrence          1          2          3
##              1 0.17894737 0.42105263 0.03157895
##              2 0.12631579 0.24210526 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 3]]
## X-squared = 2.0096, df = 2, p-value = 0.3661
## 
## [1] "Adjusted p-value: 0.366119393126778"
##               Leukoreduction
## TAH_occurrence  1  2 Sum
##            1    3 57  60
##            2    0 35  35
##            Sum  3 92  95
##               Leukoreduction
## TAH_occurrence          1          2
##              1 0.03157895 0.60000000
##              2 0.00000000 0.36842105
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.54191, df = 1, p-value = 0.4616
## 
## [1] "Adjusted p-value: 0.461640301416673"
##               Irradiation
## TAH_occurrence  1  2 Sum
##            1   19 41  60
##            2   10 25  35
##            Sum 29 66  95
##               Irradiation
## TAH_occurrence         1         2
##              1 0.2000000 0.4315789
##              2 0.1052632 0.2631579
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.0072383, df = 1, p-value = 0.9322
## 
## [1] "Adjusted p-value: 0.93219907427448"
##               Washed
## TAH_occurrence  1  2 Sum
##            1   58  2  60
##            2   35  0  35
##            Sum 93  2  95
##               Washed
## TAH_occurrence          1          2
##              1 0.61052632 0.02105263
##              2 0.36842105 0.00000000
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 0.12313, df = 1, p-value = 0.7257
## 
## [1] "Adjusted p-value: 0.725666503561585"
##               Plasma_reduction
## TAH_occurrence  1  2 Sum
##            1   59  1  60
##            2   35  0  35
##            Sum 94  1  95
##               Plasma_reduction
## TAH_occurrence          1          2
##              1 0.62105263 0.01052632
##              2 0.36842105 0.00000000
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contTable[[var - 3]]
## X-squared = 5.2911e-31, df = 1, p-value = 1
## 
## [1] "Adjusted p-value: 0.999999999999999"
# ### Adjust p-values for multiple comparison
# df_TAH_data_impute_mean_factor <- df_TAH_data_impute_mean[, indFactor]
# factorPvalueResults <- df_TAH_data_impute_mean_factor[-1] %>% 
#     summarise_each(funs(chisq.test(., df_TAH_data_impute_mean_factor[-1]$TAH_occurrence)$p.value), 
#                    -one_of("TAH_occurrence"))     
# factorPvalueResults_adj <- p.adjust(factorPvalueResults, method = 'fdr')
# factorPvalueResults_adj

4.1.2 Special case for Access

Account for the significant missingness in the variable access.

print("TAH_occurrence vs Access")
## [1] "TAH_occurrence vs Access"
ctTable <- table(TAH_data$TAH_occurrence, TAH_data$Access,
        dnn = list("TAH_occurrence", "Access"))
print(addmargins(ctTable))   
##               Access
## TAH_occurrence  1  2 Missing Sum
##            0   18 29      13  60
##            1    8  7      20  35
##            Sum 26 36      33  95
print(prop.table(ctTable))   
##               Access
## TAH_occurrence          1          2    Missing
##              0 0.18947368 0.30526316 0.13684211
##              1 0.08421053 0.07368421 0.21052632
print(chisq.test(ctTable))
## 
##  Pearson's Chi-squared test
## 
## data:  ctTable
## X-squared = 13.104, df = 2, p-value = 0.001427
### Adjust p-values for multiple comparison
factorPvalueResults_adj <- p.adjust(chisq.test(ctTable)$p.value, method = 'fdr')
print(paste0("TAH vs. Access Adjusted p-value: ", factorPvalueResults_adj))
## [1] "TAH vs. Access Adjusted p-value: 0.00142727460940099"

4.1.3 Quantitative numerical variables (Wilcoxon test)

############################################################
# If need to adjust numeric and factor p-values separately #
############################################################
df_TAH_data_impute_mean_numeric <- df_TAH_data_impute_mean[, !indFactor]
tests_list <- lapply(colnames(df_TAH_data_impute_mean_numeric),
                     function(x) wilcox.test(
                       as.formula(paste0(x, "~ TAH_occurrence")), 
                       data = cbind(df_TAH_data_impute_mean_numeric,
                       TAH_occurrence=df_TAH_data_impute_mean$TAH_occurrence)))

numericPvalueResults <- sapply(tests_list, `[[`, "p.value")
numericPvalueResults_adj <- p.adjust(numericPvalueResults, method = 'fdr')
result <- cbind(QuantVariables=colnames(df_TAH_data_impute_mean[!indFactor]),
                numeric_TAH_Pvalues=as.numeric(numericPvalueResults),
                numeric_TAH_Pvalues_adj=as.numeric(numericPvalueResults_adj))
result
##       QuantVariables                            numeric_TAH_Pvalues   
##  [1,] "Age_days"                                "0.204330730300978"   
##  [2,] "Weight"                                  "0.451902378599295"   
##  [3,] "Pre_transfusion_K"                       "0.0325746993155222"  
##  [4,] "Cr_at_transfusion"                       "0.000736976834655347"
##  [5,] "Age_of_RBC_unit"                         "0.0200204860912063"  
##  [6,] "tV_12_weight_ml_Kg"                      "0.00286239354727626" 
##  [7,] "tV_12_eTBV"                              "0.00680924098372903" 
##  [8,] "Infusion_rate_hour_Pt_weight"            "0.184471972128806"   
##  [9,] "Infusion_rate_hour_eTBV"                 "1"                   
## [10,] "Time_from_irradition_to_transfusion_min" "0.875201386003872"   
##       numeric_TAH_Pvalues_adj
##  [1,] "0.291901043287112"    
##  [2,] "0.564877973249119"    
##  [3,] "0.0651493986310444"   
##  [4,] "0.00736976834655347"  
##  [5,] "0.0500512152280158"   
##  [6,] "0.0143119677363813"   
##  [7,] "0.0226974699457634"   
##  [8,] "0.291901043287112"    
##  [9,] "1"                    
## [10,] "0.972445984448747"

4.2 Other results

library(tidyverse)

for (i in 1:length(colnames(df_TAH_data_impute_mean))) { # Separate Factor & Numeric Var's
  print (colnames(df_TAH_data_impute_mean)[i])
  ifelse (colnames(df_TAH_data_impute_mean)[i] %in% 
            c("Age_days",
              "Weight",
              "Pre_transfusion_K",
              "Cr_at_transfusion", 
              "Age_of_RBC_unit",
              "tV_12_weight_ml_Kg",
              "tV_12_eTBV", 
              "Infusion_rate_hour_Pt_weight",
              "Infusion_rate_hour_eTBV", 
              "Time_from_irradition_to_transfusion_min"), 
          df_TAH_data_impute_mean[,i] <- as.numeric(df_TAH_data_impute_mean[,i]), 
          df_TAH_data_impute_mean[,i] <- as.factor(df_TAH_data_impute_mean[,i])) 
}
## [1] "Group"
## [1] "TAH_occurrence"
## [1] "Mortality1Day"
## [1] "Sex"
## [1] "Race"
## [1] "Access"
## [1] "Age_days"
## [1] "Weight"
## [1] "Pre_transfusion_K"
## [1] "Cr_at_transfusion"
## [1] "Cardiac_dysf"
## [1] "Respiratory_dysf"
## [1] "Kidney_dysf"
## [1] "Liver_dysf"
## [1] "Intracranial_diso"
## [1] "Orthopedics"
## [1] "Anemia"
## [1] "Hemoglobinopathy"
## [1] "Sepsis"
## [1] "ECMO"
## [1] "CPB"
## [1] "Prematurity"
## [1] "Dialysis"
## [1] "RBC_Unit_type"
## [1] "Age_of_RBC_unit"
## [1] "Leukoreduction"
## [1] "Irradiation"
## [1] "Washed"
## [1] "Plasma_reduction"
## [1] "tV_12_weight_ml_Kg"
## [1] "tV_12_eTBV"
## [1] "Infusion_rate_hour_Pt_weight"
## [1] "Infusion_rate_hour_eTBV"
## [1] "Time_from_irradition_to_transfusion_min"
indFactor <- sapply(df_TAH_data_impute_mean, is.factor)
table(indFactor)
## indFactor
## FALSE  TRUE 
##    10    24
##################################################################
# If don't need to adjust numeric and factor p-values separately #
##################################################################

Pvalue = function(x) {
  if (is.factor(x)) {
    ##print(paste0("Variable: ", x))
    return(chisq.test(x, df_TAH_data_impute_mean$TAH_occurrence)$p.value)
  } else {
    return(wilcox.test(x ~ df_TAH_data_impute_mean$TAH_occurrence)$p.value)
  }
}

PvalueResults = sapply(df_TAH_data_impute_mean[, 3:dim(df_TAH_data_impute_mean)[2]], Pvalue)
PvalueResults_adj = p.adjust(PvalueResults, method="fdr")

result = cbind(p.value.fdr.adj = unname(PvalueResults_adj))
rownames(result) = names(PvalueResults_adj)
result
##                                         p.value.fdr.adj
## Mortality1Day                               0.013164988
## Sex                                         0.377735564
## Race                                        0.832034724
## Access                                      0.882551078
## Age_days                                    0.475962126
## Weight                                      0.738624482
## Pre_transfusion_K                           0.115821153
## Cr_at_transfusion                           0.011791629
## Cardiac_dysf                                1.000000000
## Respiratory_dysf                            0.582025322
## Kidney_dysf                                 0.005694053
## Liver_dysf                                  0.099005765
## Intracranial_diso                           0.632472231
## Orthopedics                                 1.000000000
## Anemia                                      0.109702056
## Hemoglobinopathy                            0.475962126
## Sepsis                                      0.500005344
## ECMO                                        0.475962126
## CPB                                         1.000000000
## Prematurity                                 0.996572507
## Dialysis                                    1.000000000
## RBC_Unit_type                               0.650878921
## Age_of_RBC_unit                             0.099005765
## Leukoreduction                              0.738624482
## Irradiation                                 1.000000000
## Washed                                      0.996572507
## Plasma_reduction                            1.000000000
## tV_12_weight_ml_Kg                          0.022899148
## tV_12_eTBV                                  0.043579142
## Infusion_rate_hour_Pt_weight                0.475962126
## Infusion_rate_hour_eTBV                     1.000000000
## Time_from_irradition_to_transfusion_min     1.000000000
############################################################
# If need to adjust numeric and factor p-values separately #
############################################################

df_TAH_data_impute_mean_factor <- df_TAH_data_impute_mean[, indFactor]
factorPvalueResults <- df_TAH_data_impute_mean_factor[-1] %>% 
    summarise_each(funs(chisq.test(., df_TAH_data_impute_mean_factor[-1]$TAH_occurrence)$p.value), 
                   -one_of("TAH_occurrence"))     
factorPvalueResults_adj <- p.adjust(factorPvalueResults, method = 'fdr')

df_TAH_data_impute_mean_numeric <- df_TAH_data_impute_mean[, !indFactor]

tests_list <- lapply(colnames(df_TAH_data_impute_mean_numeric),
                     function(x) wilcox.test(
                       as.formula(paste0(x, "~ TAH_occurrence")), 
                       data = cbind(df_TAH_data_impute_mean_numeric,
                                    TAH_occurrence=df_TAH_data_impute_mean$TAH_occurrence)))

numericPvalueResults <- sapply(tests_list, `[[`, "p.value")
numericPvalueResults_adj <- p.adjust(numericPvalueResults, method = 'fdr')
PvalueResults_adj = c(unname(factorPvalueResults_adj), numericPvalueResults_adj)
result <- cbind(p.value.fdr.adj = PvalueResults_adj)
rownames(result) <- c(names(factorPvalueResults_adj), 
                      colnames(df_TAH_data_impute_mean[!indFactor]))
result
##                                         p.value.fdr.adj
## Mortality1Day                               0.013576394
## Sex                                         0.519386400
## Race                                        0.924038564
## Access                                      0.953470361
## Cardiac_dysf                                1.000000000
## Respiratory_dysf                            0.711364282
## Kidney_dysf                                 0.003914661
## Liver_dysf                                  0.150840326
## Intracranial_diso                           0.732238786
## Orthopedics                                 1.000000000
## Anemia                                      0.150840326
## Hemoglobinopathy                            0.644538139
## Sepsis                                      0.644538139
## ECMO                                        0.644538139
## CPB                                         1.000000000
## Prematurity                                 1.000000000
## Dialysis                                    1.000000000
## RBC_Unit_type                               0.732238786
## Leukoreduction                              0.846340553
## Irradiation                                 1.000000000
## Washed                                      1.000000000
## Plasma_reduction                            1.000000000
## Age_days                                    0.291901043
## Weight                                      0.564877973
## Pre_transfusion_K                           0.065149399
## Cr_at_transfusion                           0.007369768
## Age_of_RBC_unit                             0.050051215
## tV_12_weight_ml_Kg                          0.014311968
## tV_12_eTBV                                  0.022697470
## Infusion_rate_hour_Pt_weight                0.291901043
## Infusion_rate_hour_eTBV                     1.000000000
## Time_from_irradition_to_transfusion_min     0.972445984
# Paired TAH t-tests comparing patients vs. controls
# Which test to use: http://www.bristol.ac.uk/medical-school/media/rms/red/which_test.html
library(tidyverse)

#########  Factor variables  ===============
# df_TAH_data_impute_mean_wo_TAH <- subset(df_TAH_data_impute_mean, select = -c(TAH_occurrence))
# 
# for (i in 1:length(colnames(df_TAH_data_impute_mean_wo_TAH))){
#   print (colnames(df_TAH_data_impute_mean_wo_TAH)[i])
#   ifelse (colnames(df_TAH_data_impute_mean_wo_TAH)[i] %in% c("Age_days", "Weight", "Pre_transfusion_K", "Cr_at_transfusion", 
#                                                        "Age_of_RBC_unit", "tV_12_weight_ml_Kg", "tV_12_eTBV", 
#                                                        "Infusion_rate_hour_Pt_weight", "Infusion_rate_hour_eTBV", 
#                                                        "Time_from_irradition_to_transfusion_min"), 
#           df_TAH_data_impute_mean_wo_TAH[,i] <- as.numeric(df_TAH_data_impute_mean_wo_TAH[,i]), 
#           df_TAH_data_impute_mean_wo_TAH[,i] <- as.factor(df_TAH_data_impute_mean_wo_TAH[,i])) 
# }
# indFactor <- sapply(df_TAH_data_impute_mean_wo_TAH, is.factor)
# table(indFactor)
for (i in 1:length(colnames(df_TAH_data_impute_mean))){
  print (colnames(df_TAH_data_impute_mean)[i])
  ifelse (colnames(df_TAH_data_impute_mean)[i] %in% c("Age_days", "Weight", "Pre_transfusion_K", "Cr_at_transfusion", 
                                                       "Age_of_RBC_unit", "tV_12_weight_ml_Kg", "tV_12_eTBV", 
                                                       "Infusion_rate_hour_Pt_weight", "Infusion_rate_hour_eTBV", 
                                                       "Time_from_irradition_to_transfusion_min"), 
          df_TAH_data_impute_mean[,i] <- as.numeric(df_TAH_data_impute_mean[,i]), 
          df_TAH_data_impute_mean[,i] <- as.factor(df_TAH_data_impute_mean[,i])) 
}
## [1] "Group"
## [1] "TAH_occurrence"
## [1] "Mortality1Day"
## [1] "Sex"
## [1] "Race"
## [1] "Access"
## [1] "Age_days"
## [1] "Weight"
## [1] "Pre_transfusion_K"
## [1] "Cr_at_transfusion"
## [1] "Cardiac_dysf"
## [1] "Respiratory_dysf"
## [1] "Kidney_dysf"
## [1] "Liver_dysf"
## [1] "Intracranial_diso"
## [1] "Orthopedics"
## [1] "Anemia"
## [1] "Hemoglobinopathy"
## [1] "Sepsis"
## [1] "ECMO"
## [1] "CPB"
## [1] "Prematurity"
## [1] "Dialysis"
## [1] "RBC_Unit_type"
## [1] "Age_of_RBC_unit"
## [1] "Leukoreduction"
## [1] "Irradiation"
## [1] "Washed"
## [1] "Plasma_reduction"
## [1] "tV_12_weight_ml_Kg"
## [1] "tV_12_eTBV"
## [1] "Infusion_rate_hour_Pt_weight"
## [1] "Infusion_rate_hour_eTBV"
## [1] "Time_from_irradition_to_transfusion_min"
indFactor <- sapply(df_TAH_data_impute_mean, is.factor)
table(indFactor)
## indFactor
## FALSE  TRUE 
##    10    24
# dat[indFactor] <- lapply(dat[indx], as.numeric.factor)
# str(df_TAH_data_impute_mean_wo_TAH)
df_TAH_data_impute_mean_factor <- df_TAH_data_impute_mean[, indFactor]
factorPvalueResults <- df_TAH_data_impute_mean_factor[-1] %>% 
    summarise_each(funs(chisq.test(., df_TAH_data_impute_mean_factor[-1]$TAH_occurrence)$p.value), 
                   -one_of("TAH_occurrence"))     
factorPvalueResults_adj <- p.adjust(factorPvalueResults, method = 'fdr')

# For Kidney dysfunction
p.adjust(chisq.test(cbind(x=c(17,18), y=c(7,53)))$p.value, method = 'fdr', n=18) # Pearson's Chi^2 test / Yates' continuity correction
## [1] 0.003202905
# data:  cbind(x = c(17, 18), y = c(7, 53))
# X-squared = 14.051, df = 1, p-value = 0.0001779, adj.p.value = 0.003202905

######### Numerical Variables ===============
# df_TAH_data_impute_mean_wo_TAH <- subset(df_TAH_data_impute_mean_wo_TAH, select = -c(TAH_occurrence, indFactor))
# 
# tests_list <- lapply(colnames(df_TAH_data_impute_mean_wo_TAH[-indFactor]), 
#                      # function(x) t.test(as.formula(paste0(x, "~ TAH_occurrence")), data = df_TAH_data_impute_mean)) # Parametric t-test
#                      # Wilcoxon rank sum test with continuity correction
#                      function(x) wilcox.test(as.formula(paste0(x, "~ TAH_occurrence")), data = df_TAH_data_impute_mean)) # Non-parametric Wilcox-test
# 
# result <- do.call(rbind, lapply(tests_list, `[[`, "estimate"))
# pval <- sapply(tests_list, `[[`, "p.value")
# pval_adj <- p.adjust(pval, method = 'fdr')
# est <- sapply(tests_list, `[[`, "statistic")
# result <- cbind(result, Wilcoxon.p.value.fdr.adj = pval_adj)
# rownames(result) <- colnames(df_TAH_data_impute_mean_wo_TAH[-indFactor])
# result

# colnames(df_TAH_data_impute_clean)
# colnames(TAH_data)
# df_TAH_data_impute_mean$Mortality1Day <- ifelse(df_TAH_data_impute_mean$Mortality1Day<0.5, "0", "1")
# rownames(df_TAH_data_impute_mean) <- df_TAH_data_impute_mean[ , 1]
# df_TAH_data_impute_mean <- df_TAH_data_impute_mean[ , -1]

# EDA
library(tidyverse)
df_TAH_data_Mortality0 <- filter(df_TAH_data_impute_mean, Mortality1Day==1)
dim(df_TAH_data_Mortality0)   # [1] 87 41
## [1] 87 34
df_TAH_data_Mortality1 <- filter(df_TAH_data_impute_mean, Mortality1Day==2)
dim(df_TAH_data_Mortality1)   # 7 41
## [1]  7 34
# note that some missing Mortality1Day values are estimated to be between 0 and 1!

#### Cohort separation
df_TAH_data_TAH_Controls<- filter(df_TAH_data_impute_mean, TAH_occurrence==1)
dim(df_TAH_data_TAH_Controls)   # [1] 60 41
## [1] 60 34
df_TAH_data_TAH_Patients <- filter(df_TAH_data_impute_mean, TAH_occurrence==2)
dim(df_TAH_data_TAH_Patients)   # 35 41
## [1] 35 34
select_Group_Sex_Mortality_TAH <- select(df_TAH_data_impute_mean, Group, Sex, Mortality1Day)

library(ggplot2)
ggplot(data = df_TAH_data_impute_mean, mapping = aes(x = as.numeric(Mortality1Day), colour = as.factor(Group))) +
  geom_freqpoly(binwidth = 0.1)

ggplot(data = df_TAH_data_impute_mean, mapping = aes(x = as.factor(Group), y = tV_12_eTBV)) +
  geom_boxplot()

library(plotly)
plot_ly(df_TAH_data_impute_mean) %>%
    add_trace(type = 'splom', dimensions = list( list(label='Infusion_rate_hour_eTBV', values=~Infusion_rate_hour_eTBV), 
                                                 list(label='Mortality1Day', values=~Mortality1Day),
                                                 list(label='Sex', values=~Sex), 
                                                 list(label='Age_days', values=~Age_days), 
                                                 list(label='Time_from_iradition_to_transfusion_min',
                                                      values=~Irradiation), 
                                                 list(label='tV_12_eTBV', values=~tV_12_eTBV)),
              text=~Group,
              marker = list(color = as.integer(df_TAH_data_impute_mean$Group), size=7, 
                            line=list(width=1, color = 'rgb(230,230,230)')
        )
    ) 
  # %>%
  #   layout(
  #       title= 'Random Data Pairs Plot', hovermode='closest', dragmode= 'select',
  #       plot_bgcolor='rgba(240,240,240, 0.95)',
  #       xaxis=list(domain=NULL, showline=F, zeroline=F, gridcolor='#ffff', ticklen=4),
  #       yaxis=list(domain=NULL, showline=F, zeroline=F, gridcolor='#ffff', ticklen=4),
  #       xaxis2=axis, xaxis3=axis, xaxis4=axis,yaxis2=axis, yaxis3=axis, yaxis4=axis)

# manually re-ran the Wilcoxon rank-sum test comparing Infusion_rate_hour_Pt_weight across TAH and CN:
# tah_Infusion_rate_hour_Pt_weight <- 
#   df_TAH_data_impute_mean[which(df_TAH_data_impute_mean$TAH_occurrence == 2), "Infusion_rate_hour_Pt_weight"]
# cn_Infusion_rate_hour_Pt_weight <- 
#   df_TAH_data_impute_mean[which(df_TAH_data_impute_mean$TAH_occurrence == 1), "Infusion_rate_hour_Pt_weight"]
# 
# summary(tah_Infusion_rate_hour_Pt_weight)  
# summary(cn_Infusion_rate_hour_Pt_weight)  
# # summary(tah_Infusion_rate_hour_Pt_weight)  
# #    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
# #   1.810   3.765   6.890  25.630  18.670 193.400 
# # summary(cn_Infusion_rate_hour_Pt_weight)  
# #    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
# #   0.040   3.865   5.270   8.719   7.862 120.480 
#   
# wilcox.test(tah_Infusion_rate_hour_Pt_weight, cn_Infusion_rate_hour_Pt_weight)

# =============================
# Use Chi-square test for categorical (factor variables)
# str(TAH_data): str(df_TAH_data_impute_mean_wo_TAH)
# dim(df_TAH_data_impute_mean_wo_TAH); dim(TAH_data)
# Sex                                    : Factor w/ 2 levels "1","2": 1 2 2 1 2 1 1 2 2 1 ...
# Race                                   : Factor w/ 6 levels "1","2","3","4",..: 5 5 5 5 3 1 1 1 2 1 ...
# Access                                 : Factor w/ 3 levels "1","2","Missing": 2 2 2 2 2 1 2 2 2 2 ...
tah1 <- subset(df_TAH_data_impute_mean, TAH_occurrence == 1, select = c("Sex", "Race", "Access"))
tah2 <- subset(df_TAH_data_impute_mean, TAH_occurrence == 2, select = c("Sex", "Race", "Access"))
prop.test(x = table(tah1$Sex), n=table(tah2$Sex), correct=TRUE)
## 
##  1-sample proportions test with continuity correction
## 
## data:  table(tah1$Sex), null probability 0.5
## X-squared = 2.8167, df = 1, p-value = 0.09329
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2635284 0.5180989
## sample estimates:
##         p 
## 0.3833333
prop.test(x = as.vector(table(tah2$Race)[-4]), n=as.vector(table(tah1$Race)[-4]), correct=TRUE)
## 
##  4-sample test for equality of proportions without continuity correction
## 
## data:  as.vector(table(tah2$Race)[-4]) out of as.vector(table(tah1$Race)[-4])
## X-squared = 4.0764, df = 3, p-value = 0.2533
## alternative hypothesis: two.sided
## sample estimates:
##    prop 1    prop 2    prop 3    prop 4 
## 0.6500000 0.6470588 0.2000000 0.5000000
prop.test(x = table(tah1$Access), n=table(tah2$Access), correct=TRUE)
## 
##  1-sample proportions test with continuity correction
## 
## data:  table(tah1$Access), null probability 0.5
## X-squared = 8.8167, df = 1, p-value = 0.002985
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1920041 0.4337324
## sample estimates:
##   p 
## 0.3

4.3 Interpretation of a simple logistic model

In general, we can have multiple predictor variables in a logistic regression model (to quantify the probability, \(p\), of a participant to be control or patient).

\[logit(p)= \log\left(\frac{p}{1-p}\right ) = \beta_o + \beta_1*x_1 + \cdots + \beta_k*x_k.\] Assume, we already calculated/estimated the coefficients (effect-sizes, \(\beta_i,\ i=1,2,\cdots, k\)). For simplicity, assume all other features, but \(x_1\), are fixed, so we have a single predictor (\(x_1\)).

\[logit(p) = \beta_o + \beta_1*x_1.\] ————-|————|———–|——-|———|———–|——— Outcome | Coef. | Std. Err.| z| P>|z|| [95% Conf. Interval] ————-|————|———–|——-|———|———–|——— \(x_1\) | .1563404 | .0256095 | 6.10 | 0.000 | .1061467 | .206534 intercept | -9.793942 | 1.481745 | -6.61 | 0.000 | -12.69811 | -6.889775 —————————————————————————— In this case, \(p = prob(TAH=1)\) the estimated coefficient for the intercept is the log odds of a patient with a \(x_1\)=0 being a control (\(TAH=1\)). In other words, the odds of being a control patient when \(x_1\)=0 is \(e^{-9.793942} = .00005579\). These odds are very low. So the intercept in this model corresponds to the log odds of when \(x_1\) is at a hypothetical value of zero – this is of course, not particularly interesting (in a statistical sense).

Let’s now interpret the value of the \(x_1\) coefficient \(\beta_1\). The coefficient and intercept estimates give us the following equation:

\[\log\left(\frac{p}{1-p}\right) = logit(p) = –9.793942 + 0.1563404* x_1.\] Let’s fix \(x_1\) at some value, e.g., \(x_1=54\). Then the conditional logit of a control class label (\(TAH=1\)) when \(x_1=54\) is

\[\log\left(\frac{p}{1-p}\right)( x_1 =54) = – 9.793942 + .1563404 *54.\]

Let’s examine the effect of a one-unit increase in \(x_1\). When \(x_1\) is held at 55, the conditional logit of the Control class ((\(TAH=1\))) is

\[\log\left(\frac{p}{1-p}\right)(x_1 =55) = – 9.793942 + .1563404*55.\]

Taking the difference of the two equations corresponding to \(x_1 =55\) and \(x_1 =55\), we get:

\[\underbrace{\underbrace{\log\left(\frac{p}{1-p}\right)(x_1=55)}\ –\ \underbrace{\log\left(\frac{p}{1-p}\right)(x_1= 54)}}_{LHS} = \underbrace{ 0.1563404\equiv \beta_1}_{RHS}.\]

Note that the coefficient for \(x_1\), \(\beta_1\), is just the difference in these two log odds. Thus, for a one-unit increase of \(x_1\), the expected change in log odds is \(0.1563404\).

To interpret the \(x_1\) coefficient (and determine the effect of \(x_1\) on diagnosis, TAH vs. control), we translate this change in log odds to a change in odds. Recall that the logarithm, \(y=\log(x)\), converts multiplication and division to addition and subtraction., and conversely, its inverse, the exponential function, \(x=e^y\), converts addition and subtraction back to multiplication and division.

Exponentiating both sides (\(LHS\) and \(RHS\)) of the last equation yields:

\[e^{\log\left(\frac{p}{1-p}\right)(x_1=55) – \log\left(\frac{p}{1-p}\right)(x_1 =54)}= \frac{e^{\log\left(\frac{p}{1-p}\right)(x_1=55)}}{e^{\log\left(\frac{p}{1-p}\right)(x_1=54)}}= \frac{odds(x_1=55)}{odds(x_1=54)} = e^{0.1563404} = 1.1692241\sim 1.0+0.17.\]

To summarize, a single-unit increase in \(x_1\) is expected to yield \(\sim 17\%\) increase in the odds of a participant being a control (\(TAH=1\)). This \(17\%\) increase is independent of the actual value of the variable \(x_1\).

5 One-Day Mortality Analysis

# Paired 1-Day Mortality-Group t-tests comparing patients vs. controls
df_TAH_data_impute_mean_2Way_Mortality <- df_TAH_data_impute_mean[!(df_TAH_data_impute_mean$Mortality1Day==3), ] # remove case with Mortality1Day==3
df_TAH_data_impute_mean_wo_Mortality <- subset(df_TAH_data_impute_mean_2Way_Mortality, select = -c(Mortality1Day))


####### Fix the numeric & categorical variable group-diff tests (Wilcoxon vs. Chi^2) #####
# tests_list <- lapply(colnames(df_TAH_data_impute_mean_wo_Mortality), 
#                      # function(x) t.test(as.formula(paste0(x, "~ Mortality1Day")), data = df_TAH_data_impute_mean_2Way_Mortality)) # Parametric t-test
#                      # Wilcoxon rank sum test with continuity correction
#                      function(x) wilcox.test(as.formula(paste0(x, "~ Mortality1Day")), data = df_TAH_data_impute_mean_2Way_Mortality)) # Non-parametric Wilcox-test
# 
# result <- do.call(rbind, lapply(tests_list, `[[`, "estimate"))
# pval <- sapply(tests_list, `[[`, "p.value")
# pval_adj <- p.adjust(pval, method = 'fdr')
# result <- cbind(result, Wilcoxon.p.value.fdr.adj = pval_adj, signif = ifelse(pval_adj<0.05, 1, 0))
# rownames(result) <- colnames(df_TAH_data_impute_mean_wo_Mortality)
# print("P-values Mortality1Day ~ . ")
# result

# colnames(df_TAH_data_impute_clean)
# colnames(TAH_data)
# df_TAH_data_impute_mean$Mortality1Day <- ifelse(df_TAH_data_impute_mean$Mortality1Day<0.5, "0", "1")
# rownames(df_TAH_data_impute_mean) <- df_TAH_data_impute_mean[ , 1]
# df_TAH_data_impute_mean <- df_TAH_data_impute_mean[ , -1]

# EDA
# library(tidyverse)
# df_TAH_data_Mortality0 <- filter(df_TAH_data_impute_mean, Mortality1Day==1)
# dim(df_TAH_data_Mortality0)   # [1] 87 41
# df_TAH_data_Mortality1 <- filter(df_TAH_data_impute_mean, Mortality1Day==2)
# dim(df_TAH_data_Mortality1)   # 7 41
# # note that some missing Mortality1Day values are estimated to be between 0 and 1!

tah1 <- subset(df_TAH_data_impute_mean, Mortality1Day == 1, select = c("Sex", "Race", "Access"))
tah2 <- subset(df_TAH_data_impute_mean, Mortality1Day != 1, select = c("Sex", "Race", "Access"))
prop.test(x = table(tah1$Sex), n=table(tah2$Sex), correct=TRUE)
## 
##  1-sample proportions test with continuity correction
## 
## data:  table(tah1$Sex), null probability 0.5
## X-squared = 1.1494, df = 1, p-value = 0.2837
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3320722 0.5471261
## sample estimates:
##         p 
## 0.4367816
prop.test(x = as.vector(table(tah2$Race)[-4]), n=as.vector(table(tah1$Race)[-4]), correct=TRUE)
## 
##  4-sample test for equality of proportions without continuity correction
## 
## data:  as.vector(table(tah2$Race)[-4]) out of as.vector(table(tah1$Race)[-4])
## X-squared = 2.632, df = 3, p-value = 0.4519
## alternative hypothesis: two.sided
## sample estimates:
##  prop 1  prop 2  prop 3  prop 4 
## 0.03125 0.12000 0.20000 0.12500
prop.test(x = table(tah1$Access), n=table(tah2$Access), correct=TRUE)
## 
##  1-sample proportions test with continuity correction
## 
## data:  table(tah1$Access), null probability 0.5
## X-squared = 14.897, df = 1, p-value = 0.0001136
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1978913 0.3958646
## sample estimates:
##         p 
## 0.2873563

5.1 Table 5

for (i in 1:length(colnames(df_TAH_data_impute_mean))){
  print (colnames(df_TAH_data_impute_mean)[i])
  ifelse (colnames(df_TAH_data_impute_mean)[i] %in% 
            c("Age_days",
              "Weight",
              "Pre_transfusion_K",
              "Cr_at_transfusion", 
              "Age_of_RBC_unit",
              "tV_12_weight_ml_Kg",
              "tV_12_eTBV", 
              "Infusion_rate_hour_Pt_weight",
              "Infusion_rate_hour_eTBV", 
              "Time_from_irradition_to_transfusion_min"), 
          df_TAH_data_impute_mean[,i] <- as.numeric(df_TAH_data_impute_mean[,i]), 
          df_TAH_data_impute_mean[,i] <- as.factor(df_TAH_data_impute_mean[,i])) 
}
## [1] "Group"
## [1] "TAH_occurrence"
## [1] "Mortality1Day"
## [1] "Sex"
## [1] "Race"
## [1] "Access"
## [1] "Age_days"
## [1] "Weight"
## [1] "Pre_transfusion_K"
## [1] "Cr_at_transfusion"
## [1] "Cardiac_dysf"
## [1] "Respiratory_dysf"
## [1] "Kidney_dysf"
## [1] "Liver_dysf"
## [1] "Intracranial_diso"
## [1] "Orthopedics"
## [1] "Anemia"
## [1] "Hemoglobinopathy"
## [1] "Sepsis"
## [1] "ECMO"
## [1] "CPB"
## [1] "Prematurity"
## [1] "Dialysis"
## [1] "RBC_Unit_type"
## [1] "Age_of_RBC_unit"
## [1] "Leukoreduction"
## [1] "Irradiation"
## [1] "Washed"
## [1] "Plasma_reduction"
## [1] "tV_12_weight_ml_Kg"
## [1] "tV_12_eTBV"
## [1] "Infusion_rate_hour_Pt_weight"
## [1] "Infusion_rate_hour_eTBV"
## [1] "Time_from_irradition_to_transfusion_min"
indFactor <- sapply(df_TAH_data_impute_mean, is.factor)
table(indFactor)
## indFactor
## FALSE  TRUE 
##    10    24
# Contingency Table - Mortality1Day vs. Kidney-dysfunction, e.g., 
# table(df_TAH_data_impute_mean$Mortality1Day, df_TAH_data_impute_mean$Kidney_dysf)

contTable <- list()
for (var in c(2:length(factorVarNames))) {
  print(paste0("Mortality1Day vs ", factorVarNames[var]))
  contTable[[var-1]] <- table(df_TAH_data_impute_mean$Mortality1Day,
        df_TAH_data_impute_mean[[factorVarNames[var]]],
        dnn = list("Mortality1Day", factorVarNames[var]))
}
## [1] "Mortality1Day vs Group"
## [1] "Mortality1Day vs TAH_occurrence"
## [1] "Mortality1Day vs Mortality1Day"
## [1] "Mortality1Day vs Sex"
## [1] "Mortality1Day vs Race"
## [1] "Mortality1Day vs Access"
## [1] "Mortality1Day vs Dialysis"
## [1] "Mortality1Day vs Cardiac_dysf"
## [1] "Mortality1Day vs Respiratory_dysf"
## [1] "Mortality1Day vs Kidney_dysf"
## [1] "Mortality1Day vs Liver_dysf"
## [1] "Mortality1Day vs Intracranial_diso"
## [1] "Mortality1Day vs Orthopedics"
## [1] "Mortality1Day vs Anemia"
## [1] "Mortality1Day vs Hemoglobinopathy"
## [1] "Mortality1Day vs Sepsis"
## [1] "Mortality1Day vs ECMO"
## [1] "Mortality1Day vs CPB"
## [1] "Mortality1Day vs Prematurity"
## [1] "Mortality1Day vs RBC_Unit_type"
## [1] "Mortality1Day vs Leukoreduction"
## [1] "Mortality1Day vs Irradiation"
## [1] "Mortality1Day vs Washed"
## [1] "Mortality1Day vs Plasma_reduction"
# addmargins(contTable[[10]])  # "Kidney_dysf"
# prop.table(contTable[[10]])   # "Kidney_dysf"
# chisq.test(contTable[[10]])   # "Kidney_dysf"
# fisher.test(contTable[[10]])

for (var in c(2:length(factorVarNames))) {
  print(addmargins(contTable[[var-1]]))   
  print(prop.table(contTable[[var-1]]))   
  print(chisq.test(contTable[[var-1]]))
  ### Adjust p-values for multiple comparison
  factorPvalueResults_adj <- p.adjust(chisq.test(contTable[[var-1]])$p.value, 
                                      method = 'fdr')
  print(paste0("Adjusted p-value: ", factorPvalueResults_adj))
}
##              Group
## Mortality1Day  1  2  3  4  5 Sum
##           1   19 16 21 13 18  87
##           2    2  1  3  0  1   7
##           3    1  0  0  0  0   1
##           Sum 22 17 24 13 19  95
##              Group
## Mortality1Day          1          2          3          4          5
##             1 0.20000000 0.16842105 0.22105263 0.13684211 0.18947368
##             2 0.02105263 0.01052632 0.03157895 0.00000000 0.01052632
##             3 0.01052632 0.00000000 0.00000000 0.00000000 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 5.6299, df = 8, p-value = 0.6886
## 
## [1] "Adjusted p-value: 0.688613141982977"
##              TAH_occurrence
## Mortality1Day  1  2 Sum
##           1   59 28  87
##           2    0  7   7
##           3    1  0   1
##           Sum 60 35  95
##              TAH_occurrence
## Mortality1Day          1          2
##             1 0.62105263 0.29473684
##             2 0.00000000 0.07368421
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 13.395, df = 2, p-value = 0.001234
## 
## [1] "Adjusted p-value: 0.00123421762995026"
##              Mortality1Day
## Mortality1Day  1  2  3 Sum
##           1   87  0  0  87
##           2    0  7  0   7
##           3    0  0  1   1
##           Sum 87  7  1  95
##              Mortality1Day
## Mortality1Day          1          2          3
##             1 0.91578947 0.00000000 0.00000000
##             2 0.00000000 0.07368421 0.00000000
##             3 0.00000000 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 190, df = 4, p-value < 2.2e-16
## 
## [1] "Adjusted p-value: 5.30023898594739e-40"
##              Sex
## Mortality1Day  1  2 Sum
##           1   38 49  87
##           2    5  2   7
##           3    0  1   1
##           Sum 43 52  95
##              Sex
## Mortality1Day          1          2
##             1 0.40000000 0.51578947
##             2 0.05263158 0.02105263
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 2.8495, df = 2, p-value = 0.2406
## 
## [1] "Adjusted p-value: 0.24057323869112"
##              Race
## Mortality1Day  1  2  3  4  5 Sum
##           1   32 25  5  1 24  87
##           2    1  3  0  0  3   7
##           3    0  0  1  0  0   1
##           Sum 33 28  6  1 27  95
##              Race
## Mortality1Day          1          2          3          4          5
##             1 0.33684211 0.26315789 0.05263158 0.01052632 0.25263158
##             2 0.01052632 0.03157895 0.00000000 0.00000000 0.03157895
##             3 0.00000000 0.00000000 0.01052632 0.00000000 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 17.325, df = 8, p-value = 0.0269
## 
## [1] "Adjusted p-value: 0.0268967038251054"
##              Access
## Mortality1Day  1  2 Sum
##           1   25 62  87
##           2    1  6   7
##           3    0  1   1
##           Sum 26 69  95
##              Access
## Mortality1Day          1          2
##             1 0.26315789 0.65263158
##             2 0.01052632 0.06315789
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 1.0613, df = 2, p-value = 0.5882
## 
## [1] "Adjusted p-value: 0.58820879061329"
##              Dialysis
## Mortality1Day  1  2 Sum
##           1   82  5  87
##           2    6  1   7
##           3    1  0   1
##           Sum 89  6  95
##              Dialysis
## Mortality1Day          1          2
##             1 0.86315789 0.05263158
##             2 0.06315789 0.01052632
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.86644, df = 2, p-value = 0.6484
## 
## [1] "Adjusted p-value: 0.648419306274419"
##              Cardiac_dysf
## Mortality1Day  1  2 Sum
##           1   68 19  87
##           2    6  1   7
##           3    0  1   1
##           Sum 74 21  95
##              Cardiac_dysf
## Mortality1Day          1          2
##             1 0.71578947 0.20000000
##             2 0.06315789 0.01052632
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 3.776, df = 2, p-value = 0.1514
## 
## [1] "Adjusted p-value: 0.151376936861258"
##              Respiratory_dysf
## Mortality1Day  1  2 Sum
##           1   57 30  87
##           2    3  4   7
##           3    0  1   1
##           Sum 60 35  95
##              Respiratory_dysf
## Mortality1Day          1          2
##             1 0.60000000 0.31578947
##             2 0.03157895 0.04210526
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 3.1622, df = 2, p-value = 0.2057
## 
## [1] "Adjusted p-value: 0.205747651107535"
##              Kidney_dysf
## Mortality1Day  1  2 Sum
##           1   67 20  87
##           2    3  4   7
##           3    1  0   1
##           Sum 71 24  95
##              Kidney_dysf
## Mortality1Day          1          2
##             1 0.70526316 0.21052632
##             2 0.03157895 0.04210526
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 4.3444, df = 2, p-value = 0.1139
## 
## [1] "Adjusted p-value: 0.113927815387277"
##              Liver_dysf
## Mortality1Day  1  2 Sum
##           1   77 10  87
##           2    4  3   7
##           3    1  0   1
##           Sum 82 13  95
##              Liver_dysf
## Mortality1Day          1          2
##             1 0.81052632 0.10526316
##             2 0.04210526 0.03157895
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 5.5555, df = 2, p-value = 0.06218
## 
## [1] "Adjusted p-value: 0.0621790780732849"
##              Intracranial_diso
## Mortality1Day  1  2 Sum
##           1   80  7  87
##           2    4  3   7
##           3    0  1   1
##           Sum 84 11  95
##              Intracranial_diso
## Mortality1Day          1          2
##             1 0.84210526 0.07368421
##             2 0.04210526 0.03157895
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 15.386, df = 2, p-value = 0.000456
## 
## [1] "Adjusted p-value: 0.000456019591037674"
##              Orthopedics
## Mortality1Day  1  2 Sum
##           1   83  4  87
##           2    7  0   7
##           3    1  0   1
##           Sum 91  4  95
##              Orthopedics
## Mortality1Day          1          2
##             1 0.87368421 0.04210526
##             2 0.07368421 0.00000000
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.38398, df = 2, p-value = 0.8253
## 
## [1] "Adjusted p-value: 0.82531354019221"
##              Anemia
## Mortality1Day  1  2 Sum
##           1   42 45  87
##           2    5  2   7
##           3    0  1   1
##           Sum 47 48  95
##              Anemia
## Mortality1Day          1          2
##             1 0.44210526 0.47368421
##             2 0.05263158 0.02105263
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 2.3789, df = 2, p-value = 0.3044
## 
## [1] "Adjusted p-value: 0.304388656774702"
##              Hemoglobinopathy
## Mortality1Day  1  2 Sum
##           1   78  9  87
##           2    7  0   7
##           3    1  0   1
##           Sum 86  9  95
##              Hemoglobinopathy
## Mortality1Day          1          2
##             1 0.82105263 0.09473684
##             2 0.07368421 0.00000000
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.91419, df = 2, p-value = 0.6331
## 
## [1] "Adjusted p-value: 0.633118903732215"
##              Sepsis
## Mortality1Day  1  2 Sum
##           1   81  6  87
##           2    5  2   7
##           3    1  0   1
##           Sum 87  8  95
##              Sepsis
## Mortality1Day          1          2
##             1 0.85263158 0.06315789
##             2 0.05263158 0.02105263
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 4.0397, df = 2, p-value = 0.1327
## 
## [1] "Adjusted p-value: 0.132675897142401"
##              ECMO
## Mortality1Day  1  2 Sum
##           1   78  9  87
##           2    6  1   7
##           3    1  0   1
##           Sum 85 10  95
##              ECMO
## Mortality1Day          1          2
##             1 0.82105263 0.09473684
##             2 0.06315789 0.01052632
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.22573, df = 2, p-value = 0.8933
## 
## [1] "Adjusted p-value: 0.893270496829204"
##              CPB
## Mortality1Day  1  2 Sum
##           1   83  4  87
##           2    7  0   7
##           3    1  0   1
##           Sum 91  4  95
##              CPB
## Mortality1Day          1          2
##             1 0.87368421 0.04210526
##             2 0.07368421 0.00000000
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.38398, df = 2, p-value = 0.8253
## 
## [1] "Adjusted p-value: 0.82531354019221"
##              Prematurity
## Mortality1Day  1  2 Sum
##           1   67 20  87
##           2    4  3   7
##           3    0  1   1
##           Sum 71 24  95
##              Prematurity
## Mortality1Day          1          2
##             1 0.70526316 0.21052632
##             2 0.04210526 0.03157895
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 4.3444, df = 2, p-value = 0.1139
## 
## [1] "Adjusted p-value: 0.113927815387277"
##              RBC_Unit_type
## Mortality1Day  1  2  3 Sum
##           1   26 58  3  87
##           2    3  4  0   7
##           3    0  1  0   1
##           Sum 29 63  3  95
##              RBC_Unit_type
## Mortality1Day          1          2          3
##             1 0.27368421 0.61052632 0.03157895
##             2 0.03157895 0.04210526 0.00000000
##             3 0.00000000 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 1.203, df = 4, p-value = 0.8776
## 
## [1] "Adjusted p-value: 0.877598446034101"
##              Leukoreduction
## Mortality1Day  1  2 Sum
##           1    3 84  87
##           2    0  7   7
##           3    0  1   1
##           Sum  3 92  95
##              Leukoreduction
## Mortality1Day          1          2
##             1 0.03157895 0.88421053
##             2 0.00000000 0.07368421
##             3 0.00000000 0.01052632
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.28486, df = 2, p-value = 0.8672
## 
## [1] "Adjusted p-value: 0.867249312726399"
##              Irradiation
## Mortality1Day  1  2 Sum
##           1   26 61  87
##           2    2  5   7
##           3    1  0   1
##           Sum 29 66  95
##              Irradiation
## Mortality1Day          1          2
##             1 0.27368421 0.64210526
##             2 0.02105263 0.05263158
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 2.3053, df = 2, p-value = 0.3158
## 
## [1] "Adjusted p-value: 0.315791696970328"
##              Washed
## Mortality1Day  1  2 Sum
##           1   85  2  87
##           2    7  0   7
##           3    1  0   1
##           Sum 93  2  95
##              Washed
## Mortality1Day          1          2
##             1 0.89473684 0.02105263
##             2 0.07368421 0.00000000
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.18786, df = 2, p-value = 0.9103
## 
## [1] "Adjusted p-value: 0.910345092473811"
##              Plasma_reduction
## Mortality1Day  1  2 Sum
##           1   86  1  87
##           2    7  0   7
##           3    1  0   1
##           Sum 94  1  95
##              Plasma_reduction
## Mortality1Day          1          2
##             1 0.90526316 0.01052632
##             2 0.07368421 0.00000000
##             3 0.01052632 0.00000000
## 
##  Pearson's Chi-squared test
## 
## data:  contTable[[var - 1]]
## X-squared = 0.092932, df = 2, p-value = 0.9546
## 
## [1] "Adjusted p-value: 0.954596893519514"

5.1.1 Quantitative numerical variables (Wilcoxon test)

# For Wilcoxon test, binarize Mortality1Day ....
df_TAH_data_impute_mean[ which(df_TAH_data_impute_mean$Mortality1Day==3), ] <- 2

############################################################
# If need to adjust numeric and factor p-values separately #
############################################################
df_TAH_data_impute_mean_numeric <- df_TAH_data_impute_mean[, !indFactor]
tests_list <- lapply(colnames(df_TAH_data_impute_mean_numeric),
                     function(x) wilcox.test(
                       as.formula(paste0(x, "~ Mortality1Day")), 
                       data = cbind(df_TAH_data_impute_mean_numeric,
                       Mortality1Day=df_TAH_data_impute_mean$Mortality1Day)))

numericPvalueResults <- sapply(tests_list, `[[`, "p.value")
numericPvalueResults_adj <- p.adjust(numericPvalueResults, method = 'fdr')
result <- cbind(QuantVariables=colnames(df_TAH_data_impute_mean[!indFactor]),
                numeric_Mortality1Day_Pvalues=as.numeric(numericPvalueResults),
                numeric_Mortality1Day_Pvalues_adj=
                  as.numeric(numericPvalueResults_adj))
result
##       QuantVariables                            numeric_Mortality1Day_Pvalues
##  [1,] "Age_days"                                "0.151553445361102"          
##  [2,] "Weight"                                  "0.054461343885384"          
##  [3,] "Pre_transfusion_K"                       "0.706953701787112"          
##  [4,] "Cr_at_transfusion"                       "0.103067633535562"          
##  [5,] "Age_of_RBC_unit"                         "0.295116461303598"          
##  [6,] "tV_12_weight_ml_Kg"                      "0.0314689872073928"         
##  [7,] "tV_12_eTBV"                              "0.00324443217529795"        
##  [8,] "Infusion_rate_hour_Pt_weight"            "0.498518170274654"          
##  [9,] "Infusion_rate_hour_eTBV"                 "0.590997387053384"          
## [10,] "Time_from_irradition_to_transfusion_min" "0.114192523260935"          
##       numeric_Mortality1Day_Pvalues_adj
##  [1,] "0.252589075601837"              
##  [2,] "0.18153781295128"               
##  [3,] "0.706953701787112"              
##  [4,] "0.228385046521869"              
##  [5,] "0.421594944719426"              
##  [6,] "0.157344936036964"              
##  [7,] "0.0324443217529795"             
##  [8,] "0.623147712843317"              
##  [9,] "0.656663763392648"              
## [10,] "0.228385046521869"

6 Dimensionality Reduction

6.1 PCA

df_TAH_data_impute_mean <- as.data.frame(sapply(df_TAH_data_impute_mean, as.numeric)) 

pca1 <- prcomp(as.matrix(df_TAH_data_impute_mean), center = T)
summary(pca1)
## Importance of components:
##                              PC1       PC2      PC3      PC4 PC5   PC6   PC7
## Standard deviation     3546.3724 1998.4663 50.01536 15.45642 8.9 5.157 1.628
## Proportion of Variance    0.7589    0.2410  0.00015  0.00001 0.0 0.000 0.000
## Cumulative Proportion     0.7589    0.9998  0.99998  0.99999 1.0 1.000 1.000
##                          PC8    PC9   PC10  PC11   PC12   PC13   PC14   PC15
## Standard deviation     1.008 0.8314 0.5916 0.564 0.5108 0.4832 0.4624 0.4464
## Proportion of Variance 0.000 0.0000 0.0000 0.000 0.0000 0.0000 0.0000 0.0000
## Cumulative Proportion  1.000 1.0000 1.0000 1.000 1.0000 1.0000 1.0000 1.0000
##                          PC16   PC17   PC18   PC19  PC20   PC21   PC22   PC23
## Standard deviation     0.4185 0.3865 0.3564 0.3232 0.302 0.2817 0.2749 0.2397
## Proportion of Variance 0.0000 0.0000 0.0000 0.0000 0.000 0.0000 0.0000 0.0000
## Cumulative Proportion  1.0000 1.0000 1.0000 1.0000 1.000 1.0000 1.0000 1.0000
##                          PC24   PC25   PC26   PC27   PC28   PC29   PC30   PC31
## Standard deviation     0.2312 0.2003 0.1953 0.1807 0.1628 0.1494 0.1394 0.1182
## Proportion of Variance 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Cumulative Proportion  1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
##                           PC32    PC33   PC34
## Standard deviation     0.09406 0.07904 0.0347
## Proportion of Variance 0.00000 0.00000 0.0000
## Cumulative Proportion  1.00000 1.00000 1.0000
library(plotly)
plot_ly(x = c(1:length(pca1$sdev)), y = pca1$sdev*pca1$sdev, name = "Scree", type = "bar") %>%
  layout(title="Scree Plot", xaxis = list(title="PC's"),  yaxis = list(title="Variances (SD^2)"))
scores <- pca1$x

# Loadings
loadings <- pca1$rotation

# Visualization scale factor for loadings
scaleLoad <- 10

# p <- plot_ly() %>%
#   add_trace(x=scores[,1], y=scores[,2], z=scores[,3], type="scatter3d", mode="markers", name="",
#             marker = list(color=scores[,2], colorscale = c("#FFE1A1", "#683531"), opacity = 0.7)) 
# for (k in 1:ncol(loadings)) {
#    x <- c(0, loadings[1, k])*scaleLoad  # Project PCAs only on the last 3 original data dimensions (6,5,4)
#    y <- c(0, loadings[2, k])*scaleLoad
#    z <- c(0, loadings[3, k])*scaleLoad
#    p <- p %>% add_trace(x=x, y=y, z=z, type="scatter3d", mode="lines", 
#   name=paste0("Loading PC ", k, " ", colnames(df_TAH_data_impute_mean)[k]), line=list(width=8), opacity=1) 
#   # %>%
#   # add_annotations( x = 0, y = 0, z = 0,
#   #           xref = "x", yref = "y",  zref = "z",
#   #           # axref = "x", ayref = "y", azref = "z",
#   #           text = "", showarrow = T,
#   #           ax = c(0, loadings[k,1])*scaleLoad, ay = c(0, loadings[k,2])*scaleLoad, az = c(0,
#   #                  loadings[k,3])*scaleLoad)
# }
# 
# p <- p %>%
#   layout(legend = list(orientation = 'h'), title="3D Projection of 6D Data along First 3 PCs",
#          scene = list ( xaxis = list(title = rownames(loadings)[1]),
#                         yaxis = list(title = rownames(loadings)[2]),
#                         zaxis = list(title = rownames(loadings)[3]))) 
# p

loadings
##                                                   PC1           PC2
## Group                                    1.432597e-04 -6.051592e-04
## TAH_occurrence                          -6.115045e-06  2.424250e-05
## Mortality1Day                           -6.643445e-06  1.401652e-05
## Sex                                     -4.606691e-08  2.593938e-06
## Race                                     1.409822e-05  8.628286e-06
## Access                                   5.000452e-06  1.730294e-05
## Age_days                                 1.947683e-01 -9.807995e-01
## Weight                                   1.665779e-03 -8.342779e-03
## Pre_transfusion_K                       -9.876751e-06  4.746697e-05
## Cr_at_transfusion                        1.644493e-06 -3.418279e-05
## Cardiac_dysf                            -1.093803e-05  3.643566e-05
## Respiratory_dysf                        -2.657478e-05  9.535280e-05
## Kidney_dysf                             -9.955980e-06  2.440058e-05
## Liver_dysf                              -1.146675e-05  1.429035e-05
## Intracranial_diso                       -9.649700e-06  1.498090e-05
## Orthopedics                              1.669145e-06 -1.815357e-05
## Anemia                                   1.949051e-05 -8.737288e-05
## Hemoglobinopathy                        -3.573062e-06 -4.125291e-05
## Sepsis                                   1.343524e-06  3.342350e-05
## ECMO                                    -9.302558e-06  1.740889e-05
## CPB                                     -4.710171e-06  2.422605e-06
## Prematurity                             -3.164081e-05  8.911268e-05
## Dialysis                                 5.017988e-06  8.046405e-06
## RBC_Unit_type                            2.146804e-06 -5.167423e-05
## Age_of_RBC_unit                          4.907380e-04 -1.170085e-03
## Leukoreduction                          -9.141377e-06 -1.111745e-05
## Irradiation                              2.715703e-05  4.224997e-05
## Washed                                   1.355439e-05  1.270107e-05
## Plasma_reduction                        -2.713212e-06  7.715669e-06
## tV_12_weight_ml_Kg                      -1.741111e-03  3.653784e-03
## tV_12_eTBV                              -2.490642e-05  5.137836e-05
## Infusion_rate_hour_Pt_weight            -9.977001e-04  2.671995e-03
## Infusion_rate_hour_eTBV                 -1.438915e-05  3.935351e-05
## Time_from_irradition_to_transfusion_min  9.808457e-01  1.947832e-01
##                                                   PC3           PC4
## Group                                   -7.542679e-04 -1.693229e-03
## TAH_occurrence                          -3.233289e-03  6.932950e-03
## Mortality1Day                           -1.231427e-03  2.588660e-03
## Sex                                      2.136534e-03 -2.747610e-04
## Race                                    -6.324362e-03 -2.913385e-05
## Access                                   1.659270e-04  8.342737e-04
## Age_days                                -4.889595e-03  2.736328e-04
## Weight                                   6.680159e-03 -1.540786e-02
## Pre_transfusion_K                        2.327459e-03  4.544406e-03
## Cr_at_transfusion                        5.871514e-04  6.498611e-04
## Cardiac_dysf                            -2.773133e-03 -9.496110e-06
## Respiratory_dysf                         5.628565e-04  7.922445e-04
## Kidney_dysf                              5.332355e-05  2.052319e-03
## Liver_dysf                              -8.687839e-04  3.603438e-03
## Intracranial_diso                        2.494954e-04  3.124555e-03
## Orthopedics                              7.287055e-05 -1.007711e-03
## Anemia                                   4.958779e-04  1.129606e-03
## Hemoglobinopathy                         6.048181e-04 -6.363681e-04
## Sepsis                                   4.470673e-04  2.860719e-03
## ECMO                                    -2.609078e-03  5.934652e-04
## CPB                                     -3.727258e-04 -1.320809e-03
## Prematurity                              1.372234e-03 -1.163683e-03
## Dialysis                                 5.644165e-04 -5.679688e-04
## RBC_Unit_type                            1.925665e-03 -5.734879e-03
## Age_of_RBC_unit                          4.305812e-03 -3.084218e-02
## Leukoreduction                          -2.128141e-04  1.938091e-04
## Irradiation                             -3.397669e-04 -4.479050e-03
## Washed                                   2.646263e-04 -3.933427e-04
## Plasma_reduction                         2.682400e-04 -2.944859e-04
## tV_12_weight_ml_Kg                      -7.995780e-01  5.996622e-01
## tV_12_eTBV                              -1.178709e-02  9.185166e-03
## Infusion_rate_hour_Pt_weight            -6.002411e-01 -7.992880e-01
## Infusion_rate_hour_eTBV                 -8.530322e-03 -9.791716e-03
## Time_from_irradition_to_transfusion_min -1.072706e-03  2.393419e-04
##                                                   PC5           PC6
## Group                                   -0.0134148862  0.0063909761
## TAH_occurrence                           0.0121567814 -0.0148851748
## Mortality1Day                            0.0022579561  0.0074436901
## Sex                                      0.0001377604  0.0046541401
## Race                                    -0.0103148613 -0.0197798364
## Access                                  -0.0018547446 -0.0210376188
## Age_days                                 0.0029852358  0.0080068021
## Weight                                  -0.2104778150 -0.9754942889
## Pre_transfusion_K                        0.0093767956 -0.0203448516
## Cr_at_transfusion                        0.0012817387 -0.0330326565
## Cardiac_dysf                             0.0050709619 -0.0004190476
## Respiratory_dysf                         0.0037975669  0.0115724934
## Kidney_dysf                              0.0052335901 -0.0246848517
## Liver_dysf                              -0.0023513075 -0.0015183787
## Intracranial_diso                        0.0012171943  0.0061996660
## Orthopedics                              0.0042395083  0.0069309119
## Anemia                                  -0.0072636545 -0.0078626890
## Hemoglobinopathy                        -0.0050915045  0.0191308289
## Sepsis                                   0.0032357682 -0.0039948890
## ECMO                                     0.0040199506 -0.0059614887
## CPB                                      0.0037645733 -0.0006361846
## Prematurity                              0.0069566854  0.0057695693
## Dialysis                                -0.0036174500 -0.0020440719
## RBC_Unit_type                            0.0124969866 -0.0019131657
## Age_of_RBC_unit                         -0.9764654274  0.2102471575
## Leukoreduction                           0.0056752107 -0.0025077354
## Irradiation                              0.0067677066  0.0017646801
## Washed                                  -0.0031094510  0.0016505892
## Plasma_reduction                         0.0016759871 -0.0001569927
## tV_12_weight_ml_Kg                      -0.0245457730 -0.0093568863
## tV_12_eTBV                               0.0008480285 -0.0007711355
## Infusion_rate_hour_Pt_weight             0.0233790771  0.0032968523
## Infusion_rate_hour_eTBV                  0.0017855441 -0.0005586598
## Time_from_irradition_to_transfusion_min  0.0002362727 -0.0000520760
##                                                   PC7           PC8
## Group                                    1.866208e-03 -1.356795e-01
## TAH_occurrence                           4.610002e-02  1.583997e-01
## Mortality1Day                           -5.286926e-03  5.764553e-02
## Sex                                     -1.480451e-02  6.877814e-02
## Race                                    -9.786705e-01  1.718002e-01
## Access                                  -2.950752e-02  9.727948e-02
## Age_days                                -1.141410e-04  4.660049e-04
## Weight                                   1.370760e-02 -4.779933e-02
## Pre_transfusion_K                        1.725560e-02  3.772608e-01
## Cr_at_transfusion                        1.736937e-01  7.977324e-01
## Cardiac_dysf                            -3.300141e-02 -5.120213e-02
## Respiratory_dysf                        -3.777088e-02 -7.351877e-02
## Kidney_dysf                              4.708253e-02  2.617228e-01
## Liver_dysf                               1.478778e-02  1.268537e-01
## Intracranial_diso                       -1.463809e-02  2.666229e-02
## Orthopedics                              8.444576e-03 -1.600929e-02
## Anemia                                  -8.582766e-03  7.531518e-02
## Hemoglobinopathy                         1.686616e-02 -1.664745e-02
## Sepsis                                   7.028408e-03  5.177050e-03
## ECMO                                    -1.957606e-02  4.578194e-03
## CPB                                      1.649552e-02 -1.311198e-02
## Prematurity                             -2.510848e-02  5.294188e-02
## Dialysis                                 2.672747e-02  1.456317e-01
## RBC_Unit_type                            1.721146e-02  4.759557e-02
## Age_of_RBC_unit                          8.092024e-03  1.760391e-02
## Leukoreduction                           9.345659e-04  9.094863e-03
## Irradiation                             -6.104120e-03  6.419218e-03
## Washed                                   1.104185e-02  3.956374e-02
## Plasma_reduction                        -9.000377e-03  8.120739e-03
## tV_12_weight_ml_Kg                       5.068080e-03 -2.950959e-03
## tV_12_eTBV                               3.033042e-03  7.945133e-03
## Infusion_rate_hour_Pt_weight             3.826434e-03  3.501348e-03
## Infusion_rate_hour_eTBV                  2.377230e-03  1.735590e-02
## Time_from_irradition_to_transfusion_min  2.064839e-05 -1.673871e-07
##                                                   PC9          PC10
## Group                                    2.988287e-01 -0.3486149709
## TAH_occurrence                          -4.968640e-02 -0.0397305971
## Mortality1Day                            2.293215e-02 -0.0115747814
## Sex                                      1.234783e-01  0.3953575730
## Race                                     5.217495e-02 -0.0292182783
## Access                                   2.584062e-02 -0.0439566937
## Age_days                                -2.508970e-04  0.0002226953
## Weight                                   2.833601e-03  0.0106484922
## Pre_transfusion_K                       -7.973041e-01 -0.0761514208
## Cr_at_transfusion                        3.788188e-01  0.1011863360
## Cardiac_dysf                             1.127680e-01  0.0289267366
## Respiratory_dysf                         6.966383e-02  0.3601280281
## Kidney_dysf                              2.515517e-02 -0.1272820327
## Liver_dysf                               3.773003e-02 -0.1530685880
## Intracranial_diso                       -3.027407e-02  0.2284137793
## Orthopedics                              7.945417e-02 -0.0282608818
## Anemia                                   3.077025e-02 -0.2193213839
## Hemoglobinopathy                         3.834029e-02 -0.0553292470
## Sepsis                                   4.114433e-02  0.0986513155
## ECMO                                     6.245546e-02  0.0062762967
## CPB                                      6.239334e-02  0.0333941149
## Prematurity                             -5.845956e-02  0.2060736870
## Dialysis                                 1.404432e-01 -0.0227282445
## RBC_Unit_type                            3.182812e-02 -0.5590682177
## Age_of_RBC_unit                         -1.180102e-02 -0.0014725409
## Leukoreduction                          -4.399758e-03  0.0362318509
## Irradiation                              4.470433e-02 -0.2378600928
## Washed                                   8.843792e-02  0.0249278771
## Plasma_reduction                         6.572556e-02 -0.0133511153
## tV_12_weight_ml_Kg                      -1.343343e-03 -0.0011745607
## tV_12_eTBV                               1.334402e-01 -0.0379727408
## Infusion_rate_hour_Pt_weight            -6.171643e-03  0.0040350737
## Infusion_rate_hour_eTBV                  1.216809e-01 -0.0252512077
## Time_from_irradition_to_transfusion_min -7.136745e-06  0.0000174985
##                                                  PC11          PC12
## Group                                    3.834541e-01 -1.708349e-01
## TAH_occurrence                           4.071590e-01 -1.722310e-01
## Mortality1Day                            1.576901e-01 -2.097304e-01
## Sex                                     -3.390846e-01 -2.766613e-01
## Race                                     2.278818e-02  3.207724e-02
## Access                                  -2.779409e-02  6.143130e-02
## Age_days                                -1.270143e-04  1.530540e-04
## Weight                                  -4.718912e-03 -9.104923e-03
## Pre_transfusion_K                        9.008646e-02 -9.209415e-02
## Cr_at_transfusion                       -5.128065e-02  2.651143e-01
## Cardiac_dysf                             1.542152e-01 -4.998878e-02
## Respiratory_dysf                         9.115118e-03 -5.125172e-02
## Kidney_dysf                              2.101655e-01 -2.195958e-01
## Liver_dysf                               3.617788e-02 -2.737949e-01
## Intracranial_diso                        1.885140e-01 -2.977424e-01
## Orthopedics                              3.999647e-02 -6.198811e-02
## Anemia                                  -5.344410e-01 -3.890683e-01
## Hemoglobinopathy                        -4.836307e-02 -1.973784e-01
## Sepsis                                   1.739089e-01 -2.316150e-01
## ECMO                                     8.263990e-02  9.990517e-02
## CPB                                      2.455889e-02 -9.524986e-02
## Prematurity                             -8.785861e-02 -3.325512e-01
## Dialysis                                 4.321171e-02 -4.387790e-02
## RBC_Unit_type                           -2.956266e-01 -9.230558e-02
## Age_of_RBC_unit                          5.108446e-03 -5.503323e-04
## Leukoreduction                           1.580600e-02  2.447699e-02
## Irradiation                              1.311380e-02  1.777752e-01
## Washed                                   3.506532e-02 -4.801908e-02
## Plasma_reduction                        -1.457324e-03 -1.245296e-01
## tV_12_weight_ml_Kg                      -7.523439e-03  4.897431e-03
## tV_12_eTBV                               5.783228e-02 -1.999638e-01
## Infusion_rate_hour_Pt_weight             1.751349e-03 -1.542832e-03
## Infusion_rate_hour_eTBV                  3.303495e-02 -2.051101e-01
## Time_from_irradition_to_transfusion_min -1.624492e-05 -1.237418e-05
##                                                  PC13          PC14
## Group                                    5.885081e-01  3.958187e-02
## TAH_occurrence                          -9.924832e-02  1.443046e-01
## Mortality1Day                           -1.291629e-01  1.121386e-01
## Sex                                      3.446449e-01 -1.510368e-01
## Race                                     3.726932e-02  8.481475e-03
## Access                                  -3.575298e-01 -1.191282e-02
## Age_days                                -4.110281e-04 -3.830111e-05
## Weight                                   2.067560e-03  4.549811e-03
## Pre_transfusion_K                        1.640760e-01 -1.253072e-01
## Cr_at_transfusion                        1.018058e-01  1.758736e-02
## Cardiac_dysf                            -1.498415e-01 -5.929982e-01
## Respiratory_dysf                        -1.671909e-01  5.021894e-02
## Kidney_dysf                             -4.365490e-02 -7.220431e-02
## Liver_dysf                              -1.127020e-01 -2.746009e-02
## Intracranial_diso                       -8.189081e-02  1.197524e-01
## Orthopedics                             -1.086715e-01 -1.546030e-05
## Anemia                                   4.662927e-02  1.809600e-01
## Hemoglobinopathy                         4.002106e-02 -6.470718e-02
## Sepsis                                  -4.145292e-02  3.737120e-02
## ECMO                                    -2.944304e-01 -2.577192e-01
## CPB                                     -4.560057e-02 -1.140027e-01
## Prematurity                             -1.636901e-01  2.167988e-01
## Dialysis                                -3.392812e-02 -3.797747e-02
## RBC_Unit_type                           -1.849737e-01 -2.671566e-01
## Age_of_RBC_unit                         -1.729586e-02 -4.001950e-03
## Leukoreduction                          -2.699395e-05  2.952279e-02
## Irradiation                             -2.024508e-01  5.583175e-01
## Washed                                  -5.649996e-02  1.336594e-02
## Plasma_reduction                        -8.790749e-02 -1.717355e-02
## tV_12_weight_ml_Kg                       3.524009e-03  9.394128e-04
## tV_12_eTBV                              -1.514113e-01 -2.264952e-02
## Infusion_rate_hour_Pt_weight             3.090503e-03  7.702962e-04
## Infusion_rate_hour_eTBV                 -1.635042e-01 -1.851413e-02
## Time_from_irradition_to_transfusion_min -5.625311e-06 -2.164171e-05
##                                                  PC15          PC16
## Group                                   -9.803082e-02 -2.814824e-01
## TAH_occurrence                          -1.004371e-01  3.369533e-01
## Mortality1Day                            1.803523e-03 -2.944676e-02
## Sex                                     -4.845909e-01 -1.522022e-03
## Race                                     3.590127e-02  4.266920e-02
## Access                                  -6.971938e-01 -2.189252e-01
## Age_days                                -5.605834e-05  1.018377e-04
## Weight                                   1.331155e-02  9.680872e-04
## Pre_transfusion_K                       -4.764796e-02 -2.769981e-01
## Cr_at_transfusion                        1.411857e-01 -2.320130e-02
## Cardiac_dysf                            -8.204299e-03 -2.434503e-01
## Respiratory_dysf                         3.526483e-01 -5.997082e-01
## Kidney_dysf                              3.560970e-02 -7.327494e-02
## Liver_dysf                              -3.769230e-02  1.723313e-01
## Intracranial_diso                        1.144260e-01 -1.016034e-01
## Orthopedics                             -4.751640e-03 -1.485347e-02
## Anemia                                   1.187570e-01 -1.973908e-01
## Hemoglobinopathy                         6.784039e-02  6.662553e-02
## Sepsis                                  -2.553553e-03 -3.215160e-02
## ECMO                                    -7.885801e-03 -5.256630e-03
## CPB                                     -5.109054e-02 -5.884583e-02
## Prematurity                              8.407602e-02  2.143200e-01
## Dialysis                                 1.603626e-02 -3.580330e-02
## RBC_Unit_type                            1.495965e-01  2.140437e-02
## Age_of_RBC_unit                         -1.203797e-03  1.310393e-03
## Leukoreduction                          -1.556070e-02  8.018843e-02
## Irradiation                             -1.991057e-01 -3.338728e-01
## Washed                                   3.908477e-02  1.314008e-02
## Plasma_reduction                        -2.284248e-02  1.552348e-02
## tV_12_weight_ml_Kg                       7.157516e-04 -1.731770e-03
## tV_12_eTBV                              -2.065718e-02 -2.190345e-02
## Infusion_rate_hour_Pt_weight             6.770571e-05  9.331153e-04
## Infusion_rate_hour_eTBV                 -4.512375e-02 -2.039367e-02
## Time_from_irradition_to_transfusion_min  2.043836e-05  1.737691e-05
##                                                  PC17          PC18
## Group                                    3.238365e-02  1.582647e-01
## TAH_occurrence                          -1.604382e-01  1.781727e-01
## Mortality1Day                            3.025421e-02  1.149140e-01
## Sex                                     -4.080057e-01 -8.106493e-02
## Race                                    -4.499932e-03 -9.560314e-03
## Access                                   3.524189e-01  3.522156e-01
## Age_days                                 6.345218e-05 -3.498175e-05
## Weight                                  -1.565079e-02 -3.534590e-03
## Pre_transfusion_K                       -5.382123e-02 -9.262503e-02
## Cr_at_transfusion                       -3.982467e-03  4.444659e-02
## Cardiac_dysf                            -1.519711e-01 -1.000974e-01
## Respiratory_dysf                        -9.332737e-02  3.167400e-01
## Kidney_dysf                              6.160914e-02 -1.567686e-01
## Liver_dysf                               3.009857e-02  8.268856e-02
## Intracranial_diso                        2.269084e-02  6.503941e-03
## Orthopedics                             -1.440160e-01 -5.608824e-02
## Anemia                                   3.952276e-01 -9.723036e-02
## Hemoglobinopathy                         6.199028e-02 -3.110660e-01
## Sepsis                                  -1.498333e-02 -8.843732e-04
## ECMO                                     5.060982e-02 -3.152335e-01
## CPB                                     -2.229905e-02 -4.852337e-02
## Prematurity                             -2.008221e-01  2.132846e-01
## Dialysis                                 6.847270e-02 -1.925058e-02
## RBC_Unit_type                           -4.351580e-01  3.521243e-01
## Age_of_RBC_unit                         -1.466680e-02  3.240096e-03
## Leukoreduction                           8.601871e-02 -1.968688e-02
## Irradiation                             -4.596765e-01 -3.588049e-01
## Washed                                   4.093748e-02 -1.752881e-01
## Plasma_reduction                         2.161892e-03 -1.090438e-01
## tV_12_weight_ml_Kg                      -4.688257e-03  3.606054e-03
## tV_12_eTBV                               3.907049e-02 -2.138644e-01
## Infusion_rate_hour_Pt_weight             3.230530e-03  4.018876e-03
## Infusion_rate_hour_eTBV                  2.863948e-02 -2.201167e-01
## Time_from_irradition_to_transfusion_min  6.963581e-06  1.191890e-05
##                                                  PC19          PC20
## Group                                    8.922562e-02 -7.605264e-02
## TAH_occurrence                          -5.324519e-01  2.671661e-01
## Mortality1Day                           -1.290296e-01 -9.651783e-02
## Sex                                     -1.325500e-01  1.268094e-01
## Race                                    -2.687100e-02 -1.137198e-02
## Access                                   5.909106e-04 -3.717755e-02
## Age_days                                 3.138800e-05  1.643915e-04
## Weight                                  -2.892534e-03 -1.482126e-02
## Pre_transfusion_K                       -1.297728e-02 -1.851041e-01
## Cr_at_transfusion                        9.282249e-03 -1.634876e-01
## Cardiac_dysf                             2.602250e-01  9.144936e-02
## Respiratory_dysf                        -2.696207e-01  3.992582e-02
## Kidney_dysf                              1.857408e-01  6.593720e-01
## Liver_dysf                               2.558534e-01 -2.952928e-01
## Intracranial_diso                        8.490985e-02 -2.418004e-02
## Orthopedics                             -4.988288e-03 -1.199581e-01
## Anemia                                  -9.842872e-02  2.142291e-01
## Hemoglobinopathy                        -3.268988e-01 -2.045846e-01
## Sepsis                                   5.834043e-02 -2.068358e-01
## ECMO                                    -1.036334e-01  1.239013e-01
## CPB                                     -1.423054e-01 -1.954441e-01
## Prematurity                              4.778997e-01  1.430016e-02
## Dialysis                                 4.219187e-02  5.019983e-02
## RBC_Unit_type                           -1.252750e-01 -1.840547e-02
## Age_of_RBC_unit                         -2.652790e-03  8.461898e-03
## Leukoreduction                           5.225102e-02  8.896793e-02
## Irradiation                              9.977323e-02  2.995169e-02
## Washed                                   1.780924e-02 -9.463092e-02
## Plasma_reduction                         3.376009e-02 -1.176460e-01
## tV_12_weight_ml_Kg                       3.700448e-03  1.176415e-03
## tV_12_eTBV                              -7.750694e-02 -1.854629e-01
## Infusion_rate_hour_Pt_weight            -2.632008e-04  2.504094e-03
## Infusion_rate_hour_eTBV                 -9.351681e-02 -1.859867e-01
## Time_from_irradition_to_transfusion_min -6.443096e-07 -1.566422e-06
##                                                  PC21          PC22
## Group                                   -1.064735e-01 -1.034479e-01
## TAH_occurrence                           4.797346e-02 -3.611862e-01
## Mortality1Day                           -3.079395e-02  2.408728e-01
## Sex                                      8.622409e-02  1.191933e-01
## Race                                    -3.989169e-04  7.881584e-03
## Access                                  -9.515641e-02  2.433031e-02
## Age_days                                 9.332369e-05  5.117800e-05
## Weight                                  -4.397613e-04  2.917107e-04
## Pre_transfusion_K                       -5.830602e-02 -5.889866e-02
## Cr_at_transfusion                       -6.598738e-02 -3.983736e-02
## Cardiac_dysf                            -8.031734e-03 -3.835660e-01
## Respiratory_dysf                         2.662536e-01 -4.741320e-02
## Kidney_dysf                              1.377103e-01  3.022318e-01
## Liver_dysf                               7.527573e-01 -5.945924e-02
## Intracranial_diso                       -3.229881e-01  1.566262e-01
## Orthopedics                             -1.007223e-01  5.910414e-02
## Anemia                                  -1.012620e-02 -2.318705e-01
## Hemoglobinopathy                         2.562431e-02  1.538636e-02
## Sepsis                                   6.898796e-03  4.773123e-01
## ECMO                                    -1.145175e-02  8.076439e-02
## CPB                                     -8.956636e-02 -2.558054e-01
## Prematurity                             -2.512241e-01 -2.762361e-01
## Dialysis                                -1.168044e-01 -4.459074e-02
## RBC_Unit_type                           -1.940629e-01  2.198157e-01
## Age_of_RBC_unit                         -3.669003e-03 -7.642351e-04
## Leukoreduction                          -1.473930e-01 -6.676164e-02
## Irradiation                              8.460744e-02 -8.760052e-02
## Washed                                  -1.050524e-01 -5.099813e-02
## Plasma_reduction                         6.246597e-03 -1.154520e-01
## tV_12_weight_ml_Kg                      -1.870246e-03  2.004672e-03
## tV_12_eTBV                              -8.510955e-02 -1.062387e-02
## Infusion_rate_hour_Pt_weight             3.894522e-03  1.229138e-03
## Infusion_rate_hour_eTBV                 -1.397478e-01 -7.077423e-03
## Time_from_irradition_to_transfusion_min  8.749207e-07  2.713531e-06
##                                                  PC23          PC24
## Group                                   -8.638814e-02 -1.751974e-01
## TAH_occurrence                          -1.100022e-01  1.798562e-01
## Mortality1Day                            2.975846e-01 -2.949926e-01
## Sex                                      8.664283e-02 -5.185182e-02
## Race                                     3.989404e-03  1.843316e-02
## Access                                  -1.426481e-01 -7.228618e-02
## Age_days                                 2.915352e-05  1.704684e-04
## Weight                                   9.635198e-04 -1.339797e-02
## Pre_transfusion_K                        3.684338e-02 -7.371816e-02
## Cr_at_transfusion                       -1.087588e-01  4.229377e-02
## Cardiac_dysf                            -1.522185e-01  1.921749e-01
## Respiratory_dysf                         5.967237e-03 -1.710500e-01
## Kidney_dysf                              9.802692e-02 -6.909653e-02
## Liver_dysf                               1.030194e-01 -8.753715e-03
## Intracranial_diso                       -4.341634e-03  2.401749e-01
## Orthopedics                              3.160340e-01  6.331895e-02
## Anemia                                  -6.074647e-02  2.414921e-01
## Hemoglobinopathy                        -4.747296e-01 -3.975491e-01
## Sepsis                                  -3.863390e-01  4.443679e-01
## ECMO                                    -1.879546e-01 -2.591858e-01
## CPB                                      2.644982e-01  2.485715e-01
## Prematurity                             -2.398892e-01 -3.281215e-01
## Dialysis                                 2.278111e-01 -1.785822e-01
## RBC_Unit_type                           -1.419498e-02 -2.031633e-03
## Age_of_RBC_unit                          1.467693e-03  6.378527e-03
## Leukoreduction                           2.105690e-01 -1.148012e-01
## Irradiation                             -7.959883e-02  4.591236e-02
## Washed                                   1.403403e-01 -2.741803e-02
## Plasma_reduction                         4.074500e-02  1.478733e-02
## tV_12_weight_ml_Kg                      -1.792523e-03 -1.570332e-03
## tV_12_eTBV                               1.456043e-01 -4.193131e-02
## Infusion_rate_hour_Pt_weight            -2.044046e-03  1.754990e-03
## Infusion_rate_hour_eTBV                  1.449391e-01 -3.367438e-02
## Time_from_irradition_to_transfusion_min  6.217692e-07 -1.359675e-05
##                                                  PC25          PC26
## Group                                    1.546565e-01  4.475748e-02
## TAH_occurrence                           7.497623e-02  4.211024e-02
## Mortality1Day                           -6.095621e-02 -6.016039e-01
## Sex                                      9.218089e-02 -4.753928e-02
## Race                                    -2.411331e-02  1.536663e-02
## Access                                  -3.253125e-02  1.119606e-01
## Age_days                                -1.198242e-04  6.939376e-06
## Weight                                  -6.461768e-05 -3.102288e-03
## Pre_transfusion_K                        3.529048e-02  5.884296e-02
## Cr_at_transfusion                        6.442779e-02 -3.252261e-02
## Cardiac_dysf                            -5.511798e-02 -1.808234e-01
## Respiratory_dysf                        -2.587226e-02  1.643230e-01
## Kidney_dysf                             -2.522782e-01  1.531958e-01
## Liver_dysf                               1.797820e-01 -1.119443e-02
## Intracranial_diso                        4.326919e-01 -1.644618e-01
## Orthopedics                              1.824767e-01  6.348937e-01
## Anemia                                   1.261397e-01 -6.544289e-02
## Hemoglobinopathy                        -2.580544e-01  1.006258e-01
## Sepsis                                  -2.488390e-01  5.427208e-02
## ECMO                                     4.763247e-01 -9.674277e-02
## CPB                                     -4.207356e-01 -1.402108e-01
## Prematurity                             -9.669128e-02  8.210350e-02
## Dialysis                                -2.565294e-01  3.152168e-02
## RBC_Unit_type                            3.243850e-02 -2.398335e-02
## Age_of_RBC_unit                         -9.253013e-04  1.306942e-03
## Leukoreduction                          -1.815797e-02  3.211503e-02
## Irradiation                             -4.132182e-02 -1.212818e-01
## Washed                                  -2.137913e-02  2.418515e-02
## Plasma_reduction                         5.917031e-02 -2.648600e-02
## tV_12_weight_ml_Kg                      -2.210829e-03 -1.916154e-04
## tV_12_eTBV                              -8.109784e-03  1.313747e-01
## Infusion_rate_hour_Pt_weight             7.968842e-04 -1.260836e-03
## Infusion_rate_hour_eTBV                  2.033438e-02  1.110516e-01
## Time_from_irradition_to_transfusion_min  6.942507e-07  3.035767e-06
##                                                  PC27          PC28
## Group                                    5.487652e-02  1.527946e-01
## TAH_occurrence                           9.848811e-02 -5.508869e-02
## Mortality1Day                            3.260246e-01 -1.721718e-01
## Sex                                      1.567694e-02  8.718946e-03
## Race                                    -1.178607e-02  3.882755e-03
## Access                                  -1.080852e-01 -7.397995e-03
## Age_days                                 1.015959e-05  2.159460e-05
## Weight                                  -4.020814e-03 -1.046771e-02
## Pre_transfusion_K                        8.557794e-02  3.558125e-02
## Cr_at_transfusion                        6.072555e-03  2.907371e-02
## Cardiac_dysf                             1.063182e-01 -3.019428e-01
## Respiratory_dysf                        -3.573955e-03  9.614852e-02
## Kidney_dysf                             -1.738267e-01  1.577485e-01
## Liver_dysf                              -1.602970e-01 -1.958443e-03
## Intracranial_diso                       -5.659568e-01 -1.752624e-01
## Orthopedics                              2.273541e-01 -2.516131e-01
## Anemia                                   2.140824e-01 -4.720207e-02
## Hemoglobinopathy                        -3.033666e-01 -2.444255e-01
## Sepsis                                   3.702782e-01  4.960224e-02
## ECMO                                     2.215644e-01  3.445363e-01
## CPB                                     -2.236603e-01  4.565784e-01
## Prematurity                              1.320150e-01  1.902347e-01
## Dialysis                                 4.245999e-02 -4.595803e-01
## RBC_Unit_type                           -1.263480e-01  6.570963e-02
## Age_of_RBC_unit                          3.303741e-03  5.908917e-03
## Leukoreduction                          -3.819333e-02  2.215877e-02
## Irradiation                             -4.912000e-02 -6.057036e-02
## Washed                                   7.521698e-02  1.993512e-01
## Plasma_reduction                         5.877751e-02 -6.347539e-02
## tV_12_weight_ml_Kg                      -1.759999e-03 -1.374744e-03
## tV_12_eTBV                               3.898469e-04  1.361701e-01
## Infusion_rate_hour_Pt_weight             5.126384e-04 -2.221269e-03
## Infusion_rate_hour_eTBV                 -7.251901e-03  1.115549e-01
## Time_from_irradition_to_transfusion_min -1.205950e-05 -3.498915e-07
##                                                  PC29          PC30
## Group                                   -3.782822e-02 -1.088297e-02
## TAH_occurrence                          -4.702969e-02 -3.630469e-02
## Mortality1Day                            3.184632e-01  8.707828e-02
## Sex                                     -4.942886e-02 -3.894799e-02
## Race                                     6.688113e-03  2.514238e-03
## Access                                   7.092162e-02  3.980494e-03
## Age_days                                -4.430746e-05  1.363426e-05
## Weight                                   4.445976e-03  1.727423e-04
## Pre_transfusion_K                       -5.768837e-02 -2.416048e-02
## Cr_at_transfusion                        1.117500e-01  4.049269e-03
## Cardiac_dysf                             1.933088e-01 -5.287446e-02
## Respiratory_dysf                        -5.286935e-02 -9.750494e-02
## Kidney_dysf                              1.508267e-01  8.829237e-02
## Liver_dysf                              -7.437678e-02 -9.963406e-02
## Intracranial_diso                       -2.716334e-02  1.091395e-02
## Orthopedics                              3.411441e-01  1.221592e-01
## Anemia                                   2.510874e-02 -1.100835e-02
## Hemoglobinopathy                         2.242391e-01 -5.509513e-02
## Sepsis                                  -1.474412e-01 -2.153964e-01
## ECMO                                    -2.358183e-01 -1.441430e-03
## CPB                                      9.894009e-03  1.052323e-01
## Prematurity                             -2.552630e-03  9.581243e-02
## Dialysis                                -7.039441e-01  2.324085e-02
## RBC_Unit_type                           -5.905405e-02 -1.039470e-01
## Age_of_RBC_unit                          9.628049e-04 -5.841892e-03
## Leukoreduction                           7.763779e-02 -9.125804e-01
## Irradiation                             -1.617552e-02 -6.686907e-02
## Washed                                   1.449198e-01 -1.218055e-01
## Plasma_reduction                         2.244678e-02 -6.886828e-02
## tV_12_weight_ml_Kg                       1.673797e-03 -3.991557e-04
## tV_12_eTBV                              -1.394587e-01  3.481674e-02
## Infusion_rate_hour_Pt_weight             9.508919e-04 -1.146126e-03
## Infusion_rate_hour_eTBV                 -1.066936e-01  6.722608e-02
## Time_from_irradition_to_transfusion_min  7.505348e-06 -3.194662e-06
##                                                  PC31          PC32
## Group                                   -5.356718e-02 -5.014129e-03
## TAH_occurrence                           5.605142e-02 -4.304228e-02
## Mortality1Day                           -8.120990e-02  3.983671e-02
## Sex                                      1.572286e-02 -3.754125e-02
## Race                                    -6.260417e-03 -5.429731e-04
## Access                                   2.163050e-02 -5.771428e-02
## Age_days                                 8.624457e-05  2.029822e-05
## Weight                                  -4.213117e-03 -3.713717e-03
## Pre_transfusion_K                        1.460721e-02 -3.770221e-03
## Cr_at_transfusion                       -1.240564e-02  8.185996e-02
## Cardiac_dysf                             7.583238e-02  5.793855e-03
## Respiratory_dysf                         6.511588e-02 -1.172888e-03
## Kidney_dysf                              3.309621e-02  5.630493e-02
## Liver_dysf                              -9.144719e-02 -9.130943e-02
## Intracranial_diso                       -8.711660e-02 -8.561472e-02
## Orthopedics                             -3.651318e-01 -4.999071e-02
## Anemia                                  -9.795592e-02 -3.044558e-02
## Hemoglobinopathy                        -1.362245e-01 -6.462375e-02
## Sepsis                                  -7.525203e-02 -2.795858e-02
## ECMO                                    -3.495821e-01 -5.861074e-02
## CPB                                     -4.723506e-01 -1.590765e-02
## Prematurity                             -7.896534e-02  2.103774e-02
## Dialysis                                -1.509933e-01 -1.951273e-01
## RBC_Unit_type                            5.576341e-02 -5.216816e-02
## Age_of_RBC_unit                         -7.666503e-04  5.763162e-03
## Leukoreduction                          -1.278485e-01  1.451587e-01
## Irradiation                             -5.440435e-02 -1.592236e-02
## Washed                                   3.755186e-01 -8.179367e-01
## Plasma_reduction                         1.915768e-01  2.837635e-01
## tV_12_weight_ml_Kg                      -4.885361e-03 -4.547882e-03
## tV_12_eTBV                               3.415771e-01  2.838256e-01
## Infusion_rate_hour_Pt_weight            -3.174647e-03 -3.316594e-03
## Infusion_rate_hour_eTBV                  3.176204e-01  2.477773e-01
## Time_from_irradition_to_transfusion_min -9.014439e-06  1.387547e-05
##                                                  PC33          PC34
## Group                                   -2.296811e-02 -1.648235e-02
## TAH_occurrence                           1.825510e-02  2.609544e-03
## Mortality1Day                            5.602898e-02  2.020017e-02
## Sex                                      3.781985e-04  1.741697e-02
## Race                                     3.642831e-03 -2.570696e-04
## Access                                  -2.901213e-02  1.487976e-02
## Age_days                                -3.756448e-06  2.473938e-06
## Weight                                   5.157194e-04  2.103469e-04
## Pre_transfusion_K                       -1.034070e-02  5.046357e-03
## Cr_at_transfusion                        2.678472e-02  4.983163e-03
## Cardiac_dysf                             1.493046e-01  7.384210e-03
## Respiratory_dysf                        -3.938874e-02 -2.232008e-02
## Kidney_dysf                             -7.731129e-02 -1.806091e-02
## Liver_dysf                               7.598533e-02 -2.486299e-02
## Intracranial_diso                       -1.600259e-02  3.241580e-02
## Orthopedics                             -1.536367e-02  2.066699e-02
## Anemia                                   5.703261e-02  1.431381e-02
## Hemoglobinopathy                        -1.254831e-02  7.457714e-03
## Sepsis                                  -1.487708e-02 -1.344448e-02
## ECMO                                    -5.552682e-02  5.118036e-03
## CPB                                     -8.654801e-02  2.068311e-03
## Prematurity                              2.911480e-02  5.269973e-03
## Dialysis                                -6.555579e-02 -6.819291e-03
## RBC_Unit_type                           -4.112560e-02  5.979506e-03
## Age_of_RBC_unit                         -2.853993e-04 -3.765919e-05
## Leukoreduction                           9.076232e-02 -1.499021e-02
## Irradiation                              3.200197e-02  6.427024e-03
## Washed                                  -1.143387e-01  1.030278e-02
## Plasma_reduction                        -8.908368e-01 -3.445801e-02
## tV_12_weight_ml_Kg                      -4.786689e-03 -9.760323e-03
## tV_12_eTBV                               2.248565e-01  7.003395e-01
## Infusion_rate_hour_Pt_weight            -3.216352e-03  9.384976e-03
## Infusion_rate_hour_eTBV                  2.658436e-01 -7.091991e-01
## Time_from_irradition_to_transfusion_min  5.580138e-07  4.546956e-08
a <- as.matrix(df_TAH_data_impute_mean[, c(2,5,10)])

p <- plot_ly() %>%
    add_trace(x=a[,1], y=a[,2], z=a[,3], type="scatter3d", mode="markers", name="",
              marker = list(color=a[,2], colorscale = c("#FFE1A1", "#683531"), opacity = 0.7)) 
for (k in 1:ncol(loadings)) {
    x <- c(0, -loadings[1, k])*scaleLoad  # Project PCAs only on the last 3 original data dimensions (6,5,4)
    y <- c(0, -loadings[2, k])*scaleLoad
    z <- c(0, -loadings[3, k])*scaleLoad
    p <- p %>% add_trace(x=x, y=y, z=z, type="scatter3d", mode="lines", 
                         name=paste0("Loading PC ", k, " ", colnames(df_TAH_data_impute_mean)[k]), line=list(width=8), opacity=1) 
}
p <- p %>%
    layout(legend = list(orientation = 'h'), title="Alternative 3D Projection of 3D Data along with First 3 PCs",
           scene = list ( xaxis = list(title = rownames(loadings)[1]),
                        yaxis = list(title = rownames(loadings)[2]),
                        zaxis = list(title = rownames(loadings)[3]))) 
p

6.2 Linear 2D modeling

# Define the 3D features
x <- df_TAH_data_impute_mean$Age_days
y <- df_TAH_data_impute_mean$tV_12_eTBV
z <- df_TAH_data_impute_mean$Infusion_rate_hour_eTBV

z1 <- df_TAH_data_impute_mean$TAH_occurrence

myDF <- data.frame(x, y, z)

### Fit a (bivariate-predictor) linear regression model
lm.fit <- lm(z ~ x+y)
str(df_TAH_data_impute_mean)
## 'data.frame':    95 obs. of  34 variables:
##  $ Group                                  : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ TAH_occurrence                         : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Mortality1Day                          : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Sex                                    : num  1 2 2 1 2 1 1 2 2 1 ...
##  $ Race                                   : num  5 5 5 5 2 1 1 1 2 1 ...
##  $ Access                                 : num  2 2 2 2 2 1 2 2 2 2 ...
##  $ Age_days                               : num  26 9 19 13 2 12 23 2 8 24 ...
##  $ Weight                                 : num  4.35 0.63 0.99 4.7 2 ...
##  $ Pre_transfusion_K                      : num  5.4 5.4 5.1 4.8 2 3.8 4.6 4.8 4.4 4.4 ...
##  $ Cr_at_transfusion                      : num  0.28 0.89 0.63 0.55 2 0.45 0.3 0.7 0.5 0.4 ...
##  $ Cardiac_dysf                           : num  2 1 1 2 2 1 1 1 1 2 ...
##  $ Respiratory_dysf                       : num  1 2 2 2 2 2 1 1 1 2 ...
##  $ Kidney_dysf                            : num  1 1 1 1 2 1 1 1 1 2 ...
##  $ Liver_dysf                             : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Intracranial_diso                      : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Orthopedics                            : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Anemia                                 : num  1 2 2 1 2 1 1 1 1 1 ...
##  $ Hemoglobinopathy                       : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Sepsis                                 : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ ECMO                                   : num  2 1 1 2 2 1 1 1 1 2 ...
##  $ CPB                                    : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Prematurity                            : num  1 2 2 1 2 1 2 1 2 1 ...
##  $ Dialysis                               : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ RBC_Unit_type                          : num  2 2 2 2 2 2 1 1 1 2 ...
##  $ Age_of_RBC_unit                        : num  8 7 9 5 2 4 14 14 14 8 ...
##  $ Leukoreduction                         : num  2 2 2 2 2 2 2 2 2 2 ...
##  $ Irradiation                            : num  1 1 1 2 2 1 2 2 2 2 ...
##  $ Washed                                 : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ Plasma_reduction                       : num  1 1 1 1 2 1 1 1 1 1 ...
##  $ tV_12_weight_ml_Kg                     : num  13.79 33.33 25.25 4.79 2 ...
##  $ tV_12_eTBV                             : num  0.16 0.33 0.25 0.06 2 0.21 0.2 0.18 0.21 0.16 ...
##  $ Infusion_rate_hour_Pt_weight           : num  9.2 13.33 14.43 2.99 2 ...
##  $ Infusion_rate_hour_eTBV                : num  0.11 0.13 0.14 0.04 2 0.14 0.05 0.09 0.07 0.06 ...
##  $ Time_from_irradition_to_transfusion_min: num  118 118 118 52 2 118 116 30 67 43 ...
# account for the categorical variables ....
df_TAH_data_impute_mean[ , factorVarNames[-1]] <- lapply(df_TAH_data_impute_mean[ , factorVarNames[-1]] , factor)


lm.fit <- glm(as.factor(TAH_occurrence) ~ Age_days + Age_of_RBC_unit + Irradiation + Time_from_irradition_to_transfusion_min + 
                tV_12_eTBV + Infusion_rate_hour_eTBV, data=df_TAH_data_impute_mean, family = "binomial")
summary(lm.fit)
## 
## Call:
## glm(formula = as.factor(TAH_occurrence) ~ Age_days + Age_of_RBC_unit + 
##     Irradiation + Time_from_irradition_to_transfusion_min + tV_12_eTBV + 
##     Infusion_rate_hour_eTBV, family = "binomial", data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4002  -0.8382  -0.4733   0.5344   2.1610  
## 
## Coefficients:
##                                           Estimate Std. Error z value Pr(>|z|)
## (Intercept)                             -1.485e+00  8.529e-01  -1.742  0.08158
## Age_days                                 7.411e-05  1.365e-04   0.543  0.58726
## Age_of_RBC_unit                         -8.585e-02  4.053e-02  -2.118  0.03415
## Irradiation2                             3.064e-01  6.240e-01   0.491  0.62335
## Time_from_irradition_to_transfusion_min  6.277e-05  7.465e-05   0.841  0.40039
## tV_12_eTBV                               6.063e+00  2.250e+00   2.695  0.00703
## Infusion_rate_hour_eTBV                 -1.265e+00  1.643e+00  -0.770  0.44134
##                                           
## (Intercept)                             . 
## Age_days                                  
## Age_of_RBC_unit                         * 
## Irradiation2                              
## Time_from_irradition_to_transfusion_min   
## tV_12_eTBV                              **
## Infusion_rate_hour_eTBV                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 126.074  on 94  degrees of freedom
## Residual deviance:  91.268  on 88  degrees of freedom
## AIC: 105.27
## 
## Number of Fisher Scoring iterations: 7
lm.fitReduced <- glm(as.factor(TAH_occurrence) ~ Age_of_RBC_unit + tV_12_eTBV, data=df_TAH_data_impute_mean, family = "binomial")
summary(lm.fitReduced)
## 
## Call:
## glm(formula = as.factor(TAH_occurrence) ~ Age_of_RBC_unit + tV_12_eTBV, 
##     family = "binomial", data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.3061  -0.8725  -0.5078   0.4966   1.9397  
## 
## Coefficients:
##                 Estimate Std. Error z value Pr(>|z|)   
## (Intercept)     -1.05578    0.59395  -1.778  0.07547 . 
## Age_of_RBC_unit -0.07176    0.03550  -2.022  0.04323 * 
## tV_12_eTBV       4.82842    1.65546   2.917  0.00354 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 126.07  on 94  degrees of freedom
## Residual deviance:  93.45  on 92  degrees of freedom
## AIC: 99.45
## 
## Number of Fisher Scoring iterations: 7
hControls <- hist(df_TAH_data_TAH_Controls$tV_12_eTBV, breaks = 30, plot = FALSE, xlim=range(0,5))
hPatients <- hist(df_TAH_data_TAH_Patients$tV_12_eTBV, breaks = "FD", plot = FALSE)
h <- hist(df_TAH_data_impute_mean$tV_12_eTBV, breaks = "FD", plot = FALSE)
plControls <- plot_ly(x = hControls$mids, y = hControls$counts, name="Controls") %>% add_bars() # name = df_TAH_data_impute_mean$TAH_occurrence)
plPatients <- plot_ly(x = hPatients$mids, y = hPatients$counts, name="Patients")  %>% add_bars()
subplot(plControls, plPatients, nrows = 2)

7 Individual Factor-effects on Clinical Outcomes (TAH-occurance and Mortality1Day)

7.1 TAH-occurance

# Age_days, Pre_transfusion_K, Age_of_RBC_unit, tV_12_eTBV, Infusion_rate_hour_eTBV, Time_from_irradition_to_transfusion_min
plot_ly(data=df_TAH_data_impute_mean, x=~tV_12_eTBV, name=~TAH_occurrence, type="histogram", opacity=0.9, nbinsx=100, histnorm="probability") %>% 
    add_segments(x=0.3, xend=0.3, y=0, yend=0.3, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "tV_12_eTBV Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "tV_12_eTBV"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~tV_12_weight_ml_Kg, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=20, histnorm="probability") %>% 
    add_segments(x=30, xend=30, y=0, yend=0.7, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "tV_12_weight_ml_Kg Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "tV_12_weight_ml_Kg"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~tV_12_eTBV, name=~TAH_occurrence, type="histogram", opacity=0.9, nbinsx=100, histnorm="probability") %>% 
    add_segments(x=0.3, xend=0.3, y=0, yend=0.3, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "tV_12_eTBV Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "tV_12_eTBV"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Age_days, name=~TAH_occurrence, type="histogram", opacity=0.9, nbinsx=100, histnorm="probability") %>% 
    # add_segments(x=0.3, xend=0.3, y=0, yend=0.3, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Age_days Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Age_days"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Pre_transfusion_K, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    # add_segments(x=4.5, xend=4.5, y=0, yend=0.2, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Pre_transfusion_K Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Pre_transfusion_K"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Age_of_RBC_unit, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    add_segments(x=7.95, xend=7.95, y=0, yend=0.25, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Age_of_RBC_unit Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Age_of_RBC_unit"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Infusion_rate_hour_eTBV, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=20, histnorm="probability") %>% 
    # add_segments(x=0.3, xend=0.3, y=0, yend=0.3, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Infusion_rate_hour_eTBV Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Infusion_rate_hour_eTBV"), yaxis = list(title = "Density"))
# plot_ly(data=df_TAH_data_impute_mean, x=~Infusion_rate_hour_Pt_weight, name=~TAH_occurrence, type="histogram", 
#         opacity=0.9, nbinsx=20, histnorm="probability") %>% 
#     add_segments(x=10, xend=10, y=0, yend=0.5, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
#     layout(title = "Infusion_rate_hour_Pt_weight Distributions by Cohort (Controls (1) & Patients (2))", 
#            xaxis = list(title = "Infusion_rate_hour_Pt_weight"), yaxis = list(title = "Density"))

plot_ly(data=df_TAH_data_impute_mean, x=~Time_from_irradition_to_transfusion_min, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=40, histnorm="probability") %>% 
    # add_segments(x=0.3, xend=0.3, y=0, yend=0.3, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Time_from_irradition_to_transfusion_min Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Time from irradition to transfusion (min)"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Age_days, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    # add_segments(x=7.95, xend=7.95, y=0, yend=0.25, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Age (in days) Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Age (days)"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~Weight, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    # add_segments(x=7.95, xend=7.95, y=0, yend=0.25, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "Weight Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "Weight"), yaxis = list(title = "Density"))
# plot_ly(data=df_TAH_data_impute_mean, x=~Pre_transfusion_K, name=~TAH_occurrence, type="histogram", 
#         opacity=0.9, nbinsx=30, histnorm="probability") %>% 
#     add_segments(x=5.5, xend=5.5, y=0, yend=0.25, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
#     layout(title = "Pre-transfusion K Distributions by Cohort (Controls (1) & Patients (2))", 
#            xaxis = list(title = "Pre-transfusion K"), yaxis = list(title = "Density"))

# plot_ly(data=df_TAH_data_impute_mean, x=~Infusion_rate_hour_eTBV, name=~TAH_occurrence, type="histogram", 
#         opacity=0.9, nbinsx=30, histnorm="probability") %>% 
#     add_segments(x=0.15, xend=0.15, y=0, yend=0.7, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
#     layout(title = "Infusion rate/hour eTBV Distributions by Cohort (Controls (1) & Patients (2))", 
#            xaxis = list(title = "Infusion rate/hour eTBV"), yaxis = list(title = "Density"))

plot_ly(data=df_TAH_data_impute_mean, x=~ECMO, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    # add_segments(x=1.5, xend=1.5, y=0, yend=0.7, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "ECMO Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "ECMO"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean, x=~CPB, name=~TAH_occurrence, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    # add_segments(x=1.5, xend=1.5, y=0, yend=0.7, line=list(width=4, color="green", dash='dot'), name="Cutoff") %>%
    layout(title = "CPB Distributions by Cohort (Controls (1) & Patients (2))", 
           xaxis = list(title = "CPB"), yaxis = list(title = "Density"))

7.2 Mortality1Day

# Age_days, Pre_transfusion_K, Age_of_RBC_unit, tV_12_eTBV, Infusion_rate_hour_eTBV, Time_from_irradition_to_transfusion_min
# pl_list <- list()
# for (i in 1:dim(df_TAH_data_impute_mean_2Way_Mortality)[2]) { 
#   if (i !=3 ) {
#     pl_list[[i]] <- plot_ly(x=~df_TAH_data_impute_mean_2Way_Mortality[, i], name=~df_TAH_data_impute_mean_2Way_Mortality[, 3], 
#                           type="histogram", opacity=0.9, nbinsx=10, histnorm="probability") %>% 
#                         layout(title = paste0(colnames(df_TAH_data_impute_mean_2Way_Mortality)[i], " Distributions by 1-Day Mortality Cohort"), 
#                           xaxis = list(title = colnames(df_TAH_data_impute_mean_2Way_Mortality)[i]), yaxis = list(title = "Density"))
#   }
# }
# 
# pl_list[-3] %>% subplot(nrows = 10) %>% layout(title="Mortality1Day")

plot_ly(data=df_TAH_data_impute_mean_2Way_Mortality, x=~Pre_transfusion_K, name=~Mortality1Day, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    layout(title = "Pre-transfusion K Distributions by by 1-Day Mortality Cohort", 
           xaxis = list(title = "Pre-transfusion K"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean_2Way_Mortality, x=~Infusion_rate_hour_eTBV, name=~Mortality1Day, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    layout(title = "Infusion_rate_hour_eTBVDistributions by by 1-Day Mortality Cohort", 
           xaxis = list(title = "Infusion_rate_hour_eTBV"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean_2Way_Mortality, x=~ECMO, name=~Mortality1Day, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    layout(title = "ECMO Distributions by by 1-Day Mortality Cohort", 
           xaxis = list(title = "ECMO"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean_2Way_Mortality, x=~CPB, name=~Mortality1Day, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    layout(title = "CPB Distributions by by 1-Day Mortality Cohort", 
           xaxis = list(title = "CPB"), yaxis = list(title = "Density"))
plot_ly(data=df_TAH_data_impute_mean_2Way_Mortality, x=~Group, name=~Mortality1Day, type="histogram", 
        opacity=0.9, nbinsx=30, histnorm="probability") %>% 
    layout(title = "Group Distributions by by 1-Day Mortality Cohort", 
           xaxis = list(title = "Group"), yaxis = list(title = "Density"))

8 Linear Modeling (TAH_occurrence)

# Backwards step linear model selection
lm_full.fit <- glm(as.factor(TAH_occurrence) ~ ., data=df_TAH_data_impute_mean, family = "binomial")
summary(lm.fit)
## 
## Call:
## glm(formula = as.factor(TAH_occurrence) ~ Age_days + Age_of_RBC_unit + 
##     Irradiation + Time_from_irradition_to_transfusion_min + tV_12_eTBV + 
##     Infusion_rate_hour_eTBV, family = "binomial", data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4002  -0.8382  -0.4733   0.5344   2.1610  
## 
## Coefficients:
##                                           Estimate Std. Error z value Pr(>|z|)
## (Intercept)                             -1.485e+00  8.529e-01  -1.742  0.08158
## Age_days                                 7.411e-05  1.365e-04   0.543  0.58726
## Age_of_RBC_unit                         -8.585e-02  4.053e-02  -2.118  0.03415
## Irradiation2                             3.064e-01  6.240e-01   0.491  0.62335
## Time_from_irradition_to_transfusion_min  6.277e-05  7.465e-05   0.841  0.40039
## tV_12_eTBV                               6.063e+00  2.250e+00   2.695  0.00703
## Infusion_rate_hour_eTBV                 -1.265e+00  1.643e+00  -0.770  0.44134
##                                           
## (Intercept)                             . 
## Age_days                                  
## Age_of_RBC_unit                         * 
## Irradiation2                              
## Time_from_irradition_to_transfusion_min   
## tV_12_eTBV                              **
## Infusion_rate_hour_eTBV                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 126.074  on 94  degrees of freedom
## Residual deviance:  91.268  on 88  degrees of freedom
## AIC: 105.27
## 
## Number of Fisher Scoring iterations: 7
backwards = stats::step(lm_full.fit)
## Start:  AIC=82
## as.factor(TAH_occurrence) ~ Group + Mortality1Day + Sex + Race + 
##     Access + Age_days + Weight + Pre_transfusion_K + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Liver_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + Hemoglobinopathy + 
##     Sepsis + ECMO + CPB + Prematurity + Dialysis + RBC_Unit_type + 
##     Age_of_RBC_unit + Leukoreduction + Irradiation + Washed + 
##     Plasma_reduction + tV_12_weight_ml_Kg + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df   Deviance AIC
## - Group                                    4 4.7732e-09  74
## - Race                                     4 9.2336e-09  74
## - RBC_Unit_type                            2 1.8283e-08  78
## - Liver_dysf                               1 3.3783e-09  80
## - ECMO                                     1 3.3863e-09  80
## - tV_12_eTBV                               1 3.3901e-09  80
## - Irradiation                              1 3.3994e-09  80
## - Sex                                      1 3.4087e-09  80
## - Hemoglobinopathy                         1 3.4143e-09  80
## - Infusion_rate_hour_Pt_weight             1 3.4143e-09  80
## - Sepsis                                   1 3.4233e-09  80
## - Kidney_dysf                              1 3.4246e-09  80
## - Infusion_rate_hour_eTBV                  1 3.4322e-09  80
## - Washed                                   1 3.4483e-09  80
## - Cardiac_dysf                             1 3.4524e-09  80
## - CPB                                      1 3.4541e-09  80
## - Age_days                                 1 3.4920e-09  80
## - Leukoreduction                           1 3.5064e-09  80
## - Plasma_reduction                         1 3.5106e-09  80
## - Mortality1Day                            1 3.5574e-09  80
## - Age_of_RBC_unit                          1 3.5938e-09  80
## - Respiratory_dysf                         1 3.6503e-09  80
## - Access                                   1 3.6522e-09  80
## - tV_12_weight_ml_Kg                       1 3.6643e-09  80
## - Dialysis                                 1 3.6947e-09  80
## - Pre_transfusion_K                        1 3.7557e-09  80
## - Weight                                   1 3.8228e-09  80
## - Prematurity                              1 3.8547e-09  80
## - Cr_at_transfusion                        1 4.0420e-09  80
## - Intracranial_diso                        1 4.5167e-09  80
## - Orthopedics                              1 5.7284e-09  80
## - Time_from_irradition_to_transfusion_min  1 6.6280e-09  80
## - Anemia                                   1 1.7408e-08  80
## <none>                                       3.3893e-09  82
## 
## Step:  AIC=74
## as.factor(TAH_occurrence) ~ Mortality1Day + Sex + Race + Access + 
##     Age_days + Weight + Pre_transfusion_K + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Liver_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + Hemoglobinopathy + 
##     Sepsis + ECMO + CPB + Prematurity + Dialysis + RBC_Unit_type + 
##     Age_of_RBC_unit + Leukoreduction + Irradiation + Washed + 
##     Plasma_reduction + tV_12_weight_ml_Kg + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Race                                     4     0.00  66.00
## - RBC_Unit_type                            2     0.00  70.00
## - Mortality1Day                            1     0.00  72.00
## - Prematurity                              1     0.00  72.00
## - ECMO                                     1     0.00  72.00
## - Dialysis                                 1     0.00  72.00
## - Liver_dysf                               1     0.00  72.00
## - Infusion_rate_hour_eTBV                  1     0.00  72.00
## - Leukoreduction                           1     0.00  72.00
## - Age_days                                 1     0.00  72.00
## - Cr_at_transfusion                        1     0.00  72.00
## - Sepsis                                   1     0.00  72.00
## - Hemoglobinopathy                         1     0.00  72.00
## - Infusion_rate_hour_Pt_weight             1     0.00  72.00
## - Irradiation                              1     0.00  72.00
## - Washed                                   1     0.00  72.00
## - Kidney_dysf                              1     0.00  72.00
## - Sex                                      1     0.00  72.00
## - Plasma_reduction                         1     0.00  72.00
## - Weight                                   1     0.00  72.00
## - CPB                                      1     0.00  72.00
## - tV_12_eTBV                               1     0.00  72.00
## - Pre_transfusion_K                        1     0.00  72.00
## - Age_of_RBC_unit                          1     0.00  72.00
## - Cardiac_dysf                             1     0.00  72.00
## - Access                                   1     0.00  72.00
## - Intracranial_diso                        1     0.00  72.00
## - Time_from_irradition_to_transfusion_min  1     0.00  72.00
## - tV_12_weight_ml_Kg                       1     0.00  72.00
## - Orthopedics                              1     0.00  72.00
## - Respiratory_dysf                         1     0.00  72.00
## <none>                                           0.00  74.00
## - Anemia                                   1   504.61 576.61
## 
## Step:  AIC=66
## as.factor(TAH_occurrence) ~ Mortality1Day + Sex + Access + Age_days + 
##     Weight + Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + 
##     Respiratory_dysf + Kidney_dysf + Liver_dysf + Intracranial_diso + 
##     Orthopedics + Anemia + Hemoglobinopathy + Sepsis + ECMO + 
##     CPB + Prematurity + Dialysis + RBC_Unit_type + Age_of_RBC_unit + 
##     Leukoreduction + Irradiation + Washed + Plasma_reduction + 
##     tV_12_weight_ml_Kg + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - tV_12_weight_ml_Kg                       1    0.000 64.000
## - Mortality1Day                            1    0.000 64.000
## - Plasma_reduction                         1    0.000 64.000
## - ECMO                                     1    0.000 64.000
## - Liver_dysf                               1    0.000 64.000
## - Infusion_rate_hour_Pt_weight             1    0.000 64.000
## - tV_12_eTBV                               1    0.000 64.000
## - Infusion_rate_hour_eTBV                  1    0.000 64.000
## - Leukoreduction                           1    0.000 64.000
## - Sepsis                                   1    0.000 64.000
## - Age_of_RBC_unit                          1    0.000 64.000
## - Washed                                   1    0.000 64.000
## - Sex                                      1    0.000 64.000
## - Hemoglobinopathy                         1    0.000 64.000
## - Irradiation                              1    0.000 64.000
## - Age_days                                 1    0.000 64.000
## - CPB                                      1    0.000 64.000
## - Intracranial_diso                        1    0.000 64.000
## - Pre_transfusion_K                        1    0.000 64.000
## - Access                                   1    0.000 64.000
## - Weight                                   1    0.000 64.000
## - Cardiac_dysf                             1    0.000 64.000
## - Orthopedics                              1    0.000 64.000
## - Cr_at_transfusion                        1    0.000 64.000
## - Prematurity                              1    0.000 64.000
## - Dialysis                                 1    0.000 64.000
## - Time_from_irradition_to_transfusion_min  1    0.000 64.000
## - Respiratory_dysf                         1    0.000 64.000
## - Kidney_dysf                              1    0.000 64.000
## <none>                                          0.000 66.000
## - Anemia                                   1   25.977 89.977
## - RBC_Unit_type                            2   37.923 99.923
## 
## Step:  AIC=64
## as.factor(TAH_occurrence) ~ Mortality1Day + Sex + Access + Age_days + 
##     Weight + Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + 
##     Respiratory_dysf + Kidney_dysf + Liver_dysf + Intracranial_diso + 
##     Orthopedics + Anemia + Hemoglobinopathy + Sepsis + ECMO + 
##     CPB + Prematurity + Dialysis + RBC_Unit_type + Age_of_RBC_unit + 
##     Leukoreduction + Irradiation + Washed + Plasma_reduction + 
##     tV_12_eTBV + Infusion_rate_hour_Pt_weight + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Mortality1Day                            1     0.00  62.00
## - ECMO                                     1     0.00  62.00
## - Leukoreduction                           1     0.00  62.00
## - Plasma_reduction                         1     0.00  62.00
## - Liver_dysf                               1     0.00  62.00
## - Sepsis                                   1     0.00  62.00
## - Infusion_rate_hour_Pt_weight             1     0.00  62.00
## - Washed                                   1     0.00  62.00
## - Sex                                      1     0.00  62.00
## - Hemoglobinopathy                         1     0.00  62.00
## - Age_of_RBC_unit                          1     0.00  62.00
## - Infusion_rate_hour_eTBV                  1     0.00  62.00
## - Irradiation                              1     0.00  62.00
## - Cardiac_dysf                             1     0.00  62.00
## - Age_days                                 1     0.00  62.00
## - Pre_transfusion_K                        1     0.00  62.00
## - CPB                                      1     0.00  62.00
## - Access                                   1     0.00  62.00
## - Weight                                   1     0.00  62.00
## - Intracranial_diso                        1     0.00  62.00
## - Orthopedics                              1     0.00  62.00
## - Cr_at_transfusion                        1     0.00  62.00
## - Respiratory_dysf                         1     0.00  62.00
## - Dialysis                                 1     0.00  62.00
## - Prematurity                              1     0.00  62.00
## - Kidney_dysf                              1     0.00  62.00
## <none>                                           0.00  64.00
## - Anemia                                   1    26.30  88.30
## - RBC_Unit_type                            2    38.30  98.30
## - tV_12_eTBV                               1    39.61 101.61
## - Time_from_irradition_to_transfusion_min  1   720.87 782.87
## 
## Step:  AIC=62
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Liver_dysf + Intracranial_diso + Orthopedics + 
##     Anemia + Hemoglobinopathy + Sepsis + ECMO + CPB + Prematurity + 
##     Dialysis + RBC_Unit_type + Age_of_RBC_unit + Leukoreduction + 
##     Irradiation + Washed + Plasma_reduction + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Sepsis                                   1     0.00  60.00
## - Plasma_reduction                         1     0.00  60.00
## - ECMO                                     1     0.00  60.00
## - Leukoreduction                           1     0.00  60.00
## - Liver_dysf                               1     0.00  60.00
## - Infusion_rate_hour_Pt_weight             1     0.00  60.00
## - Washed                                   1     0.00  60.00
## - Hemoglobinopathy                         1     0.00  60.00
## - Sex                                      1     0.00  60.00
## - Age_of_RBC_unit                          1     0.00  60.00
## - Infusion_rate_hour_eTBV                  1     0.00  60.00
## - Irradiation                              1     0.00  60.00
## - CPB                                      1     0.00  60.00
## - Age_days                                 1     0.00  60.00
## - Intracranial_diso                        1     0.00  60.00
## - Cardiac_dysf                             1     0.00  60.00
## - Pre_transfusion_K                        1     0.00  60.00
## - Weight                                   1     0.00  60.00
## - Cr_at_transfusion                        1     0.00  60.00
## - Orthopedics                              1     0.00  60.00
## - Access                                   1     0.00  60.00
## - Respiratory_dysf                         1     0.00  60.00
## - Prematurity                              1     0.00  60.00
## - Kidney_dysf                              1     0.00  60.00
## - Dialysis                                 1     0.00  60.00
## <none>                                           0.00  62.00
## - Anemia                                   1    37.30  97.30
## - RBC_Unit_type                            2    40.60  98.60
## - tV_12_eTBV                               1    48.96 108.96
## - Time_from_irradition_to_transfusion_min  1   648.79 708.79
## 
## Step:  AIC=60
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Liver_dysf + Intracranial_diso + Orthopedics + 
##     Anemia + Hemoglobinopathy + ECMO + CPB + Prematurity + Dialysis + 
##     RBC_Unit_type + Age_of_RBC_unit + Leukoreduction + Irradiation + 
##     Washed + Plasma_reduction + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Plasma_reduction                         1    0.000  58.000
## - ECMO                                     1    0.000  58.000
## - Liver_dysf                               1    0.000  58.000
## - Infusion_rate_hour_Pt_weight             1    0.000  58.000
## - Leukoreduction                           1    0.000  58.000
## - Washed                                   1    0.000  58.000
## - Hemoglobinopathy                         1    0.000  58.000
## - Sex                                      1    0.000  58.000
## - Age_of_RBC_unit                          1    0.000  58.000
## - Infusion_rate_hour_eTBV                  1    0.000  58.000
## - Irradiation                              1    0.000  58.000
## - CPB                                      1    0.000  58.000
## - Age_days                                 1    0.000  58.000
## - Intracranial_diso                        1    0.000  58.000
## - Pre_transfusion_K                        1    0.000  58.000
## - Cardiac_dysf                             1    0.000  58.000
## - Weight                                   1    0.000  58.000
## - Cr_at_transfusion                        1    0.000  58.000
## - Orthopedics                              1    0.000  58.000
## - Access                                   1    0.000  58.000
## - Dialysis                                 1    0.000  58.000
## - Respiratory_dysf                         1    0.000  58.000
## - Time_from_irradition_to_transfusion_min  1    0.000  58.000
## - Prematurity                              1    0.000  58.000
## - Kidney_dysf                              1    0.000  58.000
## <none>                                          0.000  60.000
## - Anemia                                   1   38.047  96.047
## - RBC_Unit_type                            2   40.617  96.617
## - tV_12_eTBV                               1   51.002 109.002
## 
## Step:  AIC=58
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Liver_dysf + Intracranial_diso + Orthopedics + 
##     Anemia + Hemoglobinopathy + ECMO + CPB + Prematurity + Dialysis + 
##     RBC_Unit_type + Age_of_RBC_unit + Leukoreduction + Irradiation + 
##     Washed + tV_12_eTBV + Infusion_rate_hour_Pt_weight + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Liver_dysf                               1     0.00  56.00
## - ECMO                                     1     0.00  56.00
## - Leukoreduction                           1     0.00  56.00
## - Infusion_rate_hour_Pt_weight             1     0.00  56.00
## - Washed                                   1     0.00  56.00
## - Hemoglobinopathy                         1     0.00  56.00
## - Sex                                      1     0.00  56.00
## - Age_of_RBC_unit                          1     0.00  56.00
## - Infusion_rate_hour_eTBV                  1     0.00  56.00
## - Irradiation                              1     0.00  56.00
## - CPB                                      1     0.00  56.00
## - Age_days                                 1     0.00  56.00
## - Intracranial_diso                        1     0.00  56.00
## - Pre_transfusion_K                        1     0.00  56.00
## - Cardiac_dysf                             1     0.00  56.00
## - Weight                                   1     0.00  56.00
## - Cr_at_transfusion                        1     0.00  56.00
## - Orthopedics                              1     0.00  56.00
## - Access                                   1     0.00  56.00
## - Dialysis                                 1     0.00  56.00
## - Respiratory_dysf                         1     0.00  56.00
## - Prematurity                              1     0.00  56.00
## - Kidney_dysf                              1     0.00  56.00
## <none>                                           0.00  58.00
## - RBC_Unit_type                            2    40.82  94.82
## - Anemia                                   1    39.93  95.93
## - tV_12_eTBV                               1    51.86 107.86
## - Time_from_irradition_to_transfusion_min  1   937.13 993.13
## 
## Step:  AIC=56
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     Hemoglobinopathy + ECMO + CPB + Prematurity + Dialysis + 
##     RBC_Unit_type + Age_of_RBC_unit + Leukoreduction + Irradiation + 
##     Washed + tV_12_eTBV + Infusion_rate_hour_Pt_weight + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - ECMO                                     1     0.00  54.00
## - Leukoreduction                           1     0.00  54.00
## - Hemoglobinopathy                         1     0.00  54.00
## - Infusion_rate_hour_Pt_weight             1     0.00  54.00
## - Washed                                   1     0.00  54.00
## - Sex                                      1     0.00  54.00
## - Age_of_RBC_unit                          1     0.00  54.00
## - Infusion_rate_hour_eTBV                  1     0.00  54.00
## - Irradiation                              1     0.00  54.00
## - CPB                                      1     0.00  54.00
## - Age_days                                 1     0.00  54.00
## - Pre_transfusion_K                        1     0.00  54.00
## - Intracranial_diso                        1     0.00  54.00
## - Weight                                   1     0.00  54.00
## - Cardiac_dysf                             1     0.00  54.00
## - Dialysis                                 1     0.00  54.00
## - Cr_at_transfusion                        1     0.00  54.00
## - Access                                   1     0.00  54.00
## - Prematurity                              1     0.00  54.00
## - Respiratory_dysf                         1     0.00  54.00
## - Kidney_dysf                              1     0.00  54.00
## <none>                                           0.00  56.00
## - RBC_Unit_type                            2    41.69  93.69
## - Anemia                                   1    41.95  95.95
## - tV_12_eTBV                               1    59.09 113.09
## - Orthopedics                              1   576.70 630.70
## - Time_from_irradition_to_transfusion_min  1   648.79 702.79
## 
## Step:  AIC=54
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     Hemoglobinopathy + CPB + Prematurity + Dialysis + RBC_Unit_type + 
##     Age_of_RBC_unit + Leukoreduction + Irradiation + Washed + 
##     tV_12_eTBV + Infusion_rate_hour_Pt_weight + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Leukoreduction                           1     0.00   52.00
## - Infusion_rate_hour_Pt_weight             1     0.00   52.00
## - Hemoglobinopathy                         1     0.00   52.00
## - Washed                                   1     0.00   52.00
## - Sex                                      1     0.00   52.00
## - Age_of_RBC_unit                          1     0.00   52.00
## - Infusion_rate_hour_eTBV                  1     0.00   52.00
## - Irradiation                              1     0.00   52.00
## - CPB                                      1     0.00   52.00
## - Age_days                                 1     0.00   52.00
## - Pre_transfusion_K                        1     0.00   52.00
## - Weight                                   1     0.00   52.00
## - Intracranial_diso                        1     0.00   52.00
## - Access                                   1     0.00   52.00
## - Cr_at_transfusion                        1     0.00   52.00
## - Prematurity                              1     0.00   52.00
## - Dialysis                                 1     0.00   52.00
## <none>                                           0.00   54.00
## - RBC_Unit_type                            2    41.94   91.94
## - Anemia                                   1    42.36   94.36
## - tV_12_eTBV                               1    59.78  111.78
## - Orthopedics                              1   360.44  412.44
## - Cardiac_dysf                             1   504.61  556.61
## - Time_from_irradition_to_transfusion_min  1   576.70  628.70
## - Kidney_dysf                              1   648.79  700.79
## - Respiratory_dysf                         1  1081.31 1133.31
## 
## Step:  AIC=52
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     Hemoglobinopathy + CPB + Prematurity + Dialysis + RBC_Unit_type + 
##     Age_of_RBC_unit + Irradiation + Washed + tV_12_eTBV + Infusion_rate_hour_Pt_weight + 
##     Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Infusion_rate_hour_Pt_weight             1     0.00  50.00
## - Hemoglobinopathy                         1     0.00  50.00
## - Washed                                   1     0.00  50.00
## - Sex                                      1     0.00  50.00
## - Infusion_rate_hour_eTBV                  1     0.00  50.00
## - Irradiation                              1     0.00  50.00
## - CPB                                      1     0.00  50.00
## - Age_days                                 1     0.00  50.00
## - Pre_transfusion_K                        1     0.00  50.00
## - Weight                                   1     0.00  50.00
## - Intracranial_diso                        1     0.00  50.00
## - Cardiac_dysf                             1     0.00  50.00
## - Access                                   1     0.00  50.00
## - Cr_at_transfusion                        1     0.00  50.00
## - Prematurity                              1     0.00  50.00
## - Age_of_RBC_unit                          1     0.00  50.00
## - Dialysis                                 1     0.00  50.00
## - Respiratory_dysf                         1     0.00  50.00
## <none>                                           0.00  52.00
## - RBC_Unit_type                            2    41.96  89.96
## - Anemia                                   1    42.41  92.41
## - tV_12_eTBV                               1    60.01 110.01
## - Time_from_irradition_to_transfusion_min  1   360.44 410.44
## - Kidney_dysf                              1   576.70 626.70
## - Orthopedics                              1   648.79 698.79
## 
## Step:  AIC=50
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     Hemoglobinopathy + CPB + Prematurity + Dialysis + RBC_Unit_type + 
##     Age_of_RBC_unit + Irradiation + Washed + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Hemoglobinopathy                         1    0.000  48.000
## - Washed                                   1    0.000  48.000
## - Age_of_RBC_unit                          1    0.000  48.000
## - Sex                                      1    0.000  48.000
## - Irradiation                              1    0.000  48.000
## - CPB                                      1    0.000  48.000
## - Age_days                                 1    0.000  48.000
## - Infusion_rate_hour_eTBV                  1    0.000  48.000
## - Pre_transfusion_K                        1    0.000  48.000
## - Weight                                   1    0.000  48.000
## - Intracranial_diso                        1    0.000  48.000
## - Cardiac_dysf                             1    0.000  48.000
## - Orthopedics                              1    0.000  48.000
## - Cr_at_transfusion                        1    0.000  48.000
## - Access                                   1    0.000  48.000
## - Prematurity                              1    0.000  48.000
## - Dialysis                                 1    0.000  48.000
## - Time_from_irradition_to_transfusion_min  1    0.000  48.000
## - Kidney_dysf                              1    0.000  48.000
## - Respiratory_dysf                         1    0.000  48.000
## <none>                                          0.000  50.000
## - RBC_Unit_type                            2   41.965  87.965
## - Anemia                                   1   43.131  91.131
## - tV_12_eTBV                               1   60.704 108.704
## 
## Step:  AIC=48
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     CPB + Prematurity + Dialysis + RBC_Unit_type + Age_of_RBC_unit + 
##     Irradiation + Washed + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Washed                                   1    0.000  46.000
## - Age_of_RBC_unit                          1    0.000  46.000
## - Sex                                      1    0.000  46.000
## - Irradiation                              1    0.000  46.000
## - CPB                                      1    0.000  46.000
## - Age_days                                 1    0.000  46.000
## - Infusion_rate_hour_eTBV                  1    0.000  46.000
## - Pre_transfusion_K                        1    0.000  46.000
## - Weight                                   1    0.000  46.000
## - Intracranial_diso                        1    0.000  46.000
## - Cardiac_dysf                             1    0.000  46.000
## - Orthopedics                              1    0.000  46.000
## - Cr_at_transfusion                        1    0.000  46.000
## - Access                                   1    0.000  46.000
## - Prematurity                              1    0.000  46.000
## - Dialysis                                 1    0.000  46.000
## - Time_from_irradition_to_transfusion_min  1    0.000  46.000
## - Kidney_dysf                              1    0.000  46.000
## - Respiratory_dysf                         1    0.000  46.000
## <none>                                          0.000  48.000
## - RBC_Unit_type                            2   42.808  86.808
## - Anemia                                   1   44.390  90.390
## - tV_12_eTBV                               1   60.711 106.711
## 
## Step:  AIC=46
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     CPB + Prematurity + Dialysis + RBC_Unit_type + Age_of_RBC_unit + 
##     Irradiation + tV_12_eTBV + Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Age_of_RBC_unit                          1    0.000  44.000
## - Sex                                      1    0.000  44.000
## - Irradiation                              1    0.000  44.000
## - CPB                                      1    0.000  44.000
## - Age_days                                 1    0.000  44.000
## - Infusion_rate_hour_eTBV                  1    0.000  44.000
## - Pre_transfusion_K                        1    0.000  44.000
## - Weight                                   1    0.000  44.000
## - Intracranial_diso                        1    0.000  44.000
## - Cardiac_dysf                             1    0.000  44.000
## - Orthopedics                              1    0.000  44.000
## - Cr_at_transfusion                        1    0.000  44.000
## - Dialysis                                 1    0.000  44.000
## - Access                                   1    0.000  44.000
## - Time_from_irradition_to_transfusion_min  1    0.000  44.000
## - Prematurity                              1    0.000  44.000
## - Kidney_dysf                              1    0.000  44.000
## - Respiratory_dysf                         1    0.000  44.000
## <none>                                          0.000  46.000
## - RBC_Unit_type                            2   43.297  85.297
## - Anemia                                   1   44.399  88.399
## - tV_12_eTBV                               1   62.367 106.367
## 
## Step:  AIC=44
## as.factor(TAH_occurrence) ~ Sex + Access + Age_days + Weight + 
##     Pre_transfusion_K + Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + 
##     Kidney_dysf + Intracranial_diso + Orthopedics + Anemia + 
##     CPB + Prematurity + Dialysis + RBC_Unit_type + Irradiation + 
##     tV_12_eTBV + Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Sex                                      1    0.000  42.000
## - CPB                                      1    0.000  42.000
## - Irradiation                              1    0.000  42.000
## - Age_days                                 1    0.000  42.000
## - Infusion_rate_hour_eTBV                  1    0.000  42.000
## - Pre_transfusion_K                        1    0.000  42.000
## - Intracranial_diso                        1    0.000  42.000
## - Weight                                   1    0.000  42.000
## - Orthopedics                              1    0.000  42.000
## - Cardiac_dysf                             1    0.000  42.000
## - Access                                   1    0.000  42.000
## - Cr_at_transfusion                        1    0.000  42.000
## - Time_from_irradition_to_transfusion_min  1    0.000  42.000
## - Dialysis                                 1    0.000  42.000
## - Respiratory_dysf                         1    0.000  42.000
## - Prematurity                              1    0.000  42.000
## - Kidney_dysf                              1    0.000  42.000
## <none>                                          0.000  44.000
## - RBC_Unit_type                            2   47.443  87.443
## - Anemia                                   1   46.692  88.692
## - tV_12_eTBV                               1   70.859 112.859
## 
## Step:  AIC=42
## as.factor(TAH_occurrence) ~ Access + Age_days + Weight + Pre_transfusion_K + 
##     Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + Kidney_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + CPB + Prematurity + 
##     Dialysis + RBC_Unit_type + Irradiation + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Irradiation                              1    0.000  40.000
## - CPB                                      1    0.000  40.000
## - Age_days                                 1    0.000  40.000
## - Pre_transfusion_K                        1    0.000  40.000
## - Weight                                   1    0.000  40.000
## - Infusion_rate_hour_eTBV                  1    0.000  40.000
## - Orthopedics                              1    0.000  40.000
## - Cardiac_dysf                             1    0.000  40.000
## - Cr_at_transfusion                        1    0.000  40.000
## - Intracranial_diso                        1    0.000  40.000
## - Access                                   1    0.000  40.000
## - Dialysis                                 1    0.000  40.000
## - Time_from_irradition_to_transfusion_min  1    0.000  40.000
## <none>                                          0.000  42.000
## - Prematurity                              1   16.250  56.250
## - Respiratory_dysf                         1   19.486  59.486
## - Kidney_dysf                              1   19.731  59.731
## - Anemia                                   1   46.706  86.706
## - RBC_Unit_type                            2   49.062  87.062
## - tV_12_eTBV                               1   73.650 113.650
## 
## Step:  AIC=40
## as.factor(TAH_occurrence) ~ Access + Age_days + Weight + Pre_transfusion_K + 
##     Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + Kidney_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + CPB + Prematurity + 
##     Dialysis + RBC_Unit_type + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - CPB                                      1     0.00  38.00
## - Age_days                                 1     0.00  38.00
## - Pre_transfusion_K                        1     0.00  38.00
## - Infusion_rate_hour_eTBV                  1     0.00  38.00
## - Intracranial_diso                        1     0.00  38.00
## - Orthopedics                              1     0.00  38.00
## - Weight                                   1     0.00  38.00
## - Cr_at_transfusion                        1     0.00  38.00
## - Dialysis                                 1     0.00  38.00
## - Access                                   1     0.00  38.00
## <none>                                           0.00  40.00
## - Cardiac_dysf                             1     6.69  44.69
## - Prematurity                              1    18.55  56.55
## - Kidney_dysf                              1    20.45  58.45
## - Respiratory_dysf                         1    21.41  59.41
## - Anemia                                   1    46.93  84.93
## - RBC_Unit_type                            2    49.08  85.08
## - tV_12_eTBV                               1    73.85 111.85
## - Time_from_irradition_to_transfusion_min  1   865.05 903.05
## 
## Step:  AIC=38
## as.factor(TAH_occurrence) ~ Access + Age_days + Weight + Pre_transfusion_K + 
##     Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + Kidney_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + Prematurity + 
##     Dialysis + RBC_Unit_type + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Age_days                                 1     0.00  36.00
## - Pre_transfusion_K                        1     0.00  36.00
## - Infusion_rate_hour_eTBV                  1     0.00  36.00
## - Intracranial_diso                        1     0.00  36.00
## - Orthopedics                              1     0.00  36.00
## - Cr_at_transfusion                        1     0.00  36.00
## - Dialysis                                 1     0.00  36.00
## - Cardiac_dysf                             1     0.00  36.00
## <none>                                           0.00  38.00
## - Prematurity                              1    19.39  55.39
## - Kidney_dysf                              1    20.49  56.49
## - Respiratory_dysf                         1    24.98  60.98
## - RBC_Unit_type                            2    49.11  83.11
## - Anemia                                   1    48.39  84.39
## - tV_12_eTBV                               1    77.79 113.79
## - Time_from_irradition_to_transfusion_min  1   360.44 396.44
## - Weight                                   1   865.05 901.05
## - Access                                   1   937.13 973.13
## 
## Step:  AIC=36
## as.factor(TAH_occurrence) ~ Access + Weight + Pre_transfusion_K + 
##     Cr_at_transfusion + Cardiac_dysf + Respiratory_dysf + Kidney_dysf + 
##     Intracranial_diso + Orthopedics + Anemia + Prematurity + 
##     Dialysis + RBC_Unit_type + tV_12_eTBV + Infusion_rate_hour_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance    AIC
## - Pre_transfusion_K                        1     0.00  34.00
## - Infusion_rate_hour_eTBV                  1     0.00  34.00
## - Intracranial_diso                        1     0.00  34.00
## - Orthopedics                              1     0.00  34.00
## - Weight                                   1     0.00  34.00
## - Cr_at_transfusion                        1     0.00  34.00
## - Time_from_irradition_to_transfusion_min  1     0.00  34.00
## <none>                                           0.00  36.00
## - Cardiac_dysf                             1    12.28  46.28
## - Prematurity                              1    20.15  54.15
## - Kidney_dysf                              1    22.07  56.07
## - Respiratory_dysf                         1    25.39  59.39
## - RBC_Unit_type                            2    49.20  81.20
## - Anemia                                   1    49.11  83.11
## - tV_12_eTBV                               1    78.63 112.63
## - Dialysis                                 1   576.70 610.70
## - Access                                   1   720.87 754.87
## 
## Step:  AIC=34
## as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Intracranial_diso + 
##     Orthopedics + Anemia + Prematurity + Dialysis + RBC_Unit_type + 
##     tV_12_eTBV + Infusion_rate_hour_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Infusion_rate_hour_eTBV                  1     0.00   32.00
## - Orthopedics                              1     0.00   32.00
## - Intracranial_diso                        1     0.00   32.00
## - Weight                                   1     0.04   32.04
## <none>                                           0.00   34.00
## - Cr_at_transfusion                        1    11.78   43.78
## - Access                                   1    12.08   44.08
## - Time_from_irradition_to_transfusion_min  1    12.23   44.23
## - Cardiac_dysf                             1    12.44   44.44
## - Prematurity                              1    20.78   52.78
## - Kidney_dysf                              1    24.46   56.46
## - Respiratory_dysf                         1    25.40   57.40
## - RBC_Unit_type                            2    50.11   80.11
## - Anemia                                   1    50.10   82.10
## - tV_12_eTBV                               1    79.83  111.83
## - Dialysis                                 1  1153.40 1185.40
## 
## Step:  AIC=32
## as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Intracranial_diso + 
##     Orthopedics + Anemia + Prematurity + Dialysis + RBC_Unit_type + 
##     tV_12_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Orthopedics                              1     0.00   30.00
## - Weight                                   1     0.00   30.00
## <none>                                           0.00   32.00
## - Time_from_irradition_to_transfusion_min  1    13.14   43.14
## - Cr_at_transfusion                        1    14.57   44.57
## - Access                                   1    14.97   44.97
## - Cardiac_dysf                             1    15.31   45.31
## - Dialysis                                 1    15.76   45.76
## - Prematurity                              1    21.04   51.04
## - Kidney_dysf                              1    27.38   57.38
## - Respiratory_dysf                         1    29.12   59.12
## - RBC_Unit_type                            2    50.38   78.38
## - Anemia                                   1    50.35   80.35
## - tV_12_eTBV                               1    87.28  117.28
## - Intracranial_diso                        1  1009.22 1039.22
## 
## Step:  AIC=30
## as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Intracranial_diso + 
##     Anemia + Prematurity + Dialysis + RBC_Unit_type + tV_12_eTBV + 
##     Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## - Intracranial_diso                        1    0.000  28.000
## <none>                                          0.000  30.000
## - Weight                                   1    9.442  37.442
## - Time_from_irradition_to_transfusion_min  1   14.967  42.967
## - Cr_at_transfusion                        1   15.806  43.806
## - Cardiac_dysf                             1   16.527  44.527
## - Access                                   1   17.528  45.528
## - Dialysis                                 1   17.631  45.631
## - Prematurity                              1   22.364  50.364
## - Kidney_dysf                              1   27.591  55.591
## - Respiratory_dysf                         1   29.502  57.502
## - RBC_Unit_type                            2   50.426  76.426
## - Anemia                                   1   51.521  79.521
## - tV_12_eTBV                               1   89.996 117.996
## 
## Step:  AIC=28
## as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Anemia + 
##     Prematurity + Dialysis + RBC_Unit_type + tV_12_eTBV + Time_from_irradition_to_transfusion_min
## 
##                                           Df Deviance     AIC
## <none>                                          0.000  28.000
## - Cardiac_dysf                             1   20.641  46.641
## - Time_from_irradition_to_transfusion_min  1   20.840  46.840
## - Cr_at_transfusion                        1   21.171  47.171
## - Dialysis                                 1   22.368  48.368
## - Weight                                   1   23.319  49.319
## - Access                                   1   24.496  50.496
## - Respiratory_dysf                         1   31.869  57.869
## - Prematurity                              1   35.940  61.940
## - Kidney_dysf                              1   39.583  65.583
## - RBC_Unit_type                            2   51.488  75.488
## - Anemia                                   1   57.356  83.356
## - tV_12_eTBV                               1   93.729 119.729
formula(backwards)
## as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Anemia + 
##     Prematurity + Dialysis + RBC_Unit_type + tV_12_eTBV + Time_from_irradition_to_transfusion_min
summary(backwards)
## 
## Call:
## glm(formula = as.factor(TAH_occurrence) ~ Access + Weight + Cr_at_transfusion + 
##     Cardiac_dysf + Respiratory_dysf + Kidney_dysf + Anemia + 
##     Prematurity + Dialysis + RBC_Unit_type + tV_12_eTBV + Time_from_irradition_to_transfusion_min, 
##     family = "binomial", data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##        Min          1Q      Median          3Q         Max  
## -2.277e-04  -2.100e-08  -2.100e-08   2.100e-08   2.150e-04  
## 
## Coefficients:
##                                           Estimate Std. Error z value Pr(>|z|)
## (Intercept)                             -1.070e+03  8.926e+04  -0.012    0.990
## Access2                                  1.823e+02  1.973e+04   0.009    0.993
## Weight                                   5.166e+00  6.385e+02   0.008    0.994
## Cr_at_transfusion                        1.038e+02  2.970e+04   0.003    0.997
## Cardiac_dysf2                           -1.914e+02  1.649e+04  -0.012    0.991
## Respiratory_dysf2                       -4.174e+02  3.395e+04  -0.012    0.990
## Kidney_dysf2                             3.051e+02  2.934e+04   0.010    0.992
## Anemia2                                 -6.487e+02  5.351e+04  -0.012    0.990
## Prematurity2                             3.307e+02  2.966e+04   0.011    0.991
## Dialysis2                               -4.551e+02  7.155e+04  -0.006    0.995
## RBC_Unit_type2                           6.421e+02  5.225e+04   0.012    0.990
## RBC_Unit_type3                           3.182e+02  1.743e+05   0.002    0.999
## tV_12_eTBV                               2.280e+03  1.861e+05   0.012    0.990
## Time_from_irradition_to_transfusion_min  1.702e-02  2.061e+00   0.008    0.993
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 1.2607e+02  on 94  degrees of freedom
## Residual deviance: 3.7847e-07  on 81  degrees of freedom
## AIC: 28
## 
## Number of Fisher Scoring iterations: 25
# Forward step model selection process
baseMod <- glm(as.factor(TAH_occurrence) ~ 1, data=df_TAH_data_impute_mean, family = "binomial")
forwards =  stats::step(baseMod, scope=list(lower=formula(baseMod), upper=formula(lm_full.fit)), direction="forward")
## Start:  AIC=128.07
## as.factor(TAH_occurrence) ~ 1
## 
##                                           Df Deviance    AIC
## + tV_12_eTBV                               1   98.627 102.63
## + tV_12_weight_ml_Kg                       1  101.516 105.52
## + Mortality1Day                            1  109.315 113.31
## + Kidney_dysf                              1  109.454 113.45
## + Age_of_RBC_unit                          1  117.696 121.70
## + Infusion_rate_hour_eTBV                  1  117.923 121.92
## + Liver_dysf                               1  118.425 122.42
## + Cr_at_transfusion                        1  119.436 123.44
## + Infusion_rate_hour_Pt_weight             1  120.292 124.29
## + Pre_transfusion_K                        1  120.998 125.00
## + Anemia                                   1  121.207 125.21
## + ECMO                                     1  122.688 126.69
## + Intracranial_diso                        1  122.688 126.69
## + Sepsis                                   1  122.694 126.69
## + Leukoreduction                           1  123.156 127.16
## + Group                                    4  117.309 127.31
## + Sex                                      1  123.594 127.59
## <none>                                        126.074 128.07
## + Hemoglobinopathy                         1  124.420 128.42
## + Dialysis                                 1  124.926 128.93
## + Age_days                                 1  124.933 128.93
## + CPB                                      1  125.019 129.02
## + RBC_Unit_type                            2  123.067 129.07
## + Respiratory_dysf                         1  125.077 129.08
## + Prematurity                              1  125.226 129.23
## + Weight                                   1  125.233 129.23
## + Access                                   1  125.287 129.29
## + Cardiac_dysf                             1  125.795 129.79
## + Plasma_reduction                         1  125.950 129.95
## + Time_from_irradition_to_transfusion_min  1  125.967 129.97
## + Irradiation                              1  125.993 129.99
## + Washed                                   1  126.046 130.05
## + Orthopedics                              1  126.064 130.06
## + Race                                     4  122.963 132.96
## 
## Step:  AIC=102.63
## as.factor(TAH_occurrence) ~ tV_12_eTBV
## 
##                                           Df Deviance     AIC
## + Kidney_dysf                              1   78.715  84.715
## + Pre_transfusion_K                        1   86.142  92.142
## + Mortality1Day                            1   89.816  95.816
## + Cr_at_transfusion                        1   90.296  96.296
## + RBC_Unit_type                            2   89.327  97.327
## + Age_of_RBC_unit                          1   93.450  99.450
## + Respiratory_dysf                         1   93.659  99.659
## + Liver_dysf                               1   93.781  99.781
## + Cardiac_dysf                             1   95.729 101.729
## + Anemia                                   1   96.274 102.274
## <none>                                         98.627 102.627
## + Leukoreduction                           1   96.768 102.768
## + Access                                   1   96.944 102.944
## + Dialysis                                 1   97.032 103.032
## + Hemoglobinopathy                         1   97.424 103.424
## + Sepsis                                   1   97.595 103.595
## + Sex                                      1   97.730 103.730
## + Prematurity                              1   97.747 103.747
## + Washed                                   1   97.778 103.778
## + CPB                                      1   97.918 103.918
## + tV_12_weight_ml_Kg                       1   97.927 103.927
## + Irradiation                              1   97.998 103.998
## + Intracranial_diso                        1   98.005 104.005
## + Plasma_reduction                         1   98.040 104.040
## + Infusion_rate_hour_eTBV                  1   98.109 104.109
## + Infusion_rate_hour_Pt_weight             1   98.226 104.226
## + Orthopedics                              1   98.293 104.293
## + Time_from_irradition_to_transfusion_min  1   98.358 104.358
## + Weight                                   1   98.398 104.398
## + Age_days                                 1   98.621 104.621
## + ECMO                                     1   98.626 104.626
## + Group                                    4   93.955 105.955
## + Race                                     4   97.308 109.308
## 
## Step:  AIC=84.71
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf
## 
##                                           Df Deviance    AIC
## + Cardiac_dysf                             1   72.605 80.605
## + Respiratory_dysf                         1   73.259 81.259
## + RBC_Unit_type                            2   72.094 82.094
## + Mortality1Day                            1   75.010 83.010
## + Pre_transfusion_K                        1   75.328 83.328
## + Anemia                                   1   75.354 83.354
## + Age_of_RBC_unit                          1   75.905 83.905
## + Washed                                   1   76.651 84.651
## <none>                                         78.715 84.715
## + Liver_dysf                               1   77.451 85.451
## + Dialysis                                 1   77.656 85.656
## + Sex                                      1   77.658 85.658
## + tV_12_weight_ml_Kg                       1   77.816 85.816
## + Leukoreduction                           1   77.854 85.854
## + Prematurity                              1   77.966 85.966
## + Time_from_irradition_to_transfusion_min  1   77.997 85.997
## + Irradiation                              1   78.096 86.096
## + Weight                                   1   78.139 86.139
## + Access                                   1   78.145 86.145
## + Age_days                                 1   78.255 86.255
## + CPB                                      1   78.407 86.407
## + Plasma_reduction                         1   78.425 86.425
## + ECMO                                     1   78.430 86.430
## + Cr_at_transfusion                        1   78.449 86.449
## + Infusion_rate_hour_eTBV                  1   78.459 86.459
## + Infusion_rate_hour_Pt_weight             1   78.503 86.503
## + Sepsis                                   1   78.664 86.664
## + Intracranial_diso                        1   78.676 86.676
## + Hemoglobinopathy                         1   78.701 86.701
## + Orthopedics                              1   78.714 86.714
## + Group                                    4   73.931 87.931
## + Race                                     4   77.340 91.340
## 
## Step:  AIC=80.61
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf
## 
##                                           Df Deviance    AIC
## + Anemia                                   1   67.458 77.458
## + Age_of_RBC_unit                          1   68.348 78.348
## + RBC_Unit_type                            2   66.844 78.844
## + Respiratory_dysf                         1   69.559 79.559
## + Washed                                   1   69.854 79.854
## + Pre_transfusion_K                        1   70.111 80.111
## + Mortality1Day                            1   70.580 80.580
## <none>                                         72.605 80.605
## + Dialysis                                 1   71.100 81.100
## + Sex                                      1   71.446 81.446
## + Prematurity                              1   71.853 81.853
## + Leukoreduction                           1   71.868 81.868
## + Time_from_irradition_to_transfusion_min  1   71.993 81.993
## + Liver_dysf                               1   72.032 82.032
## + Access                                   1   72.067 82.067
## + tV_12_weight_ml_Kg                       1   72.076 82.076
## + Irradiation                              1   72.362 82.362
## + Weight                                   1   72.379 82.379
## + Age_days                                 1   72.384 82.384
## + Intracranial_diso                        1   72.388 82.388
## + CPB                                      1   72.512 82.512
## + Cr_at_transfusion                        1   72.524 82.524
## + Sepsis                                   1   72.540 82.540
## + Hemoglobinopathy                         1   72.560 82.560
## + Infusion_rate_hour_Pt_weight             1   72.562 82.562
## + Infusion_rate_hour_eTBV                  1   72.562 82.562
## + ECMO                                     1   72.570 82.570
## + Plasma_reduction                         1   72.572 82.572
## + Orthopedics                              1   72.603 82.603
## + Group                                    4   68.535 84.535
## + Race                                     4   71.688 87.688
## 
## Step:  AIC=77.46
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia
## 
##                                           Df Deviance    AIC
## + RBC_Unit_type                            2   50.436 64.436
## + Respiratory_dysf                         1   62.694 74.694
## + Washed                                   1   63.078 75.078
## + Age_of_RBC_unit                          1   64.100 76.100
## + Pre_transfusion_K                        1   64.592 76.592
## + Age_days                                 1   64.840 76.840
## + Weight                                   1   64.912 76.912
## <none>                                         67.458 77.458
## + Mortality1Day                            1   65.922 77.922
## + Time_from_irradition_to_transfusion_min  1   66.178 78.178
## + Liver_dysf                               1   66.233 78.233
## + Dialysis                                 1   66.330 78.330
## + Access                                   1   66.454 78.454
## + Sex                                      1   66.662 78.662
## + Leukoreduction                           1   67.060 79.060
## + Prematurity                              1   67.124 79.124
## + Infusion_rate_hour_Pt_weight             1   67.292 79.292
## + tV_12_weight_ml_Kg                       1   67.331 79.331
## + Hemoglobinopathy                         1   67.343 79.343
## + ECMO                                     1   67.344 79.344
## + Infusion_rate_hour_eTBV                  1   67.347 79.347
## + CPB                                      1   67.406 79.406
## + Intracranial_diso                        1   67.408 79.408
## + Orthopedics                              1   67.428 79.428
## + Sepsis                                   1   67.444 79.444
## + Plasma_reduction                         1   67.446 79.446
## + Irradiation                              1   67.448 79.448
## + Cr_at_transfusion                        1   67.454 79.454
## + Group                                    4   61.809 79.809
## + Race                                     4   66.416 84.416
## 
## Step:  AIC=64.44
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type
## 
##                                           Df Deviance    AIC
## + Respiratory_dysf                         1   43.685 59.685
## + Age_days                                 1   45.119 61.119
## + Weight                                   1   45.682 61.682
## + Pre_transfusion_K                        1   47.260 63.260
## + Group                                    4   41.531 63.531
## + Intracranial_diso                        1   48.071 64.071
## <none>                                         50.436 64.436
## + Time_from_irradition_to_transfusion_min  1   48.465 64.465
## + ECMO                                     1   48.685 64.685
## + Infusion_rate_hour_Pt_weight             1   48.715 64.715
## + Access                                   1   49.142 65.142
## + Infusion_rate_hour_eTBV                  1   49.220 65.220
## + Mortality1Day                            1   49.498 65.498
## + Liver_dysf                               1   49.511 65.511
## + Washed                                   1   49.752 65.752
## + Orthopedics                              1   49.754 65.754
## + Prematurity                              1   49.822 65.822
## + Irradiation                              1   50.029 66.029
## + Leukoreduction                           1   50.058 66.058
## + Cr_at_transfusion                        1   50.092 66.092
## + CPB                                      1   50.181 66.181
## + Sepsis                                   1   50.210 66.210
## + Dialysis                                 1   50.245 66.245
## + Sex                                      1   50.290 66.290
## + Hemoglobinopathy                         1   50.420 66.420
## + Age_of_RBC_unit                          1   50.421 66.421
## + tV_12_weight_ml_Kg                       1   50.428 66.428
## + Plasma_reduction                         1   50.434 66.434
## + Race                                     4   48.845 70.845
## 
## Step:  AIC=59.69
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf
## 
##                                           Df Deviance    AIC
## + Intracranial_diso                        1   32.537 50.537
## + Prematurity                              1   37.073 55.073
## + Pre_transfusion_K                        1   38.378 56.378
## + tV_12_weight_ml_Kg                       1   39.889 57.889
## + Mortality1Day                            1   40.586 58.586
## + Group                                    4   35.530 59.530
## + ECMO                                     1   41.682 59.682
## <none>                                         43.685 59.685
## + Age_days                                 1   41.918 59.918
## + Washed                                   1   42.030 60.030
## + Weight                                   1   42.185 60.185
## + Orthopedics                              1   42.549 60.549
## + Infusion_rate_hour_eTBV                  1   42.573 60.573
## + Dialysis                                 1   42.682 60.682
## + Infusion_rate_hour_Pt_weight             1   42.692 60.692
## + Access                                   1   42.889 60.889
## + Time_from_irradition_to_transfusion_min  1   42.938 60.938
## + Liver_dysf                               1   43.066 61.066
## + Sepsis                                   1   43.152 61.152
## + Age_of_RBC_unit                          1   43.271 61.271
## + Irradiation                              1   43.420 61.420
## + Hemoglobinopathy                         1   43.483 61.483
## + Sex                                      1   43.485 61.485
## + Leukoreduction                           1   43.539 61.539
## + Cr_at_transfusion                        1   43.619 61.619
## + Plasma_reduction                         1   43.681 61.681
## + CPB                                      1   43.682 61.682
## + Race                                     4   43.203 67.203
## 
## Step:  AIC=50.54
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso
## 
##                                           Df Deviance    AIC
## + Orthopedics                              1   28.965 48.965
## + Access                                   1   30.233 50.233
## + Age_days                                 1   30.319 50.319
## + Weight                                   1   30.363 50.363
## + Group                                    4   24.513 50.513
## <none>                                         32.537 50.537
## + Prematurity                              1   30.627 50.627
## + Pre_transfusion_K                        1   31.269 51.269
## + Hemoglobinopathy                         1   31.597 51.597
## + Liver_dysf                               1   31.641 51.641
## + Irradiation                              1   31.833 51.833
## + Time_from_irradition_to_transfusion_min  1   31.838 51.838
## + Cr_at_transfusion                        1   31.869 51.869
## + Mortality1Day                            1   31.961 51.961
## + Washed                                   1   32.047 52.047
## + tV_12_weight_ml_Kg                       1   32.131 52.131
## + Sex                                      1   32.197 52.197
## + ECMO                                     1   32.291 52.291
## + Dialysis                                 1   32.305 52.305
## + Sepsis                                   1   32.409 52.409
## + Leukoreduction                           1   32.440 52.440
## + CPB                                      1   32.457 52.457
## + Age_of_RBC_unit                          1   32.530 52.530
## + Infusion_rate_hour_Pt_weight             1   32.531 52.531
## + Plasma_reduction                         1   32.537 52.537
## + Infusion_rate_hour_eTBV                  1   32.537 52.537
## + Race                                     4   31.194 57.194
## 
## Step:  AIC=48.96
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics
## 
##                                           Df Deviance    AIC
## + Prematurity                              1   26.204 48.204
## <none>                                         28.965 48.965
## + Liver_dysf                               1   27.450 49.450
## + Access                                   1   27.457 49.457
## + Weight                                   1   27.672 49.672
## + Pre_transfusion_K                        1   27.841 49.841
## + Sex                                      1   27.881 49.881
## + Age_days                                 1   27.992 49.993
## + Mortality1Day                            1   28.267 50.267
## + Cr_at_transfusion                        1   28.291 50.291
## + tV_12_weight_ml_Kg                       1   28.293 50.293
## + Hemoglobinopathy                         1   28.417 50.417
## + Washed                                   1   28.462 50.462
## + Irradiation                              1   28.571 50.571
## + Group                                    4   22.736 50.736
## + Sepsis                                   1   28.739 50.739
## + Dialysis                                 1   28.747 50.747
## + ECMO                                     1   28.779 50.779
## + Time_from_irradition_to_transfusion_min  1   28.817 50.817
## + Age_of_RBC_unit                          1   28.820 50.820
## + CPB                                      1   28.886 50.886
## + Leukoreduction                           1   28.909 50.909
## + Infusion_rate_hour_Pt_weight             1   28.920 50.920
## + Infusion_rate_hour_eTBV                  1   28.921 50.921
## + Plasma_reduction                         1   28.965 50.965
## + Race                                     4   25.385 53.385
## 
## Step:  AIC=48.2
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity
## 
##                                           Df Deviance    AIC
## + Weight                                   1   21.152 45.152
## + Age_days                                 1   21.492 45.492
## + Access                                   1   22.861 46.861
## <none>                                         26.204 48.204
## + Group                                    4   18.480 48.480
## + Liver_dysf                               1   24.933 48.933
## + Cr_at_transfusion                        1   25.000 49.000
## + Mortality1Day                            1   25.213 49.213
## + Infusion_rate_hour_Pt_weight             1   25.302 49.302
## + Pre_transfusion_K                        1   25.376 49.376
## + Infusion_rate_hour_eTBV                  1   25.562 49.562
## + Time_from_irradition_to_transfusion_min  1   25.572 49.572
## + Sex                                      1   25.688 49.688
## + Sepsis                                   1   25.791 49.791
## + Washed                                   1   25.815 49.815
## + Hemoglobinopathy                         1   26.020 50.020
## + Age_of_RBC_unit                          1   26.054 50.054
## + ECMO                                     1   26.108 50.107
## + Dialysis                                 1   26.136 50.136
## + Irradiation                              1   26.145 50.145
## + CPB                                      1   26.149 50.149
## + Leukoreduction                           1   26.177 50.177
## + tV_12_weight_ml_Kg                       1   26.197 50.197
## + Plasma_reduction                         1   26.203 50.203
## + Race                                     4   24.649 54.649
## 
## Step:  AIC=45.15
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity + Weight
## 
##                                           Df Deviance    AIC
## + Access                                   1   16.148 42.148
## + Infusion_rate_hour_Pt_weight             1   18.046 44.046
## + Infusion_rate_hour_eTBV                  1   18.451 44.451
## <none>                                         21.152 45.152
## + Liver_dysf                               1   19.523 45.523
## + Cr_at_transfusion                        1   20.458 46.458
## + Pre_transfusion_K                        1   20.465 46.465
## + Time_from_irradition_to_transfusion_min  1   20.519 46.519
## + Sex                                      1   20.559 46.559
## + Mortality1Day                            1   20.624 46.624
## + Age_of_RBC_unit                          1   20.930 46.930
## + Washed                                   1   20.991 46.991
## + Sepsis                                   1   21.002 47.002
## + Hemoglobinopathy                         1   21.113 47.112
## + ECMO                                     1   21.114 47.114
## + CPB                                      1   21.133 47.133
## + tV_12_weight_ml_Kg                       1   21.145 47.146
## + Dialysis                                 1   21.151 47.151
## + Leukoreduction                           1   21.151 47.151
## + Irradiation                              1   21.152 47.152
## + Age_days                                 1   21.152 47.152
## + Plasma_reduction                         1   21.152 47.152
## + Race                                     4   15.464 47.464
## + Group                                    4   18.006 50.006
## 
## Step:  AIC=42.15
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity + Weight + Access
## 
##                                           Df Deviance    AIC
## + Infusion_rate_hour_eTBV                  1    13.81  41.81
## + Infusion_rate_hour_Pt_weight             1    13.86  41.86
## <none>                                          16.15  42.15
## + Dialysis                                 1    15.37  43.37
## + Age_of_RBC_unit                          1    15.37  43.37
## + Liver_dysf                               1    15.61  43.61
## + Time_from_irradition_to_transfusion_min  1    15.91  43.91
## + Irradiation                              1    15.92  43.92
## + Mortality1Day                            1    16.05  44.05
## + Cr_at_transfusion                        1    16.06  44.06
## + Sepsis                                   1    16.09  44.09
## + Hemoglobinopathy                         1    16.09  44.09
## + tV_12_weight_ml_Kg                       1    16.10  44.10
## + Pre_transfusion_K                        1    16.11  44.11
## + Washed                                   1    16.12  44.12
## + ECMO                                     1    16.13  44.13
## + Age_days                                 1    16.14  44.14
## + CPB                                      1    16.15  44.15
## + Plasma_reduction                         1    16.15  44.15
## + Leukoreduction                           1    16.15  44.15
## + Race                                     4    13.87  47.87
## + Group                                    4    15.66  49.66
## + Sex                                      1   865.05 893.05
## 
## Step:  AIC=41.81
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity + Weight + Access + Infusion_rate_hour_eTBV
## 
##                                           Df Deviance    AIC
## + Sex                                      1   0.0000 30.000
## + Pre_transfusion_K                        1  10.7276 40.728
## + Time_from_irradition_to_transfusion_min  1  11.7763 41.776
## <none>                                        13.8146 41.815
## + Age_of_RBC_unit                          1  12.5904 42.590
## + Liver_dysf                               1  12.7831 42.783
## + Irradiation                              1  13.2617 43.262
## + Cr_at_transfusion                        1  13.4501 43.450
## + tV_12_weight_ml_Kg                       1  13.5202 43.520
## + Age_days                                 1  13.5458 43.546
## + Hemoglobinopathy                         1  13.7692 43.769
## + CPB                                      1  13.7826 43.783
## + Dialysis                                 1  13.7854 43.785
## + ECMO                                     1  13.7929 43.793
## + Infusion_rate_hour_Pt_weight             1  13.8085 43.808
## + Washed                                   1  13.8108 43.811
## + Mortality1Day                            1  13.8117 43.812
## + Sepsis                                   1  13.8146 43.815
## + Plasma_reduction                         1  13.8146 43.815
## + Leukoreduction                           1  13.8146 43.815
## + Race                                     4   8.5957 44.596
## + Group                                    4  12.8173 48.817
## 
## Step:  AIC=30
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity + Weight + Access + Infusion_rate_hour_eTBV + 
##     Sex
## 
##                                           Df Deviance    AIC
## <none>                                            0.0   30.0
## + Age_of_RBC_unit                          1      0.0   32.0
## + Irradiation                              1      0.0   32.0
## + Pre_transfusion_K                        1      0.0   32.0
## + Cr_at_transfusion                        1      0.0   32.0
## + Dialysis                                 1      0.0   32.0
## + ECMO                                     1      0.0   32.0
## + CPB                                      1      0.0   32.0
## + Hemoglobinopathy                         1      0.0   32.0
## + Sepsis                                   1      0.0   32.0
## + Plasma_reduction                         1      0.0   32.0
## + Leukoreduction                           1      0.0   32.0
## + Washed                                   1      0.0   32.0
## + Mortality1Day                            1      0.0   32.0
## + Race                                     4      0.0   38.0
## + Group                                    4      0.0   38.0
## + Time_from_irradition_to_transfusion_min  1    576.7  608.7
## + Liver_dysf                               1    720.9  752.9
## + Age_days                                 1    865.0  897.0
## + Infusion_rate_hour_Pt_weight             1   1225.5 1257.5
## + tV_12_weight_ml_Kg                       1   3390.6 3422.6
formula(forwards)
## as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + Cardiac_dysf + 
##     Anemia + RBC_Unit_type + Respiratory_dysf + Intracranial_diso + 
##     Orthopedics + Prematurity + Weight + Access + Infusion_rate_hour_eTBV + 
##     Sex
summary(forwards)
## 
## Call:
## glm(formula = as.factor(TAH_occurrence) ~ tV_12_eTBV + Kidney_dysf + 
##     Cardiac_dysf + Anemia + RBC_Unit_type + Respiratory_dysf + 
##     Intracranial_diso + Orthopedics + Prematurity + Weight + 
##     Access + Infusion_rate_hour_eTBV + Sex, family = "binomial", 
##     data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##        Min          1Q      Median          3Q         Max  
## -4.844e-04  -2.000e-08  -2.000e-08   2.000e-08   3.862e-04  
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)
## (Intercept)               -2771.98  136568.26  -0.020    0.984
## tV_12_eTBV                 5528.03  273482.73   0.020    0.984
## Kidney_dysf2                603.59   32060.88   0.019    0.985
## Cardiac_dysf2             -1234.85 1534899.83  -0.001    0.999
## Anemia2                   -1743.08   86202.48  -0.020    0.984
## RBC_Unit_type2             1675.58   82332.37   0.020    0.984
## RBC_Unit_type3              647.35  169521.48   0.004    0.997
## Respiratory_dysf2          -698.78   36519.57  -0.019    0.985
## Intracranial_diso2          646.63 1532717.06   0.000    1.000
## Orthopedics2                309.36   23306.62   0.013    0.989
## Prematurity2                805.95   39588.73   0.020    0.984
## Weight                       18.87     933.40   0.020    0.984
## Access2                     480.68   24090.86   0.020    0.984
## Infusion_rate_hour_eTBV    -760.83   70586.62  -0.011    0.991
## Sex2                        331.83   17147.07   0.019    0.985
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 1.2607e+02  on 94  degrees of freedom
## Residual deviance: 1.1911e-06  on 80  degrees of freedom
## AIC: 30
## 
## Number of Fisher Scoring iterations: 25
# Other Models
lm.fit <- glm(as.factor(Mortality1Day) ~ Age_days + Irradiation, # + Time_from_irradition_to_transfusion_min + tV_12_eTBV, 
              data=df_TAH_data_impute_mean, family = "binomial")
summary(lm.fit)
## 
## Call:
## glm(formula = as.factor(Mortality1Day) ~ Age_days + Irradiation, 
##     family = "binomial", data = df_TAH_data_impute_mean)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.5095  -0.4988  -0.4291  -0.2883   2.5731  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)   
## (Intercept)  -2.1247321  0.7927310  -2.680  0.00736 **
## Age_days     -0.0002729  0.0002413  -1.131  0.25803   
## Irradiation2  0.1486727  0.8582696   0.173  0.86248   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 54.898  on 94  degrees of freedom
## Residual deviance: 53.202  on 92  degrees of freedom
## AIC: 59.202
## 
## Number of Fisher Scoring iterations: 6
coef.lm.fit <- coef(lm.fit)

### Reparameterize the 2D (x,y) grid, and define the corresponding model values z on the grid
# x.seq <- seq(min(x),max(x),length.out=100)
# y.seq <- seq(min(y),max(y),length.out=100)
# z.seq <- function(x,y) coef.lm.fit[1]+coef.lm.fit[2]*x+coef.lm.fit[3]*y
# # define the values of z = z(x.seq, y.seq), as a Matrix of dimension c(dim(x.seq), dim(y.seq))
# z <- t(outer(x.seq, y.seq, z.seq))
# 
# #Setup Axis
# axis_x <- seq(min(x), max(x), length.out=100)
# axis_y <- seq(min(y), max(y), length.out=100)
# 
# #Sample points
# library(reshape2)
# lm_surface <- expand.grid(x = axis_x, y = axis_y, KEEP.OUT.ATTRS = F)
# lm_surface$z <- predict.lm(lm.fit, newdata = lm_surface)
# lm_surface <- acast(lm_surface, x ~ y, value.var = "z") # z ~ 0 + x + y
# 
# plot_ly(myDF, x = ~x, y = ~y, z = ~z,
#         text = df_TAH_data_impute_mean$TAH_Occurrence, type="scatter3d", mode="markers",
#         color=df_TAH_data_impute_mean$Mortality1Day) %>%
#   add_trace(x=~axis_x, y=~axis_y, z=~lm_surface, type="surface", color="gray", name="LM model", opacity=0.3) %>%
#   layout(title="3D Plane Regression (Infusion_rate_hour ~ Age_days + eTBV); Color=Mortality", showlegend = F,
#          scene = list ( xaxis = list(title = "Age_days"),
#                         yaxis = list(title = "eTBV"),
#                         zaxis = list(title = "Infusion_rate_hour"))) %>% 
#   hide_colorbar()

9 Non-linear Dimensionality Reduction

9.1 2D t-SNE

library(Rtsne)
execTime_tSNE <- system.time(tsne_digits <- Rtsne(df_TAH_data_impute_mean, dims = 2, perplexity=7, 
                                                  check_duplicates = FALSE, verbose=TRUE, max_iter = 500))
## Performing PCA
## Read the 95 x 42 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 7.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.00 seconds (sparsity = 0.308033)!
## Learning embedding...
## Iteration 50: error is 57.417063 (50 iterations in 0.00 seconds)
## Iteration 100: error is 57.096917 (50 iterations in 0.00 seconds)
## Iteration 150: error is 55.922942 (50 iterations in 0.00 seconds)
## Iteration 200: error is 52.954287 (50 iterations in 0.00 seconds)
## Iteration 250: error is 54.233427 (50 iterations in 0.00 seconds)
## Iteration 300: error is 1.540796 (50 iterations in 0.00 seconds)
## Iteration 350: error is 0.540761 (50 iterations in 0.00 seconds)
## Iteration 400: error is 0.235010 (50 iterations in 0.00 seconds)
## Iteration 450: error is 0.189666 (50 iterations in 0.00 seconds)
## Iteration 500: error is 0.179151 (50 iterations in 0.00 seconds)
## Fitting performed in 0.04 seconds.
execTime_tSNE
##    user  system elapsed 
##    0.05    0.00    0.05
# 2D t-SNE Plot
df <- data.frame(tsne_digits$Y, colors=df_TAH_data_impute_mean$TAH_occurrence)
df$col2 <- ifelse(df$colors==1, "green", "red") # map binary color to green (control) or red (patient)

plot_ly(df, x = ~X1, y = ~X2, type="scatter", mode = 'markers', color=~colors,
        name=paste0("Case: ", rownames(df_TAH_data_impute_mean)),
        marker=list(color = ~col2, 
                    size=5*as.numeric(df_TAH_data_impute_mean$Group))) %>%
  layout(title = "t-SNE 2D Embedding (Color=TAH; Size=Group)", xaxis = list(title = ""),  yaxis = list(title = "")) %>%
  hide_colorbar() %>% hide_legend()
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

9.2 3D t-SNE

execTime_tSNE <- system.time(tsne_digits3D <- Rtsne(df_TAH_data_impute_mean, dims = 3, perplexity=10, 
                                                    verbose=TRUE, max_iter = 500)); execTime_tSNE
## Performing PCA
## Read the 95 x 42 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 3, perplexity = 10.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.00 seconds (sparsity = 0.439889)!
## Learning embedding...
## Iteration 50: error is 51.722068 (50 iterations in 0.01 seconds)
## Iteration 100: error is 53.824599 (50 iterations in 0.01 seconds)
## Iteration 150: error is 53.630193 (50 iterations in 0.01 seconds)
## Iteration 200: error is 50.524562 (50 iterations in 0.01 seconds)
## Iteration 250: error is 52.212905 (50 iterations in 0.01 seconds)
## Iteration 300: error is 1.100251 (50 iterations in 0.00 seconds)
## Iteration 350: error is 0.370685 (50 iterations in 0.00 seconds)
## Iteration 400: error is 0.175874 (50 iterations in 0.00 seconds)
## Iteration 450: error is 0.147498 (50 iterations in 0.00 seconds)
## Iteration 500: error is 0.143203 (50 iterations in 0.00 seconds)
## Fitting performed in 0.06 seconds.
##    user  system elapsed 
##    0.08    0.00    0.07
df3D <- data.frame(tsne_digits3D$Y, colors=df_TAH_data_impute_mean$TAH_occurrence)
df3D$col2 <- ifelse(df3D$colors==1, "green", "red") # map binary color to green (control) or red (patient)

plot_ly(df3D, x = ~df3D[, 1], y = ~df3D[, 2], z= ~df3D[, 3], type="scatter3d",  mode = 'markers',
        color=~col2, name=paste0("Case: ", rownames(df_TAH_data_impute_mean)),
        marker=list(color = ~col2, 
                    size=5*as.numeric(df_TAH_data_impute_mean$Group))) %>%
  layout(title = "t-SNE 3D Embedding", 
         scene = list(xaxis = list(title=""),  yaxis=list(title=""), zaxis=list(title=""))) %>%
  hide_colorbar() %>% hide_legend()
df <- as.data.frame(df_TAH_data_impute_mean)

9.3 UMAP

library(plotly)
# install.packages('umap')
library(umap)
# 
# # Specify the input data 
# umapData <- iris[ , 1:4]
# umapLabels <- iris[ , 5]
# 
# # UMAP projection in 2D
# umapData.umap <- umap(umapData)   # exclude the iris 3-class labels
# 
# # Using Python through R-reticulate interface
# # library(reticulate)
# # iris.umap_learn <- umap(umapData, method="umap-learn")
# 
# # Plot UMAP reduction in 2D
# plot(umapData.umap$layout, col=as.factor(umapLabels))

# https://rdrr.io/cran/umap/man/umap.defaults.html
custom.settings = umap.defaults
custom.settings$n_neighbors = 5
custom.settings$n_components=3
# custom.settings
df_TAH_data_impute_meanNum <- as.data.frame(lapply(df_TAH_data_impute_mean , as.numeric))
execTime_UMAP <- system.time(umap_digits3D <- umap(df_TAH_data_impute_meanNum, umap.config=custom.settings)); execTime_UMAP
##    user  system elapsed 
##    0.29    0.03    0.32
cols <- palette(rainbow(10)) 

# 2D UMAP Plot
dfUMAP <- data.frame(umap_digits3D$layout, colors=df_TAH_data_impute_mean$TAH_occurrence)
dfUMAP$col2 <- ifelse(dfUMAP$colors==1, "green", "red") # map binary color to green (control) or red (patient)

plot_ly(dfUMAP, x = ~X1, y = ~X2, type="scatter",  mode = 'markers',
        color=~col2, name=paste0("Case: ", rownames(df_TAH_data_impute_mean)),
        marker=list(color = ~col2, #as.factor(colors), 
                    size=5*as.numeric(df_TAH_data_impute_mean$Group))) %>%
  layout(title="UMAP (40D->2D) Embedding", xaxis = list(title = ""),  yaxis = list(title = "")) %>%
  hide_colorbar() %>% hide_legend()

Use UMAP to predict TAH binary label.

umapData_Pred <- predict(umap_digits3D, df_TAH_data_impute_meanNum)  # mind transpose of data (case * Feature)
# train.labels.colors <- colMap(train.labels)

# 2D UMAP Plot
dfUMAP <- data.frame(x=umap_digits3D$layout[, 1], y=umap_digits3D$layout[, 2],
                     col=as.factor(df_TAH_data_impute_mean$TAH_occurrence), 
                     text = df_TAH_data_impute_mean$TAH_occurrence,
                     predX = umapData_Pred[ , 1], predY=umapData_Pred[ , 2])
dfUMAP$col2 <- ifelse(dfUMAP$col==1, "green", "red") # map binary color to green (control) or red (patient)

plot_ly(dfUMAP) %>%
    add_text(x = ~x, y = ~y, mode = 'text', name="Observed", text=text, 
             textfont=list(color=~col2, size=15), showlegend=F) %>%
    # Add training data UMAP projection scatter Digits
    # add_text(text=text, textfont=list(color=~col, size=15), showlegend=F) %>%
    add_markers(x=~predX, y=~predY,  name ="Predicted", marker = list(color=~col2)) %>%
    layout(title="UMAP Prediction: Projection of TAH using the training Data", 
           xaxis = list(title = ""),  yaxis = list(title = ""))
dfUMAP <- data.frame(x=umap_digits3D$layout[, 1], y=umap_digits3D$layout[, 2],
                     col=as.factor(df_TAH_data_impute_mean$TAH_occurrence), textLbl = df_TAH_data_impute_mean$TAH_occurrence,
                     predX = umapData_Pred[ , 1], predY=umapData_Pred[ , 2])

dfUMAP$col2 <- ifelse(dfUMAP$col==1, "green", "red") # map binary color to green (control) or red (patient)

plot_ly(dfUMAP, x = ~x, y = ~y, mode = 'text', name="Observed") %>%
    # Add training data UMAP projection scatter Digits
    add_text(text=~textLbl, textfont=list(color=~col2, size=15)) %>%
    add_markers(x=~predX, y=~predY,  name ="Predicted", marker=list(color=~col2, size=15, opacity=0.5)) %>%
    layout(title="UMAP TAH Prediction: Projection of Controls (green) and Patients (red) using the training Data",
           xaxis = list(title = ""),  yaxis = list(title = ""))

10 Regularized Linear Model Prediction

Specify the predictors (\(X\)) and the outcomes (\(Y\)).

y_TAH       <- df_TAH_data_impute_meanNum$TAH_occurrence
y_Mortality <- df_TAH_data_impute_meanNum$Mortality1Day

y_Mortality <- ifelse(as.numeric(y_Mortality) > 1, "2", "1")

X <- select(df_TAH_data_impute_meanNum, -c(TAH_occurrence, Mortality1Day)) 
dim(X)  # [1] 95 34
## [1] 95 32

10.1 Ridge and LASSO Regularized LM

10.1.1 Model TAH

library("glmnet")
library(doParallel)
cl <- makePSOCKcluster(6)
registerDoParallel(cl); getDoParWorkers()
## [1] 6
cv.ridge <-  cv.glmnet(x=as.matrix(X), y=as.factor(y_TAH), type.measure="mse", alpha=0, parallel=T, family="binomial")
## alpha =1 for lasso only, alpha = 0 for ridge only, and 0<alpha<1 to blend ridge & lasso penalty !!!!

# plot(cv.ridge)

plotCV.glmnet <- function(cv.glmnet.object, name="") {
  df <- as.data.frame(cbind(x=log(cv.glmnet.object$lambda), y=cv.glmnet.object$cvm, 
                           errorBar=cv.glmnet.object$cvsd), nzero=cv.glmnet.object$nzero)

  featureNum <- cv.glmnet.object$nzero
  xFeature <- log(cv.glmnet.object$lambda)
  yFeature <- max(cv.glmnet.object$cvm)+max(cv.glmnet.object$cvsd)
  dataFeature <- data.frame(featureNum, xFeature, yFeature)

  plot_ly(data = df) %>%
    # add error bars for each CV-mean at log(lambda)
    add_trace(x = ~x, y = ~y, type = 'scatter', mode = 'markers',
        name = 'CV MSE', error_y = ~list(array = errorBar)) %>% 
    # add the lambda-min and lambda 1SD vertical dash lines
    add_lines(data=df, x=c(log(cv.glmnet.object$lambda.min), log(cv.glmnet.object$lambda.min)), 
              y=c(min(cv.glmnet.object$cvm)-max(df$errorBar), max(cv.glmnet.object$cvm)+max(df$errorBar)),
              showlegend=F, line=list(dash="dash"), name="lambda.min", mode = 'lines+markers') %>%
    add_lines(data=df, x=c(log(cv.glmnet.object$lambda.1se), log(cv.glmnet.object$lambda.1se)), 
              y=c(min(cv.glmnet.object$cvm)-max(df$errorBar), max(cv.glmnet.object$cvm)+max(df$errorBar)), 
              showlegend=F, line=list(dash="dash"), name="lambda.1se") %>%
    # Add Number of Features Annotations on Top
    add_trace(dataFeature, x = ~xFeature, y = ~yFeature, type = 'scatter', name="Number of Features",
        mode = 'text', text = ~featureNum, textposition = 'middle right',
        textfont = list(color = '#000000', size = 9)) %>%
    # Add top x-axis (non-zero features)
    # add_trace(data=df, x=~c(min(cv.glmnet.object$nzero),max(cv.glmnet.object$nzero)),
    #           y=~c(max(y)+max(errorBar),max(y)+max(errorBar)), showlegend=F, 
    #           name = "Non-Zero Features", yaxis = "ax", mode = "lines+markers", type = "scatter") %>%
    layout(title = paste0("Cross-Validation MSE (", name, ")"),
                            xaxis = list(title=paste0("log(",TeX("\\lambda"),")"),  side="bottom", showgrid=TRUE), # type="log"
                            hovermode = "x unified", legend = list(orientation='h'),  # xaxis2 = ax,  
                            yaxis = list(title = cv.glmnet.object$name, side="left", showgrid = TRUE))
}

plotCV.glmnet(cv.ridge, "Ridge")
coef(cv.ridge)
## 33 x 1 sparse Matrix of class "dgCMatrix"
##                                                    s1
## (Intercept)                             -2.710086e+00
## Group                                   -4.345753e-03
## Sex                                     -1.428609e-01
## Race                                    -1.971094e-02
## Access                                   6.911144e-02
## Age_days                                -1.935071e-06
## Weight                                   1.157368e-04
## Pre_transfusion_K                        1.336358e-01
## Cr_at_transfusion                        1.099052e-01
## Cardiac_dysf                            -6.273937e-02
## Respiratory_dysf                        -1.487991e-01
## Kidney_dysf                              3.969724e-01
## Liver_dysf                               3.127293e-01
## Intracranial_diso                        2.548654e-01
## Orthopedics                              2.364015e-02
## Anemia                                  -2.162983e-01
## Hemoglobinopathy                        -1.241734e-01
## Sepsis                                   2.467923e-01
## ECMO                                     1.512490e-01
## CPB                                      1.902543e-01
## Prematurity                              6.670518e-02
## Dialysis                                 1.043460e-01
## RBC_Unit_type                           -6.145441e-02
## Age_of_RBC_unit                         -1.285021e-02
## Leukoreduction                           3.240957e-01
## Irradiation                              2.699466e-02
## Washed                                  -1.855221e-01
## Plasma_reduction                        -2.575890e-02
## tV_12_weight_ml_Kg                       3.492291e-03
## tV_12_eTBV                               2.244901e-01
## Infusion_rate_hour_Pt_weight             1.850471e-03
## Infusion_rate_hour_eTBV                  1.463833e-01
## Time_from_irradition_to_transfusion_min  3.868063e-06
cv.lasso <-  cv.glmnet(x=as.matrix(X), y=as.factor(y_TAH), type.measure="mse", alpha=1, parallel=T, family="binomial")
plotCV.glmnet(cv.lasso, "LASSO")
coef(cv.lasso)
## 33 x 1 sparse Matrix of class "dgCMatrix"
##                                                   s1
## (Intercept)                             -2.664830935
## Group                                    .          
## Sex                                      .          
## Race                                     .          
## Access                                   .          
## Age_days                                 .          
## Weight                                   .          
## Pre_transfusion_K                        0.158588353
## Cr_at_transfusion                        .          
## Cardiac_dysf                             .          
## Respiratory_dysf                        -0.093961072
## Kidney_dysf                              1.306782298
## Liver_dysf                               0.142076628
## Intracranial_diso                        .          
## Orthopedics                              .          
## Anemia                                  -0.390875362
## Hemoglobinopathy                         .          
## Sepsis                                   .          
## ECMO                                     .          
## CPB                                      .          
## Prematurity                              .          
## Dialysis                                 .          
## RBC_Unit_type                            .          
## Age_of_RBC_unit                         -0.015845717
## Leukoreduction                           .          
## Irradiation                              .          
## Washed                                   .          
## Plasma_reduction                         .          
## tV_12_weight_ml_Kg                       0.009916597
## tV_12_eTBV                               0.824338604
## Infusion_rate_hour_Pt_weight             .          
## Infusion_rate_hour_eTBV                  .          
## Time_from_irradition_to_transfusion_min  .
df_ridge_lasso <- as.data.frame(cbind(feature=str(coef(cv.lasso)@Dimnames[[1]]), 
                                      ridge=as.matrix(coef(cv.ridge))[,1],
                                      lasso=as.matrix(coef(cv.lasso))[,1]))
##  chr [1:33] "(Intercept)" "Group" "Sex" "Race" "Access" "Age_days" "Weight" ...
dim(df_ridge_lasso) # [1] 35  2
## [1] 33  2
head(df_ridge_lasso)
##                     ridge     lasso
## (Intercept) -2.710086e+00 -2.664831
## Group       -4.345753e-03  0.000000
## Sex         -1.428609e-01  0.000000
## Race        -1.971094e-02  0.000000
## Access       6.911144e-02  0.000000
## Age_days    -1.935071e-06  0.000000
variables <- rownames(df_ridge_lasso[-1,])
plot_ly(df_ridge_lasso[-1,], x = ~variables, y = ~ridge, type = 'bar', name = 'Ridge') %>% 
  add_trace(y = ~lasso, name = 'LASSO') %>% 
  layout(yaxis = list(title = 'Effect'), barmode = 'group', title="Variable Importance Plot (TAH Prediction Model)")
#### Report also the SE/CI of the LASSO effect-size estimates
# install.packages("glmnetSE")
library(glmnetSE)
df_data <- cbind(y_TAH=y_TAH, X)
glmnetSE.model <- glmnetSE(data=df_data, cf.no.shrnkg = c("y_TAH"), alpha=1, method="10CVoneSE", r=250, seed = 123, family="gaussian", perf.metric="mse") ### family="binomial")
summary(glmnetSE.model)
## LASSO model:
## Outcome variable: y_TAH 
## Variables without shrinkage: y_TAH 
## 
## 
##                             Coefficients Estimates Std.Error CI.low CI.up
##                                    Group         0      <NA>   <NA>  <NA>
##                                      Sex         0      <NA>   <NA>  <NA>
##                                     Race         0      <NA>   <NA>  <NA>
##                                   Access         0      <NA>   <NA>  <NA>
##                                 Age_days         0      <NA>   <NA>  <NA>
##                                   Weight         0      <NA>   <NA>  <NA>
##                        Pre_transfusion_K         0      <NA>   <NA>  <NA>
##                        Cr_at_transfusion         0      <NA>   <NA>  <NA>
##                             Cardiac_dysf         0      <NA>   <NA>  <NA>
##                         Respiratory_dysf         0      <NA>   <NA>  <NA>
##                              Kidney_dysf     0.161      <NA>   <NA>  <NA>
##                               Liver_dysf         0      <NA>   <NA>  <NA>
##                        Intracranial_diso         0      <NA>   <NA>  <NA>
##                              Orthopedics         0      <NA>   <NA>  <NA>
##                                   Anemia         0      <NA>   <NA>  <NA>
##                         Hemoglobinopathy         0      <NA>   <NA>  <NA>
##                                   Sepsis         0      <NA>   <NA>  <NA>
##                                     ECMO         0      <NA>   <NA>  <NA>
##                                      CPB         0      <NA>   <NA>  <NA>
##                              Prematurity         0      <NA>   <NA>  <NA>
##                                 Dialysis         0      <NA>   <NA>  <NA>
##                            RBC_Unit_type         0      <NA>   <NA>  <NA>
##                          Age_of_RBC_unit         0      <NA>   <NA>  <NA>
##                           Leukoreduction         0      <NA>   <NA>  <NA>
##                              Irradiation         0      <NA>   <NA>  <NA>
##                                   Washed         0      <NA>   <NA>  <NA>
##                         Plasma_reduction         0      <NA>   <NA>  <NA>
##                       tV_12_weight_ml_Kg     4e-04      <NA>   <NA>  <NA>
##                               tV_12_eTBV    0.0667      <NA>   <NA>  <NA>
##             Infusion_rate_hour_Pt_weight         0      <NA>   <NA>  <NA>
##                  Infusion_rate_hour_eTBV         0      <NA>   <NA>  <NA>
##  Time_from_irradition_to_transfusion_min         0      <NA>   <NA>  <NA>
##  p.value Sig.
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
##     <NA>     
## 
## 
## Performance Metric: 
##  Metric Value CI.low CI.up
##     mse   0.2   0.18  0.29

10.1.2 Model 1-Day Mortality

# has_NA = apply(is.na(X), 1, any) #= 1 if any column in that row is NA
# X = X[!has_NA, ]
cv.ridge <-  cv.glmnet(x=as.matrix(X), y=as.factor(y_Mortality), 
                       type.measure="mse", alpha=0, parallel=T, family="binomial")

plotCV.glmnet(cv.ridge, "Ridge")
coef(cv.ridge)
## 33 x 1 sparse Matrix of class "dgCMatrix"
##                                                    s1
## (Intercept)                             -2.386467e+00
## Group                                   -1.722271e-38
## Sex                                     -5.917855e-38
## Race                                     1.344001e-38
## Access                                   6.362398e-38
## Age_days                                -1.664252e-41
## Weight                                  -2.568711e-39
## Pre_transfusion_K                        1.395261e-38
## Cr_at_transfusion                        2.347954e-38
## Cardiac_dysf                             1.430001e-38
## Respiratory_dysf                         9.379509e-38
## Kidney_dysf                              1.587302e-37
## Liver_dysf                               2.387188e-37
## Intracranial_diso                        3.192094e-37
## Orthopedics                              1.234568e-37
## Anemia                                  -4.432624e-38
## Hemoglobinopathy                         1.782531e-38
## Sepsis                                   2.779735e-37
## ECMO                                     1.115047e-37
## CPB                                      1.234568e-37
## Prematurity                              1.114431e-37
## Dialysis                                 2.197298e-37
## RBC_Unit_type                           -3.290092e-38
## Age_of_RBC_unit                         -3.197691e-39
## Leukoreduction                           8.783487e-38
## Irradiation                              1.830673e-38
## Washed                                   2.598448e-37
## Plasma_reduction                         4.290214e-37
## tV_12_weight_ml_Kg                       1.806057e-39
## tV_12_eTBV                               1.535367e-37
## Infusion_rate_hour_Pt_weight             1.469213e-39
## Infusion_rate_hour_eTBV                  1.681580e-37
## Time_from_irradition_to_transfusion_min -5.857657e-42
cv.lasso <-  cv.glmnet(x=as.matrix(X), y=as.factor(y_Mortality), 
                       type.measure="mse", alpha=1, parallel=T, family="binomial")
plotCV.glmnet(cv.lasso, "LASSO")
coef(cv.lasso)
## 33 x 1 sparse Matrix of class "dgCMatrix"
##                                                s1
## (Intercept)                             -2.386467
## Group                                    .       
## Sex                                      .       
## Race                                     .       
## Access                                   .       
## Age_days                                 .       
## Weight                                   .       
## Pre_transfusion_K                        .       
## Cr_at_transfusion                        .       
## Cardiac_dysf                             .       
## Respiratory_dysf                         .       
## Kidney_dysf                              .       
## Liver_dysf                               .       
## Intracranial_diso                        .       
## Orthopedics                              .       
## Anemia                                   .       
## Hemoglobinopathy                         .       
## Sepsis                                   .       
## ECMO                                     .       
## CPB                                      .       
## Prematurity                              .       
## Dialysis                                 .       
## RBC_Unit_type                            .       
## Age_of_RBC_unit                          .       
## Leukoreduction                           .       
## Irradiation                              .       
## Washed                                   .       
## Plasma_reduction                         .       
## tV_12_weight_ml_Kg                       .       
## tV_12_eTBV                               .       
## Infusion_rate_hour_Pt_weight             .       
## Infusion_rate_hour_eTBV                  .       
## Time_from_irradition_to_transfusion_min  .
df_ridge_lasso <- as.data.frame(cbind(feature=str(coef(cv.lasso)@Dimnames[[1]]), 
                                      ridge=as.matrix(coef(cv.ridge))[,1],
                                      lasso=as.matrix(coef(cv.lasso))[,1]))
##  chr [1:33] "(Intercept)" "Group" "Sex" "Race" "Access" "Age_days" "Weight" ...
dim(df_ridge_lasso) # [1] 35  2
## [1] 33  2
head(df_ridge_lasso)
##                     ridge     lasso
## (Intercept) -2.386467e+00 -2.386467
## Group       -1.722271e-38  0.000000
## Sex         -5.917855e-38  0.000000
## Race         1.344001e-38  0.000000
## Access       6.362398e-38  0.000000
## Age_days    -1.664252e-41  0.000000
variables <- rownames(df_ridge_lasso[-1,])
plot_ly(df_ridge_lasso[-1,], x = ~variables, y = ~ridge, type = 'bar', name = 'Ridge') %>% 
  add_trace(y = ~lasso, name = 'LASSO') %>% 
  layout(yaxis = list(title = 'Effect'), barmode = 'group', title="Variable Importance Plot (1-Day Mortality Prediction Model)")

11 Probability Distribution Models for each TAH and Control Cohorts

# df_TAH_data_TAH_Controls<- filter(df_TAH_data_impute_mean, TAH_Occurrence==0)
# df_TAH_data_TAH_Patients
library(tidyr)

# df_TAH_data_TAH_Controls_long <- gather(df_TAH_data_TAH_Controls, feature, value,
#                                         Group:Irradiation, factor_key=TRUE)
# pl1 <- plot_ly(df_TAH_data_TAH_Controls_long, y = ~log(value), color = ~feature, type = "box", showlegend=F)  %>%
#   layout(title="Feature Distributions: Controls (TAH=1)")
# 
# df_TAH_data_TAH_Patients_long <- gather(df_TAH_data_TAH_Patients, feature, value,
#                                         Group:Irradiation, factor_key=TRUE)
# pl2 <- plot_ly(df_TAH_data_TAH_Patients_long, y = ~log(value), color = ~feature, type = "box", showlegend=F) %>%
#   layout(title="Feature Distributions: Patients (TAH=2)")
# 
# subplot(pl1, pl2, nrows=2, shareX = TRUE) %>% layout(title="Feature Distributions: Controls (Top) vs. Patients (Bottom)")
# 
# subplot(pl1, pl2, nrows=2, shareX = TRUE) %>% layout(title="Feature Distributions: Controls vs. Patients",
#                                                      updatemenus = list(list(
#                         active = 0,
#                         buttons= list(
#                           list(label = 'linear',
#                                method = 'update',
#                                args = list(list(visible = c(T,F)), list(yaxis = list(type = 'linear')))),
#                           list(label = 'log',
#                                method = 'update', 
#                                args = list(list(visible = c(F,T)), list(yaxis = list(type = 'log'))))))))


CNTR_data <- as.data.frame(sapply(df_TAH_data_TAH_Controls, as.numeric)) %>% 
  gather(variable, value, -c("Age_days", "Time_from_irradition_to_transfusion_min"))
        # %>%  separate(variable, "TAH_occurrence", sep = "\\_")
pl_Controls <- plot_ly(CNTR_data, x=~variable, y=~value, color=~variable, type="box", showlegend=F) %>%
  layout(title="Feature Distributions: Controls (non-TAH)")

PTNT_data <- as.data.frame(sapply(df_TAH_data_TAH_Patients, as.numeric)) %>% 
  gather(variable, value, -c("Age_days", "Time_from_irradition_to_transfusion_min"))
        # %>%  separate(variable, "TAH_occurrence", sep = "\\_")
pl_Patients <- plot_ly(PTNT_data, x=~variable, y=~value, color=~variable, type="box", showlegend=F) %>%
  layout(title="Feature Distributions: Patients (TAH)")

subplot(pl_Controls, pl_Patients, nrows=2, shareX = TRUE) %>% 
  layout(title="Feature Distributions: Controls (Top) vs. Patients (Bottom)")
CNTR_data$Cohort <- "Controls"
PTNT_data$Cohort <- "Patients"
df_CNTR_Pat <- rbind(CNTR_data, PTNT_data)

plot_ly(df_CNTR_Pat, x=~variable, y=~value, color=~Cohort, type="box", showlegend=F) %>%
  layout(title="Feature Distributions: Controls (non-TAH) vs. Patients (TAH)", boxmode = "group", 
         xaxis = list(title='Features'), yaxis = list(title='values'))

Other SOCR publicaitons, webapps, research projects, Ebooks, and instructional resources are available online.