This reads in the NSQIP data for all shunt cases and all peds cases from 2019.
This finds all the unique cases of shunt placement and merges with record data. Then, we create our final working dataframes that only contains the factors of interest.
df0 <- merge(df_raw,df_shunt[,2:13], by="CaseID")
df <- df0[,c(1,3:6,14,16,22,94,126:130,196:199,348:358)]
df_first <- df[which(df$PED_SHNT_1STPERM == "Yes"),]
df_revise <- df[which(df$PED_SHNT_1STPERM == "No"),]
#rem null
#df_rem_NULL <- df[!df$ETHNICITY_HISPANIC == "NULL", ]
#df_rem_NULL <- df[!df$DELIVERY_MODE == "NULL", ]
df_rem_NULL <- df[!df$PREM_BIRTH == "Unknown", ]
below: closer examination of premature birth influence on shunt revision
df_premature0 <- df_rem_NULL[,c(8,19)]
premature <- as.data.frame(table(df_premature0),stringsAsFactors=FALSE)
prem_no <- premature[1:9,]
prem_yes <- premature[10:18,]
df_premature <- prem_no
df_premature$first_shunt <- prem_yes$Freq
df_premature$multi_shunt <- prem_no$Freq
df_premature <- df_premature[,-c(2,3)]
df_premature$proportion_revised <- (df_premature$multi_shunt/(df_premature$multi_shunt+df_premature$first_shunt))
df_premature[8,1] <- "24 and fewer weeks gestation"
ggplot of premature birth versus shunt revisions
ggplot(data=df_premature, aes(x=PREM_BIRTH, y=proportion_revised,fill=proportion_revised))+geom_bar(stat="identity")+
scale_x_discrete(labels=c("<24 weeks","24 weeks","25-26 weeks","27-28 weeks","29-30 weeks","31-32 weeks","33-34 weeks","35-26","Full Term")) +
gghisto +theme(axis.text.x = element_text(size=10, angle=15)) + scale_y_continuous(labels = scales::percent)+scale_fill_gradient(low="mistyrose",high="lightcoral") +
theme(legend.position="none") + xlab("Weeks Gestation") + ylab("Proportion reporting \nshunt revision") +ggtitle("Proportions of Premature Birth \nCategories Reporting Shunt Revisions ")
prem_table <- table(df_rem_NULL$PREM_BIRTH, df_rem_NULL$PED_SHNT_1STPERM)
chisq.test(df_rem_NULL$PREM_BIRTH, df_rem_NULL$PED_SHNT_1STPERM, correct=FALSE)
##
## Pearson's Chi-squared test
##
## data: df_rem_NULL$PREM_BIRTH and df_rem_NULL$PED_SHNT_1STPERM
## X-squared = 34.828, df = 8, p-value = 2.874e-05
library(chisq.posthoc.test)
chisq.posthoc.test(prem_table)
## Dimension Value No Yes
## 1 24 completed weeks gestation Residuals 2.2982125 -2.2982125
## 2 24 completed weeks gestation p values 0.3878950 0.3878950
## 3 25-26 completed weeks gestation Residuals 3.1190716 -3.1190716
## 4 25-26 completed weeks gestation p values 0.0326560 0.0326560
## 5 27-28 completed weeks gestation Residuals 1.2547522 -1.2547522
## 6 27-28 completed weeks gestation p values 1.0000000 1.0000000
## 7 29-30 completed weeks gestation Residuals -1.4604842 1.4604842
## 8 29-30 completed weeks gestation p values 1.0000000 1.0000000
## 9 31-32 completed weeks gestation Residuals -0.8819048 0.8819048
## 10 31-32 completed weeks gestation p values 1.0000000 1.0000000
## 11 33-34 completed weeks gestation Residuals -2.7798978 2.7798978
## 12 33-34 completed weeks gestation p values 0.0978770 0.0978770
## 13 35-36 completed weeks gestation Residuals -1.8116193 1.8116193
## 14 35-36 completed weeks gestation p values 1.0000000 1.0000000
## 15 Less than 24 completed weeks gestation Residuals 2.4482438 -2.4482438
## 16 Less than 24 completed weeks gestation p values 0.2583980 0.2583980
## 17 No Residuals -1.0753303 1.0753303
## 18 No p values 1.0000000 1.0000000
preliminary findings: mode of birth predicts needing a second shunt. days from admissions to operation are related to shunt revision. premature birth signficantly related to first or second shunt.
#summary of ALL shunts
tbl_summary(df[,c(2:21)],label = `PED_SHNT_1STPERM` ~ "First Shunt",by=`PED_SHNT_1STPERM`)%>%
bold_labels() %>%add_p()
## There was an error in 'add_p()/add_difference()' for variable 'RACE', p-value omitted:
## Error in stats::fisher.test(c("White", "Unknown/Not Reported", "White", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=259.676, ipn_0:=ipoin[itp=489]=515, stp[ipn_0]=259.449).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'TRANST', p-value omitted:
## Error in stats::fisher.test(c("Admitted from home/clinic/doctor's office", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=324.318, ipn_0:=ipoin[itp=379]=786, stp[ipn_0]=321.999).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'DISCHDEST', p-value omitted:
## Error in stats::fisher.test(c("NULL", "Home", "Home", "Home", "Home", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=35.1155, ipn_0:=ipoin[itp=126]=57, stp[ipn_0]=29.4798).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'PED_SHNT_HC_ETIOL', p-value omitted:
## Error in stats::fisher.test(c("Intraventricular hemorrhage (IVH) of prematurity without other cause", : FEXACT error 7(location). LDSTP=18210 is too small for this problem,
## (pastp=96.8752, ipn_0:=ipoin[itp=122]=10, stp[ipn_0]=40.3951).
## Increase workspace or consider using 'simulate.p.value=TRUE'
| Characteristic | No, N = 5591 | Yes, N = 1,7391 | p-value2 |
|---|---|---|---|
| AGE_DAYS | 942 (233, 3,600) | 131 (50, 598) | <0.001 |
| SEX | 0.8 | ||
| Female | 248 (44%) | 780 (45%) | |
| Male | 311 (56%) | 959 (55%) | |
| RACE | |||
| American Indian or Alaska Native | 6 (1.1%) | 8 (0.5%) | |
| Asian | 11 (2.0%) | 43 (2.5%) | |
| Black or African American | 99 (18%) | 353 (20%) | |
| Native Hawaiian or Other Pacific Islander | 5 (0.9%) | 5 (0.3%) | |
| Unknown/Not Reported | 95 (17%) | 317 (18%) | |
| White | 343 (61%) | 1,013 (58%) | |
| ETHNICITY_HISPANIC | 0.11 | ||
| No | 397 (71%) | 1,263 (73%) | |
| NULL | 47 (8.4%) | 178 (10%) | |
| Yes | 115 (21%) | 298 (17%) | |
| TRANST | |||
| Admitted from home/clinic/doctor's office | 269 (48%) | 775 (45%) | |
| Admitted through ER, including outside ER with direct hospital admission | 234 (42%) | 460 (26%) | |
| Chronic care/Rehab/Intermediate Care/Spinal Cord | 1 (0.2%) | 7 (0.4%) | |
| Other | 8 (1.4%) | 28 (1.6%) | |
| Transferred from outside hospital (NICU, PICU, Inpatient on General floor, Adult ICU) | 47 (8.4%) | 469 (27%) | |
| HtoODay | 1 (0, 11) | 2 (0, 15) | <0.001 |
| PREM_BIRTH | <0.001 | ||
| 24 completed weeks gestation | 32 (5.7%) | 63 (3.6%) | |
| 25-26 completed weeks gestation | 62 (11%) | 125 (7.2%) | |
| 27-28 completed weeks gestation | 39 (7.0%) | 99 (5.7%) | |
| 29-30 completed weeks gestation | 13 (2.3%) | 64 (3.7%) | |
| 31-32 completed weeks gestation | 16 (2.9%) | 65 (3.7%) | |
| 33-34 completed weeks gestation | 16 (2.9%) | 104 (6.0%) | |
| 35-36 completed weeks gestation | 36 (6.4%) | 158 (9.1%) | |
| Less than 24 completed weeks gestation | 30 (5.4%) | 56 (3.2%) | |
| No | 286 (51%) | 958 (55%) | |
| Unknown | 29 (5.2%) | 47 (2.7%) | |
| DELIVERY_MODE | <0.001 | ||
| NULL | 490 (88%) | 1,018 (59%) | |
| Scheduled C-Section | 5 (0.9%) | 179 (10%) | |
| Unknown/Not Documented | 3 (0.5%) | 53 (3.0%) | |
| Unscheduled C-Section | 38 (6.8%) | 279 (16%) | |
| Vaginal Delivery | 23 (4.1%) | 210 (12%) | |
| ANESURG | 54 (42, 70) | 52 (42, 66) | 0.034 |
| SURGANE | 23 (16, 30) | 23 (17, 32) | 0.2 |
| DPATRM | 137 (110, 178) | 126 (101, 155) | <0.001 |
| ANETIME | 147 (118, 194) | 138 (111, 168) | <0.001 |
| OPTIME | 69 (47, 94) | 56 (41, 75) | <0.001 |
| DOptoDis | 2 (1, 4) | 2 (1, 5) | 0.3 |
| DISCHDEST | |||
| Expired | 3 (0.5%) | 9 (0.5%) | |
| Facility which was home | 2 (0.4%) | 7 (0.4%) | |
| Home | 478 (86%) | 1,298 (75%) | |
| NULL | 57 (10%) | 319 (18%) | |
| Rehab | 10 (1.8%) | 20 (1.2%) | |
| Separate acute care | 2 (0.4%) | 65 (3.7%) | |
| Skilled care, not home | 7 (1.3%) | 19 (1.1%) | |
| Unknown | 0 (0%) | 1 (<0.1%) | |
| Unskilled facility, not home | 0 (0%) | 1 (<0.1%) | |
| TOTHLOS | 2 (1, 10) | 2 (1, 9) | 0.079 |
| STILLINHOSP | <0.001 | ||
| NULL | 502 (90%) | 1,420 (82%) | |
| Yes | 57 (10%) | 319 (18%) | |
| PED_SHNT_HC_ETIOL | |||
| Congenital hydrocephalus | 0 (0%) | 525 (30%) | |
| Intracranial cyst | 0 (0%) | 116 (6.7%) | |
| Intraventricular hemorrhage (IVH) of prematurity without other cause | 0 (0%) | 373 (21%) | |
| Neoplastic | 0 (0%) | 220 (13%) | |
| NULL | 559 (100%) | 0 (0%) | |
| Other - insufficient information to classify type | 0 (0%) | 155 (8.9%) | |
| Post hemorrhagic from other vascular lesion | 0 (0%) | 58 (3.3%) | |
| Post infectious | 0 (0%) | 77 (4.4%) | |
| Post traumatic | 0 (0%) | 40 (2.3%) | |
| Spina bifida with Chiari malformation / myelomeningocele | 0 (0%) | 118 (6.8%) | |
| Syndromic, not otherwise specified | 0 (0%) | 38 (2.2%) | |
| Vascular anomaly | 0 (0%) | 19 (1.1%) | |
| PED_SHNT_PRIOR_HCPROC | <0.001 | ||
| No | 0 (0%) | 1,124 (65%) | |
| NULL | 559 (100%) | 0 (0%) | |
| Yes | 0 (0%) | 615 (35%) | |
| 1 Median (IQR); n (%) | |||
| 2 Wilcoxon rank sum test; Pearson's Chi-squared test | |||
#summary removing specified null values
tbl_summary(df_rem_NULL[,c(2:21)],label = `PED_SHNT_1STPERM` ~ "First Shunt",by=`PED_SHNT_1STPERM`)%>%
bold_labels() %>%add_p()
## There was an error in 'add_p()/add_difference()' for variable 'RACE', p-value omitted:
## Error in stats::fisher.test(c("White", "White", "Unknown/Not Reported", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=226.606, ipn_0:=ipoin[itp=244]=26, stp[ipn_0]=225.063).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'TRANST', p-value omitted:
## Error in stats::fisher.test(c("Admitted from home/clinic/doctor's office", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=327.251, ipn_0:=ipoin[itp=353]=1011, stp[ipn_0]=329.048).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'DISCHDEST', p-value omitted:
## Error in stats::fisher.test(c("NULL", "Home", "Home", "Home", "NULL", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=39.8074, ipn_0:=ipoin[itp=145]=2922, stp[ipn_0]=34.0131).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'PED_SHNT_HC_ETIOL', p-value omitted:
## Error in stats::fisher.test(c("Intraventricular hemorrhage (IVH) of prematurity without other cause", : FEXACT error 7(location). LDSTP=18240 is too small for this problem,
## (pastp=94.3609, ipn_0:=ipoin[itp=96]=103, stp[ipn_0]=215.755).
## Increase workspace or consider using 'simulate.p.value=TRUE'
| Characteristic | No, N = 5301 | Yes, N = 1,6921 | p-value2 |
|---|---|---|---|
| AGE_DAYS | 834 (214, 3,436) | 126 (48, 496) | <0.001 |
| SEX | >0.9 | ||
| Female | 236 (45%) | 757 (45%) | |
| Male | 294 (55%) | 935 (55%) | |
| RACE | |||
| American Indian or Alaska Native | 6 (1.1%) | 8 (0.5%) | |
| Asian | 9 (1.7%) | 43 (2.5%) | |
| Black or African American | 93 (18%) | 347 (21%) | |
| Native Hawaiian or Other Pacific Islander | 5 (0.9%) | 4 (0.2%) | |
| Unknown/Not Reported | 86 (16%) | 299 (18%) | |
| White | 331 (62%) | 991 (59%) | |
| ETHNICITY_HISPANIC | 0.10 | ||
| No | 378 (71%) | 1,235 (73%) | |
| NULL | 42 (7.9%) | 166 (9.8%) | |
| Yes | 110 (21%) | 291 (17%) | |
| TRANST | |||
| Admitted from home/clinic/doctor's office | 256 (48%) | 762 (45%) | |
| Admitted through ER, including outside ER with direct hospital admission | 219 (41%) | 430 (25%) | |
| Chronic care/Rehab/Intermediate Care/Spinal Cord | 1 (0.2%) | 7 (0.4%) | |
| Other | 8 (1.5%) | 28 (1.7%) | |
| Transferred from outside hospital (NICU, PICU, Inpatient on General floor, Adult ICU) | 46 (8.7%) | 465 (27%) | |
| HtoODay | 1 (0, 11) | 2 (0, 16) | <0.001 |
| PREM_BIRTH | <0.001 | ||
| 24 completed weeks gestation | 32 (6.0%) | 63 (3.7%) | |
| 25-26 completed weeks gestation | 62 (12%) | 125 (7.4%) | |
| 27-28 completed weeks gestation | 39 (7.4%) | 99 (5.9%) | |
| 29-30 completed weeks gestation | 13 (2.5%) | 64 (3.8%) | |
| 31-32 completed weeks gestation | 16 (3.0%) | 65 (3.8%) | |
| 33-34 completed weeks gestation | 16 (3.0%) | 104 (6.1%) | |
| 35-36 completed weeks gestation | 36 (6.8%) | 158 (9.3%) | |
| Less than 24 completed weeks gestation | 30 (5.7%) | 56 (3.3%) | |
| No | 286 (54%) | 958 (57%) | |
| DELIVERY_MODE | <0.001 | ||
| NULL | 461 (87%) | 971 (57%) | |
| Scheduled C-Section | 5 (0.9%) | 179 (11%) | |
| Unknown/Not Documented | 3 (0.6%) | 53 (3.1%) | |
| Unscheduled C-Section | 38 (7.2%) | 279 (16%) | |
| Vaginal Delivery | 23 (4.3%) | 210 (12%) | |
| ANESURG | 54 (42, 70) | 52 (42, 66) | 0.076 |
| SURGANE | 22 (16, 30) | 23 (17, 32) | 0.11 |
| DPATRM | 136 (109, 176) | 125 (101, 155) | <0.001 |
| ANETIME | 147 (117, 192) | 137 (111, 168) | <0.001 |
| OPTIME | 67 (47, 92) | 56 (41, 74) | <0.001 |
| DOptoDis | 2 (1, 3) | 2 (1, 5) | 0.6 |
| DISCHDEST | |||
| Expired | 3 (0.6%) | 9 (0.5%) | |
| Facility which was home | 1 (0.2%) | 6 (0.4%) | |
| Home | 453 (85%) | 1,258 (74%) | |
| NULL | 56 (11%) | 314 (19%) | |
| Rehab | 8 (1.5%) | 20 (1.2%) | |
| Separate acute care | 2 (0.4%) | 64 (3.8%) | |
| Skilled care, not home | 7 (1.3%) | 19 (1.1%) | |
| Unknown | 0 (0%) | 1 (<0.1%) | |
| Unskilled facility, not home | 0 (0%) | 1 (<0.1%) | |
| TOTHLOS | 2 (1, 9) | 2 (1, 9) | 0.2 |
| STILLINHOSP | <0.001 | ||
| NULL | 474 (89%) | 1,378 (81%) | |
| Yes | 56 (11%) | 314 (19%) | |
| PED_SHNT_HC_ETIOL | |||
| Congenital hydrocephalus | 0 (0%) | 524 (31%) | |
| Intracranial cyst | 0 (0%) | 109 (6.4%) | |
| Intraventricular hemorrhage (IVH) of prematurity without other cause | 0 (0%) | 373 (22%) | |
| Neoplastic | 0 (0%) | 193 (11%) | |
| NULL | 530 (100%) | 0 (0%) | |
| Other - insufficient information to classify type | 0 (0%) | 149 (8.8%) | |
| Post hemorrhagic from other vascular lesion | 0 (0%) | 58 (3.4%) | |
| Post infectious | 0 (0%) | 73 (4.3%) | |
| Post traumatic | 0 (0%) | 39 (2.3%) | |
| Spina bifida with Chiari malformation / myelomeningocele | 0 (0%) | 118 (7.0%) | |
| Syndromic, not otherwise specified | 0 (0%) | 37 (2.2%) | |
| Vascular anomaly | 0 (0%) | 19 (1.1%) | |
| PED_SHNT_PRIOR_HCPROC | <0.001 | ||
| No | 0 (0%) | 1,097 (65%) | |
| NULL | 530 (100%) | 0 (0%) | |
| Yes | 0 (0%) | 595 (35%) | |
| 1 Median (IQR); n (%) | |||
| 2 Wilcoxon rank sum test; Pearson's Chi-squared test | |||
#summary of first time shunts, characterized by surgical adjuncts
#tbl_summary(df_first[,c(2:5,7:16)], by=PED_SHNT_SURGADJS)%>%
#bold_labels() %>%add_p()