knitr::opts_chunk$set(echo = TRUE)

# library(sjPlot)
library(xlsx)
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(irr)
## Loading required package: lpSolve
library(car)
## Loading required package: carData
library(sandwich)

freg <- read.xlsx(file="/cloud/project/Jafri/CRMREGR2-20190625.xlsx", sheetIndex = 1, header=TRUE)

dfj <- read.xlsx(file="/cloud/project/Jafri/CRM-STATS-Jafri-20190522.xlsx", sheetIndex = 1, header=TRUE)
freg <- read.xlsx(file="/cloud/project/Jafri/CRMREGR2-20190625.xlsx", sheetIndex = 1, header=TRUE)

fcprdef <- read.xlsx(file="/cloud/project/Jafri/CPRDEF 20190723.xlsx", sheetIndex = 1, header=TRUE)

PostEstReg <- function(DepVarVec, RegObj) {
  # requires package 'car'
  # DepVarVec is just the dependent variable used in the regression
  # RegObj is the regression object returned by the lm or other regression command
  yols1a <- DepVarVec
  ols1yhat <- fitted(RegObj)
  ols1rr <- resid(RegObj, type = "response")
  ols1rp <- resid(RegObj, type = "pearson")
  
  print("VIF:")
  print(vif(RegObj))
  
  par(mfcol = c(2, 3))
  
  {
    plot(ols1yhat, ols1rr, main = "Fitted vs Residuals")
    qqnorm(ols1rr)
    plot(ols1yhat, ols1rp, main = "Fitted vs Pearson Residuals")
    qqnorm(ols1rp)
    plot(yols1a, ols1rp, main = "Actual vs Pearson Residuals")
    plot(yols1a, ols1yhat, main = "Actual vs Fitted")
  }
  
  hist(
    ols1rr,
    main = "Actual Residuals",
    xlab = "Residuals",
    border = "black",
    col = "skyblue",
    # xlim=c(0,125),
    las = 1,
    breaks = 15
  )
  
  print("")
  print("")
    
  # residualPlots(RegObj) # removed because was causing formatting error, but could try again with above print statements added, to separate histogram above from residual plots
  print("")
  print("")
  print("correlation of actual and fitted")
  print(cor(yols1a, ols1yhat)) # correlation of actual and fitted
  print("")
  print("")
  print("correlation of predicted values and residuals")
  print(cor(ols1yhat, ols1rr)) # correlation of predicted values and residuals
  print("")
  print("")
  print("Bootstrapped regression...")
  
  fit11booted <- Boot(RegObj, R = 1000)
  print(summary(fit11booted))
  print(Confint(fit11booted, level=.90, type="norm"))
  
}
# end of function PostEstReg

1 T-tests

1.1 CPT post vs pre

mean(freg$CPTPost)
## [1] 0.7209583
mean(freg$CPTPre)
## [1] 0.6174167
t.test(freg$CPTPost,freg$CPTPre, paired = TRUE)
## 
##  Paired t-test
## 
## data:  freg$CPTPost and freg$CPTPre
## t = 6.0442, df = 23, p-value = 3.65e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.06810373 0.13897961
## sample estimates:
## mean of the differences 
##               0.1035417

1.2 CTS post vs pre

mean(freg$CTSPost)
## [1] 0.5754167
mean(freg$CTSPre)
## [1] 0.4279167
t.test(freg$CTSPost,freg$CTSPre, paired = TRUE)
## 
##  Paired t-test
## 
## data:  freg$CTSPost and freg$CTSPre
## t = 7.8227, df = 23, p-value = 6.287e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.1084947 0.1865053
## sample estimates:
## mean of the differences 
##                  0.1475

1.3 CPR post vs pre

mean(freg$CPRPost)
## [1] 34.375
mean(freg$CPRPre)
## [1] 70.625
t.test(freg$CPRPost,freg$CPRPre, paired = TRUE)
## 
##  Paired t-test
## 
## data:  freg$CPRPost and freg$CPRPre
## t = -3.712, df = 23, p-value = 0.001147
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -56.45167 -16.04833
## sample estimates:
## mean of the differences 
##                  -36.25

1.4 Defibrillation post vs pre

mean(freg$DEFPost)
## [1] 118.875
mean(freg$DEFPre)
## [1] 152.2083
t.test(freg$DEFPost,freg$DEFPre, paired = TRUE)
## 
##  Paired t-test
## 
## data:  freg$DEFPost and freg$DEFPre
## t = -1.78, df = 23, p-value = 0.08829
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -72.071748   5.405081
## sample estimates:
## mean of the differences 
##               -33.33333

1.5 CPR under 30 seconds post vs pre

mean(fcprdef$CPRPO)
## [1] 0.4166667
mean(fcprdef$CPRPR)
## [1] 0.7916667
t.test(fcprdef$CPRPO,fcprdef$CPRPR, paired = TRUE)
## 
##  Paired t-test
## 
## data:  fcprdef$CPRPO and fcprdef$CPRPR
## t = -2.8399, df = 23, p-value = 0.009278
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.6481615 -0.1018385
## sample estimates:
## mean of the differences 
##                  -0.375

1.6 Defibrillation under 30 seconds post vs pre

mean(fcprdef$DEFIBPO)
## [1] 0.3333333
mean(fcprdef$DEFIBPR)
## [1] 0.625
t.test(fcprdef$DEFIBPO,fcprdef$DEFIBPR, paired = TRUE)
## 
##  Paired t-test
## 
## data:  fcprdef$DEFIBPO and fcprdef$DEFIBPR
## t = -2.0701, df = 23, p-value = 0.04986
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.5831349679 -0.0001983654
## sample estimates:
## mean of the differences 
##              -0.2916667

2 Regressions with potential confounders

These are regressions to test if any confounding variables are associated with CPT or CTS outcomes. All confounding variables relate to team composition.

For each regression, the following items are reported:

2.1 List of independent variables (possible confounders)

  • “ED.MD” - MD leading code
  • “RT” - RT present
  • “Pharm” - pharmacist present (left out of regressions since highly correlated with other independent variables)
  • "NUMB - number of staff members
  • “LeaderTWbin” - leader with teamwork experience
  • “X..TW” - team members with teamwork experience
  • “X..PALS” - team members with pals experience
  • “LEDEXP2” - leader’s clinical experience
  • “STAFFSIX”- staff experience
  • “LDCODEREG” - leader number of codes
  • “STAFFCODES” - staff number codes
  • “LPALS” - leader with PALS under a year
# head(freg[c("ED.MD","RT","NUMB","LeaderTWbin","X..TW","X..PALS","LEDEXP2","STAFFSIX","LDCODEREG","STAFFCODES")], n=50)

2.2 CPT regressions and post-estimation tests

2.2.1 CPTPre

# fit11<- lm(CPTPre ~ ED.MD + RT + LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES, data=freg)
fit11<- lm(CPTPre ~ ED.MD + RT + NUMB + LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit11)
## 
## Call:
## lm(formula = CPTPre ~ ED.MD + RT + NUMB + LeaderTWbin + freg$X..TW + 
##     freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + 
##     freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.135915 -0.042473  0.004129  0.054686  0.154504 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.883751   0.189452   4.665 0.000546 ***
## ED.MD           -0.008519   0.049143  -0.173 0.865260    
## RT               0.007392   0.050802   0.145 0.886732    
## NUMB            -0.009747   0.013213  -0.738 0.474918    
## LeaderTWbin      0.038867   0.056703   0.685 0.506087    
## freg$X..TW      -0.200588   0.119936  -1.672 0.120283    
## freg$X..PALS     0.003076   0.175501   0.018 0.986304    
## freg$LEDEXP2    -0.030326   0.015787  -1.921 0.078821 .  
## freg$STAFFSIX    0.034083   0.135602   0.251 0.805801    
## freg$LDCODEREG  -0.008149   0.021467  -0.380 0.710879    
## freg$STAFFCODES  0.113253   0.136966   0.827 0.424451    
## LPALS           -0.016253   0.054106  -0.300 0.769015    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09976 on 12 degrees of freedom
## Multiple R-squared:  0.3958, Adjusted R-squared:  -0.1581 
## F-statistic: 0.7146 on 11 and 12 DF,  p-value: 0.7074
# tab_model(fit11, vcov.fun = "vcovCL")

PostEstReg(DepVarVec = freg$CPTPre, RegObj = fit11)
## [1] "VIF:"
##           ED.MD              RT            NUMB     LeaderTWbin 
##        2.659458        1.556105        1.490595        1.884752 
##      freg$X..TW    freg$X..PALS    freg$LEDEXP2   freg$STAFFSIX 
##        1.553843        2.256168        1.376508        1.698070 
##  freg$LDCODEREG freg$STAFFCODES           LPALS 
##        1.505011        1.913060        1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.6291076
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] 2.20752e-16
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## Loading required namespace: boot
## 
## Number of bootstrap replications R = 992 
##                   original    bootBias   bootSE    bootMed
## (Intercept)      0.8837508  0.10976683 0.623660  0.9218012
## ED.MD           -0.0085193 -0.00042760 0.130109 -0.0069392
## RT               0.0073917  0.01970943 0.122608  0.0256062
## NUMB            -0.0097465 -0.00422023 0.040632 -0.0120304
## LeaderTWbin      0.0388669 -0.00416830 0.120821  0.0348260
## freg$X..TW      -0.2005876 -0.03472042 0.348193 -0.2192862
## freg$X..PALS     0.0030760 -0.08223244 0.416323 -0.0639036
## freg$LEDEXP2    -0.0303256 -0.00928559 0.047974 -0.0356916
## freg$STAFFSIX    0.0340826  0.03334648 0.323008  0.0302424
## freg$LDCODEREG  -0.0081486 -0.00035249 0.071189 -0.0097734
## freg$STAFFCODES  0.1132528 -0.03051203 0.487509  0.1094107
## LPALS           -0.0162534 -0.00406958 0.111152 -0.0157150
## Bootstrap normal confidence intervals
## 
##                     Estimate         5 %       95 %
## (Intercept)      0.883750842 -0.25184508 1.79981311
## ED.MD           -0.008519334 -0.22210215 0.20591868
## RT               0.007391653 -0.21399067 0.18935511
## NUMB            -0.009746540 -0.07236023 0.06130760
## LeaderTWbin      0.038866933 -0.15569806 0.24176853
## freg$X..TW      -0.200587632 -0.73859309 0.40685865
## freg$X..PALS     0.003075991 -0.59948252 0.77009938
## freg$LEDEXP2    -0.030325562 -0.09995081 0.05787088
## freg$STAFFSIX    0.034082633 -0.53056525 0.53203757
## freg$LDCODEREG  -0.008148639 -0.12489175 0.10929946
## freg$STAFFCODES  0.113252793 -0.65811633 0.94564597
## LPALS           -0.016253413 -0.19501328 0.17064562
# fit11booted <- Boot(fit11, R = 1000)
# Confint(fit11booted, level=.90, type="norm")
# summary(fit11booted)

\

residualPlots(fit11)

##                 Test stat Pr(>|Test stat|)  
## ED.MD              0.5603          0.58652  
## RT                -0.8009          0.44013  
## NUMB              -1.3417          0.20674  
## LeaderTWbin       -1.8342          0.09379 .
## freg$X..TW         0.0746          0.94191  
## freg$X..PALS       0.3436          0.73760  
## freg$LEDEXP2      -0.1585          0.87691  
## freg$STAFFSIX     -0.1907          0.85226  
## freg$LDCODEREG    -0.4731          0.64537  
## freg$STAFFCODES    0.2924          0.77540  
## LPALS             -0.3539          0.73014  
## Tukey test         0.1091          0.91315  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.2.2 CPTPost

fit12<- lm(CPTPost ~ ED.MD + RT + NUMB + freg$LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit12)
## 
## Call:
## lm(formula = CPTPost ~ ED.MD + RT + NUMB + freg$LeaderTWbin + 
##     freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + 
##     freg$LDCODEREG + freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.087417 -0.026652 -0.007017  0.017907  0.147134 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.8114389  0.1345100   6.033 5.91e-05 ***
## ED.MD             0.0223593  0.0348912   0.641   0.5337    
## RT               -0.0150070  0.0360691  -0.416   0.6847    
## NUMB              0.0008206  0.0093814   0.087   0.9317    
## freg$LeaderTWbin  0.0402819  0.0402588   1.001   0.3368    
## freg$X..TW       -0.0836371  0.0851539  -0.982   0.3454    
## freg$X..PALS      0.1010923  0.1246045   0.811   0.4330    
## freg$LEDEXP2     -0.0234127  0.0112089  -2.089   0.0587 .  
## freg$STAFFSIX    -0.1134308  0.0962766  -1.178   0.2616    
## freg$LDCODEREG   -0.0072582  0.0152412  -0.476   0.6425    
## freg$STAFFCODES   0.2414726  0.0972455   2.483   0.0288 *  
## LPALS            -0.0368509  0.0384153  -0.959   0.3563    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.07083 on 12 degrees of freedom
## Multiple R-squared:  0.5794, Adjusted R-squared:  0.1938 
## F-statistic: 1.503 on 11 and 12 DF,  p-value: 0.2472
PostEstReg(DepVarVec = freg$CPTPost, RegObj = fit12)
## [1] "VIF:"
##            ED.MD               RT             NUMB freg$LeaderTWbin 
##         2.659458         1.556105         1.490595         1.884752 
##       freg$X..TW     freg$X..PALS     freg$LEDEXP2    freg$STAFFSIX 
##         1.553843         2.256168         1.376508         1.698070 
##   freg$LDCODEREG  freg$STAFFCODES            LPALS 
##         1.505011         1.913060         1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.7611689
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] 3.027944e-16
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## 
## Number of bootstrap replications R = 996 
##                     original    bootBias   bootSE    bootMed
## (Intercept)       0.81143889  0.01321214 0.379187  0.8110811
## ED.MD             0.02235927  0.00373942 0.076270  0.0256676
## RT               -0.01500700  0.00083196 0.078708 -0.0163255
## NUMB              0.00082057 -0.00104905 0.026472  0.0022544
## freg$LeaderTWbin  0.04028192 -0.00365969 0.093578  0.0431576
## freg$X..TW       -0.08363706 -0.00646201 0.278871 -0.0895615
## freg$X..PALS      0.10109233 -0.01948498 0.328186  0.1087617
## freg$LEDEXP2     -0.02341271 -0.00080677 0.027770 -0.0244021
## freg$STAFFSIX    -0.11343078  0.02186688 0.232713 -0.1170034
## freg$LDCODEREG   -0.00725822  0.00062539 0.060771 -0.0071425
## freg$STAFFCODES   0.24147256  0.03019908 0.426957  0.2502006
## LPALS            -0.03685095 -0.00708956 0.084281 -0.0421819
## Bootstrap normal confidence intervals
## 
##                       Estimate         5 %       95 %
## (Intercept)       0.8114388912  0.17451955 1.42193395
## ED.MD             0.0223592652 -0.10683264 0.14407233
## RT               -0.0150070027 -0.14530133 0.11362341
## NUMB              0.0008205671 -0.04167376 0.04541299
## freg$LeaderTWbin  0.0402819179 -0.10997979 0.19786302
## freg$X..TW       -0.0836370631 -0.53587743 0.38152731
## freg$X..PALS      0.1010923309 -0.41924133 0.66039595
## freg$LEDEXP2     -0.0234127071 -0.06828422 0.02307234
## freg$STAFFSIX    -0.1134307768 -0.51807673 0.24748143
## freg$LDCODEREG   -0.0072582158 -0.10784323 0.09207601
## freg$STAFFCODES   0.2414725580 -0.49100873 0.91355569
## LPALS            -0.0368509488 -0.16839165 0.10886886

\

residualPlots(fit12)

##                  Test stat Pr(>|Test stat|)  
## ED.MD              -0.7047          0.49566  
## RT                 -1.9108          0.08243 .
## NUMB                0.5350          0.60332  
## freg$LeaderTWbin    0.3351          0.74386  
## freg$X..TW          0.5026          0.62513  
## freg$X..PALS        1.8226          0.09563 .
## freg$LEDEXP2       -1.7546          0.10711  
## freg$STAFFSIX       0.2799          0.78473  
## freg$LDCODEREG      0.0042          0.99676  
## freg$STAFFCODES    -0.2239          0.82694  
## LPALS               1.7591          0.10631  
## Tukey test         -2.0901          0.03661 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.2.3 CPTDelta

freg$CPTDELTA<-freg$CPTPost - freg$CPTPre

fit13<- lm(CPTDELTA ~ ED.MD + RT + NUMB + freg$LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit13)
## 
## Call:
## lm(formula = CPTDELTA ~ ED.MD + RT + NUMB + freg$LeaderTWbin + 
##     freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + 
##     freg$LDCODEREG + freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.169813 -0.035257 -0.008683  0.055430  0.131742 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)
## (Intercept)      -0.0723120  0.1891733  -0.382    0.709
## ED.MD             0.0308786  0.0490706   0.629    0.541
## RT               -0.0223987  0.0507272  -0.442    0.667
## NUMB              0.0105671  0.0131939   0.801    0.439
## freg$LeaderTWbin  0.0014150  0.0566195   0.025    0.980
## freg$X..TW        0.1169506  0.1197594   0.977    0.348
## freg$X..PALS      0.0980163  0.1752423   0.559    0.586
## freg$LEDEXP2      0.0069129  0.0157641   0.439    0.669
## freg$STAFFSIX    -0.1475134  0.1354023  -1.089    0.297
## freg$LDCODEREG    0.0008904  0.0214351   0.042    0.968
## freg$STAFFCODES   0.1282198  0.1367649   0.938    0.367
## LPALS            -0.0205975  0.0540268  -0.381    0.710
## 
## Residual standard error: 0.09961 on 12 degrees of freedom
## Multiple R-squared:  0.265,  Adjusted R-squared:  -0.4087 
## F-statistic: 0.3934 on 11 and 12 DF,  p-value: 0.9335
PostEstReg(DepVarVec = freg$CPTDELTA, RegObj = fit13)
## [1] "VIF:"
##            ED.MD               RT             NUMB freg$LeaderTWbin 
##         2.659458         1.556105         1.490595         1.884752 
##       freg$X..TW     freg$X..PALS     freg$LEDEXP2    freg$STAFFSIX 
##         1.553843         2.256168         1.376508         1.698070 
##   freg$LDCODEREG  freg$STAFFCODES            LPALS 
##         1.505011         1.913060         1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.5147995
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] -5.139585e-17
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## 
## Number of bootstrap replications R = 995 
##                     original    bootBias   bootSE    bootMed
## (Intercept)      -0.07231195 -0.08020562 0.611738 -0.1135667
## ED.MD             0.03087860  0.00243577 0.191579  0.0347095
## RT               -0.02239866 -0.01595927 0.209446 -0.0366895
## NUMB              0.01056711  0.00532905 0.044783  0.0127844
## freg$LeaderTWbin  0.00141498 -0.00073591 0.202168  0.0043005
## freg$X..TW        0.11695057  0.01696532 0.484662  0.1245217
## freg$X..PALS      0.09801634  0.04567916 0.667974  0.1562587
## freg$LEDEXP2      0.00691285  0.00638003 0.084245  0.0127328
## freg$STAFFSIX    -0.14751341 -0.01902163 0.493624 -0.1545153
## freg$LDCODEREG    0.00089042 -0.00347304 0.081514  0.0039974
## freg$STAFFCODES   0.12821977  0.08361575 0.493474  0.1518451
## LPALS            -0.02059754  0.00456557 0.218090 -0.0166284
## Bootstrap normal confidence intervals
## 
##                       Estimate         5 %       95 %
## (Intercept)      -0.0723119509 -0.99832616 1.01411350
## ED.MD             0.0308785992 -0.28667640 0.34356205
## RT               -0.0223986561 -0.35094670 0.33806793
## NUMB              0.0105671067 -0.06842307 0.07889919
## freg$LeaderTWbin  0.0014149850 -0.33038609 0.33468789
## freg$X..TW        0.1169505685 -0.69721240 0.89718289
## freg$X..PALS      0.0980163399 -1.04638268 1.15105703
## freg$LEDEXP2      0.0069128544 -0.13803710 0.13910274
## freg$STAFFSIX    -0.1475134098 -0.94043175 0.68344820
## freg$LDCODEREG    0.0008904232 -0.12971493 0.13844186
## freg$STAFFCODES   0.1282197653 -0.76708873 0.85629675
## LPALS            -0.0205975360 -0.38388916 0.33356295

\

residualPlots(fit13)

##                  Test stat Pr(>|Test stat|)  
## ED.MD              -1.0992          0.29516  
## RT                 -0.4004          0.69650  
## NUMB                1.8582          0.09008 .
## freg$LeaderTWbin    2.2194          0.04842 *
## freg$X..TW          0.2797          0.78489  
## freg$X..PALS        0.8172          0.43117  
## freg$LEDEXP2       -0.9849          0.34582  
## freg$STAFFSIX       0.3917          0.70279  
## freg$LDCODEREG      0.4769          0.64277  
## freg$STAFFCODES    -0.4548          0.65811  
## LPALS               1.6224          0.13300  
## Tukey test         -0.3549          0.72264  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.3 CTS regressions and post-estimation tests

2.3.1 CTSPre

# fit11<- lm(CPTPre ~ ED.MD + RT + LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES, data=freg)
fit11<- lm(CTSPre ~ ED.MD + RT + NUMB + LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit11)
## 
## Call:
## lm(formula = CTSPre ~ ED.MD + RT + NUMB + LeaderTWbin + freg$X..TW + 
##     freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + 
##     freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.114836 -0.038243 -0.005925  0.038971  0.143783 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)  
## (Intercept)      0.422189   0.164759   2.562   0.0249 *
## ED.MD            0.047396   0.042738   1.109   0.2892  
## RT              -0.004405   0.044180  -0.100   0.9222  
## NUMB            -0.008136   0.011491  -0.708   0.4925  
## LeaderTWbin      0.036035   0.049312   0.731   0.4790  
## freg$X..TW      -0.045850   0.104303  -0.440   0.6680  
## freg$X..PALS     0.002982   0.152626   0.020   0.9847  
## freg$LEDEXP2    -0.021254   0.013730  -1.548   0.1476  
## freg$STAFFSIX    0.117971   0.117927   1.000   0.3369  
## freg$LDCODEREG   0.025142   0.018669   1.347   0.2029  
## freg$STAFFCODES  0.142931   0.119114   1.200   0.2533  
## LPALS           -0.017302   0.047054  -0.368   0.7195  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.08675 on 12 degrees of freedom
## Multiple R-squared:  0.4369, Adjusted R-squared:  -0.07921 
## F-statistic: 0.8465 on 11 and 12 DF,  p-value: 0.6053
# tab_model(fit11, vcov.fun = "vcovCL")

PostEstReg(DepVarVec = freg$CTSPre, RegObj = fit11)
## [1] "VIF:"
##           ED.MD              RT            NUMB     LeaderTWbin 
##        2.659458        1.556105        1.490595        1.884752 
##      freg$X..TW    freg$X..PALS    freg$LEDEXP2   freg$STAFFSIX 
##        1.553843        2.256168        1.376508        1.698070 
##  freg$LDCODEREG freg$STAFFCODES           LPALS 
##        1.505011        1.913060        1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.6610101
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] -4.160405e-16
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## 
## Number of bootstrap replications R = 991 
##                   original   bootBias   bootSE    bootMed
## (Intercept)      0.4221892  0.0553963 0.626883  0.4511148
## ED.MD            0.0473960  0.0092023 0.189839  0.0487597
## RT              -0.0044055  0.0072545 0.158935  0.0076912
## NUMB            -0.0081361 -0.0016673 0.054917 -0.0099196
## LeaderTWbin      0.0360346  0.0031613 0.143391  0.0345500
## freg$X..TW      -0.0458505 -0.0403645 0.365794 -0.0672660
## freg$X..PALS     0.0029818 -0.0368204 0.480317 -0.0162316
## freg$LEDEXP2    -0.0212543 -0.0036889 0.041042 -0.0233082
## freg$STAFFSIX    0.1179707  0.0216531 0.406394  0.1090854
## freg$LDCODEREG   0.0251422 -0.0041422 0.079724  0.0222432
## freg$STAFFCODES  0.1429312  0.0300531 0.780996  0.1615154
## LPALS           -0.0173019 -0.0061345 0.178564 -0.0164472
## Bootstrap normal confidence intervals
## 
##                     Estimate         5 %       95 %
## (Intercept)      0.422189221 -0.66433753 1.39792346
## ED.MD            0.047395953 -0.27406388 0.35045112
## RT              -0.004405464 -0.27308402 0.24976403
## NUMB            -0.008136064 -0.09679991 0.08386245
## LeaderTWbin      0.036034595 -0.20298430 0.26873096
## freg$X..TW      -0.045850476 -0.60716375 0.59619186
## freg$X..PALS     0.002981819 -0.75024907 0.82985352
## freg$LEDEXP2    -0.021254338 -0.08507392 0.04994312
## freg$STAFFSIX    0.117970688 -0.57214171 0.76477685
## freg$LDCODEREG   0.025142188 -0.10185072 0.16041944
## freg$STAFFCODES  0.142931189 -1.17174673 1.39750300
## LPALS           -0.017301859 -0.30487873 0.28254393

\

residualPlots(fit11)

##                 Test stat Pr(>|Test stat|)
## ED.MD             -1.3311           0.2101
## RT                -0.0348           0.9728
## NUMB              -0.8270           0.4258
## LeaderTWbin       -1.2443           0.2393
## freg$X..TW        -0.2805           0.7843
## freg$X..PALS       0.4596           0.6548
## freg$LEDEXP2      -1.1066           0.2921
## freg$STAFFSIX      1.0282           0.3260
## freg$LDCODEREG    -1.6720           0.1227
## freg$STAFFCODES   -0.5696           0.5804
## LPALS             -0.0995           0.9226
## Tukey test        -1.1319           0.2577

2.3.2 CTSPost

fit12<- lm(CTSPost ~ ED.MD + RT + NUMB + freg$LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit12)
## 
## Call:
## lm(formula = CTSPost ~ ED.MD + RT + NUMB + freg$LeaderTWbin + 
##     freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + 
##     freg$LDCODEREG + freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14386 -0.04406  0.01818  0.03779  0.16831 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)   
## (Intercept)       0.77315    0.19074   4.053   0.0016 **
## ED.MD             0.01949    0.04948   0.394   0.7005   
## RT               -0.02438    0.05115  -0.477   0.6422   
## NUMB             -0.01549    0.01330  -1.164   0.2670   
## freg$LeaderTWbin -0.01264    0.05709  -0.221   0.8285   
## freg$X..TW       -0.03063    0.12075  -0.254   0.8041   
## freg$X..PALS     -0.12947    0.17669  -0.733   0.4778   
## freg$LEDEXP2     -0.02342    0.01589  -1.473   0.1664   
## freg$STAFFSIX     0.09057    0.13652   0.663   0.5196   
## freg$LDCODEREG    0.02273    0.02161   1.052   0.3137   
## freg$STAFFCODES   0.07675    0.13790   0.557   0.5881   
## LPALS            -0.02032    0.05447  -0.373   0.7157   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1004 on 12 degrees of freedom
## Multiple R-squared:  0.4241, Adjusted R-squared:  -0.1037 
## F-statistic: 0.8035 on 11 and 12 DF,  p-value: 0.638
PostEstReg(DepVarVec = freg$CTSPost, RegObj = fit12)
## [1] "VIF:"
##            ED.MD               RT             NUMB freg$LeaderTWbin 
##         2.659458         1.556105         1.490595         1.884752 
##       freg$X..TW     freg$X..PALS     freg$LEDEXP2    freg$STAFFSIX 
##         1.553843         2.256168         1.376508         1.698070 
##   freg$LDCODEREG  freg$STAFFCODES            LPALS 
##         1.505011         1.913060         1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.651263
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] 1.14215e-16
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## 
## Number of bootstrap replications R = 991 
##                   original   bootBias   bootSE    bootMed
## (Intercept)       0.773149 -0.0117094 0.512550  0.7696896
## ED.MD             0.019490 -0.0011364 0.124101  0.0306014
## RT               -0.024375 -0.0034516 0.135527 -0.0229196
## NUMB             -0.015486  0.0059371 0.082552 -0.0122750
## freg$LeaderTWbin -0.012636 -0.0129058 0.169199 -0.0097583
## freg$X..TW       -0.030628 -0.0087547 0.382264 -0.0291101
## freg$X..PALS     -0.129467 -0.0478203 0.933980 -0.1268113
## freg$LEDEXP2     -0.023418  0.0036551 0.051486 -0.0222434
## freg$STAFFSIX     0.090573 -0.0030826 0.495715  0.0817570
## freg$LDCODEREG    0.022728  0.0048745 0.071045  0.0241231
## freg$STAFFCODES   0.076747 -0.0227580 1.630457  0.0904374
## LPALS            -0.020319 -0.0082181 0.150356 -0.0300588
## Bootstrap normal confidence intervals
## 
##                     Estimate         5 %       95 %
## (Intercept)       0.77314874 -0.05821157 1.62792782
## ED.MD             0.01949043 -0.18350133 0.22475494
## RT               -0.02437547 -0.24384567 0.20199785
## NUMB             -0.01548592 -0.15720874 0.11436264
## freg$LeaderTWbin -0.01263592 -0.27803823 0.27857804
## freg$X..TW       -0.03062819 -0.65064243 0.60689550
## freg$X..PALS     -0.12946678 -1.61790742 1.45461454
## freg$LEDEXP2     -0.02341769 -0.11175962 0.05761411
## freg$STAFFSIX     0.09057297 -0.72172289 0.90903394
## freg$LDCODEREG    0.02272790 -0.09900531 0.13471203
## freg$STAFFCODES   0.07674716 -2.58235866 2.78136906
## LPALS            -0.02031880 -0.25941358 0.23521220

\

residualPlots(fit12)

##                  Test stat Pr(>|Test stat|)  
## ED.MD              -1.4858          0.16543  
## RT                 -0.3036          0.76709  
## NUMB               -0.2616          0.79850  
## freg$LeaderTWbin    1.0755          0.30518  
## freg$X..TW          0.0715          0.94430  
## freg$X..PALS        1.4784          0.16736  
## freg$LEDEXP2       -2.4659          0.03135 *
## freg$STAFFSIX       0.8382          0.41977  
## freg$LDCODEREG     -0.6528          0.52732  
## freg$STAFFCODES    -0.3888          0.70485  
## LPALS               1.1960          0.25683  
## Tukey test         -0.0823          0.93441  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.3.3 CTSDelta

freg$CTSDELTA<-freg$CTSPost - freg$CTSPre

fit13<- lm(CTSDELTA ~ ED.MD + RT + NUMB + freg$LeaderTWbin + freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + freg$LDCODEREG + freg$STAFFCODES + LPALS, data=freg)
summary(fit13)
## 
## Call:
## lm(formula = CTSDELTA ~ ED.MD + RT + NUMB + freg$LeaderTWbin + 
##     freg$X..TW + freg$X..PALS + freg$LEDEXP2 + freg$STAFFSIX + 
##     freg$LDCODEREG + freg$STAFFCODES + LPALS, data = freg)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.154521 -0.040586 -0.005528  0.072272  0.171339 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)
## (Intercept)       0.350960   0.217482   1.614    0.133
## ED.MD            -0.027906   0.056414  -0.495    0.630
## RT               -0.019970   0.058318  -0.342    0.738
## NUMB             -0.007350   0.015168  -0.485    0.637
## freg$LeaderTWbin -0.048671   0.065092  -0.748    0.469
## freg$X..TW        0.015222   0.137681   0.111    0.914
## freg$X..PALS     -0.132449   0.201467  -0.657    0.523
## freg$LEDEXP2     -0.002163   0.018123  -0.119    0.907
## freg$STAFFSIX    -0.027398   0.155665  -0.176    0.863
## freg$LDCODEREG   -0.002414   0.024643  -0.098    0.924
## freg$STAFFCODES  -0.066184   0.157231  -0.421    0.681
## LPALS            -0.003017   0.062112  -0.049    0.962
## 
## Residual standard error: 0.1145 on 12 degrees of freedom
## Multiple R-squared:  0.1981, Adjusted R-squared:  -0.5369 
## F-statistic: 0.2696 on 11 and 12 DF,  p-value: 0.9811
PostEstReg(DepVarVec = freg$CTSDELTA, RegObj = fit13)
## [1] "VIF:"
##            ED.MD               RT             NUMB freg$LeaderTWbin 
##         2.659458         1.556105         1.490595         1.884752 
##       freg$X..TW     freg$X..PALS     freg$LEDEXP2    freg$STAFFSIX 
##         1.553843         2.256168         1.376508         1.698070 
##   freg$LDCODEREG  freg$STAFFCODES            LPALS 
##         1.505011         1.913060         1.752870

## [1] ""
## [1] ""
## [1] ""
## [1] ""
## [1] "correlation of actual and fitted"
## [1] 0.4451374
## [1] ""
## [1] ""
## [1] "correlation of predicted values and residuals"
## [1] -3.394721e-16
## [1] ""
## [1] ""
## [1] "Bootstrapped regression..."
## 
## Number of bootstrap replications R = 999 
##                    original    bootBias   bootSE     bootMed
## (Intercept)       0.3509595 -0.02115166 1.073547  0.34893345
## ED.MD            -0.0279055 -0.01968903 0.305071 -0.02724498
## RT               -0.0199700 -0.01968962 0.173990 -0.04102681
## NUMB             -0.0073499 -0.00026968 0.118294 -0.00583900
## freg$LeaderTWbin -0.0486705 -0.00787419 0.390572 -0.05864105
## freg$X..TW        0.0152223  0.00700997 0.613647  0.03320488
## freg$X..PALS     -0.1324486  0.08193324 1.703758 -0.11690642
## freg$LEDEXP2     -0.0021634  0.00724656 0.078972 -0.00017402
## freg$STAFFSIX    -0.0273977 -0.03796575 0.790798 -0.04866812
## freg$LDCODEREG   -0.0024143 -0.00469481 0.351048  0.00177152
## freg$STAFFCODES  -0.0661840  0.03321301 1.196170 -0.06492926
## LPALS            -0.0030169  0.00415726 0.184171 -0.00724722
## Bootstrap normal confidence intervals
## 
##                      Estimate        5 %      95 %
## (Intercept)       0.350959522 -1.3937157 2.1379381
## ED.MD            -0.027905520 -0.5100142 0.4935812
## RT               -0.019970006 -0.2864681 0.2859074
## NUMB             -0.007349857 -0.2016567 0.1874964
## freg$LeaderTWbin -0.048670518 -0.6832295 0.6016368
## freg$X..TW        0.015222286 -1.0011465 1.0175712
## freg$X..PALS     -0.132448598 -3.0168140 2.5880504
## freg$LEDEXP2     -0.002163356 -0.1393066 0.1204867
## freg$STAFFSIX    -0.027397716 -1.2901786 1.3113147
## freg$LDCODEREG   -0.002414293 -0.5751415 0.5797025
## freg$STAFFCODES  -0.066184032 -2.0669224 1.8681283
## LPALS            -0.003016942 -0.3101080 0.2957596

\

residualPlots(fit13)

##                  Test stat Pr(>|Test stat|)  
## ED.MD              -0.2541          0.80413  
## RT                 -0.2394          0.81520  
## NUMB                0.3817          0.70994  
## freg$LeaderTWbin    2.1092          0.05866 .
## freg$X..TW          0.2754          0.78814  
## freg$X..PALS        0.8676          0.40413  
## freg$LEDEXP2       -0.9805          0.34791  
## freg$STAFFSIX      -0.0313          0.97562  
## freg$LDCODEREG      0.5779          0.57494  
## freg$STAFFCODES     0.0866          0.93252  
## LPALS               1.1211          0.28611  
## Tukey test          0.1958          0.84478  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.4 Independent variable correlations

cor(freg[c("ED.MD", "RT", "Pharm", "NUMB","LeaderTWbin", "X..TW", "X..PALS", "LEDEXP2", "STAFFSIX", "LDCODEREG", "STAFFCODES")])
##                   ED.MD          RT       Pharm         NUMB LeaderTWbin
## ED.MD        1.00000000 -0.30831321  0.17513348 -0.099686506 -0.38564688
## RT          -0.30831321  1.00000000  0.08606630  0.465061815  0.00000000
## Pharm        0.17513348  0.08606630  1.00000000  0.337363248  0.30550505
## NUMB        -0.09968651  0.46506181  0.33736325  1.000000000 -0.04866321
## LeaderTWbin -0.38564688  0.00000000  0.30550505 -0.048663206  1.00000000
## X..TW       -0.17093398  0.15356711 -0.16267019 -0.035229490  0.27022506
## X..PALS     -0.28718487  0.25342902  0.07654671  0.231060976  0.04202907
## LEDEXP2     -0.27335411  0.08260358 -0.09242199 -0.127442791  0.20012993
## STAFFSIX    -0.10414788  0.05621465 -0.04024492  0.005149436 -0.17233192
## LDCODEREG   -0.22520343  0.07161149  0.16641006  0.147488117  0.25419556
## STAFFCODES  -0.31811800  0.23100031 -0.22288030  0.241155275 -0.14042924
##                     X..TW     X..PALS       LEDEXP2     STAFFSIX
## ED.MD       -0.1709339759 -0.28718487 -0.2733541074 -0.104147880
## RT           0.1535671119  0.25342902  0.0826035775  0.056214652
## Pharm       -0.1626701858  0.07654671 -0.0924219921 -0.040244919
## NUMB        -0.0352294905  0.23106098 -0.1274427914  0.005149436
## LeaderTWbin  0.2702250594  0.04202907  0.2001299264 -0.172331918
## X..TW        1.0000000000 -0.23561896 -0.0004336818 -0.057511233
## X..PALS     -0.2356189573  1.00000000 -0.1150719584  0.428590107
## LEDEXP2     -0.0004336818 -0.11507196  1.0000000000  0.140361290
## STAFFSIX    -0.0575112329  0.42859011  0.1403612899  1.000000000
## LDCODEREG   -0.2182515138  0.11094511  0.2070377769 -0.082159140
## STAFFCODES   0.1416727951 -0.13223828  0.0623773789  0.131813183
##               LDCODEREG  STAFFCODES
## ED.MD       -0.22520343 -0.31811800
## RT           0.07161149  0.23100031
## Pharm        0.16641006 -0.22288030
## NUMB         0.14748812  0.24115527
## LeaderTWbin  0.25419556 -0.14042924
## X..TW       -0.21825151  0.14167280
## X..PALS      0.11094511 -0.13223828
## LEDEXP2      0.20703778  0.06237738
## STAFFSIX    -0.08215914  0.13181318
## LDCODEREG    1.00000000  0.25335802
## STAFFCODES   0.25335802  1.00000000
cor(freg[c("ED.MD", "RT", "NUMB","LeaderTWbin", "X..TW", "X..PALS", "LEDEXP2", "STAFFSIX", "LDCODEREG", "STAFFCODES")]) 
##                   ED.MD          RT         NUMB LeaderTWbin         X..TW
## ED.MD        1.00000000 -0.30831321 -0.099686506 -0.38564688 -0.1709339759
## RT          -0.30831321  1.00000000  0.465061815  0.00000000  0.1535671119
## NUMB        -0.09968651  0.46506181  1.000000000 -0.04866321 -0.0352294905
## LeaderTWbin -0.38564688  0.00000000 -0.048663206  1.00000000  0.2702250594
## X..TW       -0.17093398  0.15356711 -0.035229490  0.27022506  1.0000000000
## X..PALS     -0.28718487  0.25342902  0.231060976  0.04202907 -0.2356189573
## LEDEXP2     -0.27335411  0.08260358 -0.127442791  0.20012993 -0.0004336818
## STAFFSIX    -0.10414788  0.05621465  0.005149436 -0.17233192 -0.0575112329
## LDCODEREG   -0.22520343  0.07161149  0.147488117  0.25419556 -0.2182515138
## STAFFCODES  -0.31811800  0.23100031  0.241155275 -0.14042924  0.1416727951
##                 X..PALS       LEDEXP2     STAFFSIX   LDCODEREG  STAFFCODES
## ED.MD       -0.28718487 -0.2733541074 -0.104147880 -0.22520343 -0.31811800
## RT           0.25342902  0.0826035775  0.056214652  0.07161149  0.23100031
## NUMB         0.23106098 -0.1274427914  0.005149436  0.14748812  0.24115527
## LeaderTWbin  0.04202907  0.2001299264 -0.172331918  0.25419556 -0.14042924
## X..TW       -0.23561896 -0.0004336818 -0.057511233 -0.21825151  0.14167280
## X..PALS      1.00000000 -0.1150719584  0.428590107  0.11094511 -0.13223828
## LEDEXP2     -0.11507196  1.0000000000  0.140361290  0.20703778  0.06237738
## STAFFSIX     0.42859011  0.1403612899  1.000000000 -0.08215914  0.13181318
## LDCODEREG    0.11094511  0.2070377769 -0.082159140  1.00000000  0.25335802
## STAFFCODES  -0.13223828  0.0623773789  0.131813183  0.25335802  1.00000000

3 ICC calculations

3.1 Prepare the data

library(xlsx)
library(irr)
fjicc <- read.xlsx(file="Jafri-ICC-20190625.xlsx", sheetIndex = 1, header=TRUE)
# View(fjicc)

# names(fjicc)

3.2 ICC calculation for CPT

fjcpticc <- fjicc[c("CPT_J", "CPT_S", "CPT_K")]
# View(fjcpticc)
icc(fjcpticc, model="twoway", type="agreement", unit="single")
##  Single Score Intraclass Correlation
## 
##    Model: twoway 
##    Type : agreement 
## 
##    Subjects = 48 
##      Raters = 3 
##    ICC(A,1) = 0.528
## 
##  F-Test, H0: r0 = 0 ; H1: r0 > 0 
##  F(47,34.1) = 5.44 , p = 7.19e-07 
## 
##  95%-Confidence Interval for ICC Population Values:
##   0.317 < ICC < 0.696

3.3 ICC calculation for CTS

fjctsicc <- fjicc[c("CTS_J", "CTS_S", "CTS_K")]
# View(fjctsicc)
icc(fjctsicc, model="twoway", type="agreement", unit="single")
##  Single Score Intraclass Correlation
## 
##    Model: twoway 
##    Type : agreement 
## 
##    Subjects = 48 
##      Raters = 3 
##    ICC(A,1) = 0.43
## 
##  F-Test, H0: r0 = 0 ; H1: r0 > 0 
##  F(47,21.8) = 4.5 , p = 0.000174 
## 
##  95%-Confidence Interval for ICC Population Values:
##   0.185 < ICC < 0.631