## Warning: package 'rcompanion' was built under R version 3.4.4

Load Data

dat <- read.csv("~/nqf_caregivers/data/nqf_dat.csv", header = T, stringsAsFactors = F)

## Edit language
dat$LANGUAGE <- ifelse(dat$LANGUAGE == "ENGL", "ENGL", "OTHER")

prov <- provider_caremeasure_check(attending_check(dat))

prov <- expire_check(prov)

team <- team_caremeasure_check(attending_check(dat))

team <- expire_check(team)

Patient Level Analysis (Provider-Patient Interaction Level)

temp <- aggregate(cbind(NQF,
                       AGE,
                       SOFA) ~ 
                     ETHNICITY +
                     GENDER +
                     MARITAL_STATUS +
                     FIRST_CAREUNIT +
                     HADM_ID +
                     SUBJECT_ID +
                     CGID,
                 data = prov, 
                 FUN = mean)

cat("There are", nrow(temp), "Unique Provider-Patient Interactions.\n")
## There are 4950 Unique Provider-Patient Interactions.

Provider-Patient Interaction (Provider Level) Statistics

plotDat(temp, "NQF", "GENDER", F, "Gender", "Gender", "Frequency")

test <- table(temp$GENDER, temp$NQF)
test
##    
##        0    1
##   F 1093 1397
##   M 1289 1171
chisq.test(test)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  test
## X-squared = 35.497, df = 1, p-value = 2.555e-09
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##   Comparison  p.Chisq p.adj.Chisq
## 1      F : M 2.55e-09    2.55e-09
plotDat(temp, "NQF","ETHNICITY", F, "Ethnicity", "Ethnicity", "Frequency")

test <- table(temp$ETHNICITY, temp$NQF)
test
##        
##            0    1
##   BLACK  195  252
##   OTHER  234  268
##   WHITE 1953 2048
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 4.8447, df = 2, p-value = 0.08871
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##      Comparison p.Chisq p.adj.Chisq
## 1 BLACK : OTHER  0.3910       0.391
## 2 BLACK : WHITE  0.0421       0.126
## 3 OTHER : WHITE  0.3780       0.391
plotDat(temp, "NQF", "MARITAL_STATUS", F, "Marital Status", "Marital Status", "Frequency")

test <- table(temp$MARITAL_STATUS, temp$NQF)
test
##          
##              0    1
##   MARRIED 1101  970
##   SINGLE   422  570
##   UNKNOWN  118   93
##   WIDOWED  741  935
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 48.865, df = 3, p-value = 1.394e-10
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##          Comparison  p.Chisq p.adj.Chisq
## 1  MARRIED : SINGLE 4.67e-08    1.83e-07
## 2 MARRIED : UNKNOWN 4.88e-01    4.88e-01
## 3 MARRIED : WIDOWED 6.09e-08    1.83e-07
## 4  SINGLE : UNKNOWN 5.14e-04    1.03e-03
## 5  SINGLE : WIDOWED 4.23e-01    4.88e-01
## 6 UNKNOWN : WIDOWED 1.65e-03    2.47e-03
plotDat(temp, "NQF", "FIRST_CAREUNIT", F, "First Careunit", "First Careunit", "Frequency")

test <- table(temp$FIRST_CAREUNIT, temp$NQF)
test
##        
##            0    1
##   CCU    337  375
##   CSRU   144   52
##   MICU  1307 1715
##   SICU   371  262
##   TSICU  223  164
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 121.24, df = 4, p-value < 2.2e-16
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##      Comparison  p.Chisq p.adj.Chisq
## 1    CCU : CSRU 1.44e-10    4.80e-10
## 2    CCU : MICU 5.34e-02    5.93e-02
## 3    CCU : SICU 4.50e-05    9.00e-05
## 4   CCU : TSICU 1.39e-03    1.74e-03
## 5   CSRU : MICU 3.20e-16    3.20e-15
## 6   CSRU : SICU 2.49e-04    3.71e-04
## 7  CSRU : TSICU 2.60e-04    3.71e-04
## 8   MICU : SICU 2.42e-12    1.21e-11
## 9  MICU : TSICU 1.17e-07    2.92e-07
## 10 SICU : TSICU 8.07e-01    8.07e-01
boxplot(temp$AGE ~ temp$NQF, 
        main = "Caremeasure Implementation by Age",
        xlab = "Implementation (1 == Yes)",
        ylab = "Age (Years)")

t.test(temp$AGE ~ temp$NQF)
## 
##  Welch Two Sample t-test
## 
## data:  temp$AGE by temp$NQF
## t = -10.265, df = 4943.4, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.781107 -1.209871
## sample estimates:
## mean in group 0 mean in group 1 
##        83.43432        84.92981
boxplot(temp$SOFA ~ temp$NQF, 
        main = "Caremeasure Implementation by SOFA Score",
        xlab = "Implementation (1 == Yes)",
        ylab = "SOFA Score")

t.test(temp$SOFA ~ temp$NQF)
## 
##  Welch Two Sample t-test
## 
## data:  temp$SOFA by temp$NQF
## t = -0.3143, df = 4888.3, p-value = 0.7533
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1909025  0.1381490
## sample estimates:
## mean in group 0 mean in group 1 
##        4.845508        4.871885

Hospital Admission Level Analysis (Care Team Level)

temp <- aggregate(cbind(NQF,
                       AGE,
                       SOFA) ~ 
                     ETHNICITY +
                     GENDER +
                     MARITAL_STATUS +
                     FIRST_CAREUNIT +
                     HADM_ID,
                 data = team, 
                 FUN = mean)
plotDat(temp, "NQF", "GENDER", F, "Gender", "Gender", "Frequency")

test <- table(temp$GENDER, temp$NQF)
test
##    
##       0   1
##   F 191 442
##   M 241 381
chisq.test(test)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  test
## X-squared = 9.8365, df = 1, p-value = 0.001711
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##   Comparison p.Chisq p.adj.Chisq
## 1      F : M 0.00171     0.00171
plotDat(temp, "NQF","ETHNICITY", F, "Ethnicity", "Ethnicity", "Frequency")

test <- table(temp$ETHNICITY, temp$NQF)
test
##        
##           0   1
##   BLACK  32  73
##   OTHER  38  87
##   WHITE 362 663
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 1.9838, df = 2, p-value = 0.3709
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##      Comparison p.Chisq p.adj.Chisq
## 1 BLACK : OTHER   1.000       1.000
## 2 BLACK : WHITE   0.377       0.566
## 3 OTHER : WHITE   0.322       0.566
plotDat(temp, "NQF", "MARITAL_STATUS", F, "Marital Status", "Marital Status", "Frequency")

test <- table(temp$MARITAL_STATUS, temp$NQF)
test
##          
##             0   1
##   MARRIED 211 314
##   SINGLE   67 179
##   UNKNOWN  23  33
##   WIDOWED 131 297
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 17.223, df = 3, p-value = 0.000636
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##          Comparison  p.Chisq p.adj.Chisq
## 1  MARRIED : SINGLE 0.000646     0.00388
## 2 MARRIED : UNKNOWN 1.000000     1.00000
## 3 MARRIED : WIDOWED 0.002700     0.00810
## 4  SINGLE : UNKNOWN 0.059900     0.12000
## 5  SINGLE : WIDOWED 0.402000     0.48200
## 6 UNKNOWN : WIDOWED 0.153000     0.22900
plotDat(temp, "NQF", "FIRST_CAREUNIT", F, "First Careunit", "First Careunit", "Frequency")

test <- table(temp$FIRST_CAREUNIT, temp$NQF)
test
##        
##           0   1
##   CCU    39 114
##   CSRU   42  19
##   MICU  183 542
##   SICU  107  89
##   TSICU  61  59
chisq.test(test)
## 
##  Pearson's Chi-squared test
## 
## data:  test
## X-squared = 114.15, df = 4, p-value < 2.2e-16
pairwiseNominalIndependence(
  as.matrix(test), 
  fisher = F, gtest = F, chisq = T, method = "fdr")
##      Comparison  p.Chisq p.adj.Chisq
## 1    CCU : CSRU 9.03e-09    3.01e-08
## 2    CCU : MICU 1.00e+00    1.00e+00
## 3    CCU : SICU 8.35e-08    1.67e-07
## 4   CCU : TSICU 2.82e-05    4.70e-05
## 5   CSRU : MICU 1.34e-12    6.70e-12
## 6   CSRU : SICU 6.84e-02    8.55e-02
## 7  CSRU : TSICU 3.11e-02    4.44e-02
## 8   MICU : SICU 8.32e-15    8.32e-14
## 9  MICU : TSICU 1.89e-08    4.73e-08
## 10 SICU : TSICU 5.94e-01    6.60e-01
boxplot(temp$AGE ~ temp$NQF, 
        main = "Caremeasure Implementation by Age",
        xlab = "Implementation (1 == Yes)",
        ylab = "Age (Years)")

t.test(temp$AGE ~ temp$NQF)
## 
##  Welch Two Sample t-test
## 
## data:  temp$AGE by temp$NQF
## t = -4.7878, df = 930.19, p-value = 1.961e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2.0173473 -0.8443392
## sample estimates:
## mean in group 0 mean in group 1 
##        83.24378        84.67462
boxplot(temp$SOFA ~ temp$NQF, 
        main = "Caremeasure Implementation by SOFA Score",
        xlab = "Implementation (1 == Yes)",
        ylab = "SOFA Score")

t.test(temp$SOFA ~ temp$NQF)
## 
##  Welch Two Sample t-test
## 
## data:  temp$SOFA by temp$NQF
## t = -2.6818, df = 928.65, p-value = 0.007453
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.7880552 -0.1220467
## sample estimates:
## mean in group 0 mean in group 1 
##        4.451389        4.906440