Running Dropout related Tests with dropR

library(dropR)
data("dropRdemo")
qs <- which(grepl("vi_", names(dropRdemo)))
dropRdemo <- add_dropout_idx(dropRdemo, q_pos = qs)

stats <- compute_stats(dropRdemo,
                             by_cond = "experimental_condition",
                             no_of_vars = length(qs))

Running a Chi-sq. Test for a Selected Question

NOTE: Chi-sq. tests are only available when an column denoting the experimental condition is given.

Let’s compute a Chisq test at question 15 for experimentatl conditions 11 and 12. dropR’s dropout Chisq-Test returns a list containing the actual test results and dropout overview table at the selected question.

do_chisq(stats,
         chisq_question = 15,
         sel_cond_chisq = c('11','12'),
         p_sim = TRUE)
#> $`Test result`
#> 
#>  Pearson's Chi-squared test with simulated p-value (based on 2000
#>  replicates)
#> 
#> data:  test_table
#> X-squared = 1.1979, df = NA, p-value = 0.3253
#> 
#> 
#> $`Dropout at question 15`
#>           participants
#> conditions dropout remaining
#>         11      14        58
#>         12       7        50

Kaplan-Meier Estimation

kpm <- do_kpm(df = add_dropout_idx(dropRdemo, qs),
              condition_col = "experimental_condition",
              model_fit = "total")

kpm$model_fit
#> [1] "total"
head(kpm$steps)
#>   x         y      uppr       lwr condition
#> 1 0 0.3821138 0.4479241 0.3259726     total
#> 2 1 0.3821138 0.4479241 0.3259726     total
#> 3 1 0.3373984 0.4019727 0.2831975     total
#> 4 2 0.3373984 0.4019727 0.2831975     total
#> 5 2 0.3252033 0.3893417 0.2716307     total
#> 6 3 0.3252033 0.3893417 0.2716307     total
head(kpm$d)
#>   obs_id experimental_condition vi_1 vi_2 vi_3 vi_4 vi_5 vi_6 vi_7 vi_8 vi_9
#> 1 7a9f33                     11    1    1    1    1    1    1    1    1    1
#> 2 e11f94                     22    1   NA    1    1    1    1   NA   NA   NA
#> 3 e72a50                     22    1   NA    1    1    1    1    1    1    1
#> 4 f90f5f                     11    1    1    1    1    1    1    1    1    1
#> 5 20bc72                     12    1   NA    1    1    1    1    1    1    1
#> 6 76b97a                     22    1   NA    1    1    1    1    1    1    1
#>   vi_10 vi_11 vi_12 vi_13 vi_14 vi_15 vi_16 vi_17 vi_18 vi_19 vi_20 vi_21 vi_22
#> 1     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 2    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
#> 3     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 4     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 5     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 6     1     1     1     1     1     1     1     1     1     1     1     1     1
#>   vi_23 vi_24 vi_25 vi_26 vi_27 vi_28 vi_29 vi_30 vi_31 vi_32 vi_33 vi_34 vi_35
#> 1     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 2    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
#> 3     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 4     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 5     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 6     1     1     1     1     1    NA    NA    NA    NA    NA    NA    NA    NA
#>   vi_36 vi_37 vi_38 vi_39 vi_40 vi_41 vi_42 vi_43 vi_44 vi_45 vi_46 vi_47 vi_48
#> 1     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 2    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
#> 3     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 4     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 5     1     1     1     1     1     1     1     1     1     1     1     1     1
#> 6    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
#>   vi_49 vi_50 vi_51 vi_52 do_idx surv
#> 1     1     1     1     1      0    0
#> 2    NA    NA    NA    NA      6    6
#> 3     1     1     1     1      0    0
#> 4     1     1     1     1      0    0
#> 5     1     1     1     1      0    0
#> 6    NA    NA    NA    NA     27   27