The do_steps
function calculates steps for data points represented by numbers of questions from the original
experimental or survey data in x
and remaining percent of participants in y
.
Details
Due to the nature of dropout/ survival data, step functions are necessary to accurately depict participants remaining. Dropout data includes the time until the event (a.k.a. dropout at a certain question or time), so that changes in remaining participants are discrete rather than continuous. This means that changes in survival probability occur at specific points and are better represented as steps than as a continuum.
Examples
x <- c(1, 2, 3, 4, 5)
y <- c(100, 100, 95, 90, 85)
do_steps(x, y)
#> x y
#> 1 1 100
#> 2 3 100
#> 3 3 95
#> 4 4 95
#> 5 4 90
#> 6 5 90
#> 7 5 85
# Using the example dataset dropRdemo
do_stats <- compute_stats(df = add_dropout_idx(dropRdemo, 3:54),
by_cond = "experimental_condition",
no_of_vars = 52)
tot_stats <- do_stats[do_stats$condition == "total", ]
do_steps(tot_stats$q_idx, tot_stats$pct_remain)
#> x y
#> 1 1 0.9593496
#> 2 2 0.9593496
#> 3 2 0.9471545
#> 4 3 0.9471545
#> 5 3 0.9105691
#> 6 4 0.9105691
#> 7 4 0.8983740
#> 8 5 0.8983740
#> 9 5 0.8943089
#> 10 6 0.8943089
#> 11 6 0.8780488
#> 12 7 0.8780488
#> 13 7 0.8617886
#> 14 8 0.8617886
#> 15 8 0.8536585
#> 16 9 0.8536585
#> 17 9 0.8495935
#> 18 10 0.8495935
#> 19 10 0.8333333
#> 20 11 0.8333333
#> 21 11 0.8292683
#> 22 12 0.8292683
#> 23 12 0.8008130
#> 24 15 0.8008130
#> 25 15 0.7926829
#> 26 16 0.7926829
#> 27 16 0.7886179
#> 28 17 0.7886179
#> 29 17 0.7845528
#> 30 18 0.7845528
#> 31 18 0.7723577
#> 32 19 0.7723577
#> 33 19 0.7642276
#> 34 20 0.7642276
#> 35 20 0.7601626
#> 36 21 0.7601626
#> 37 21 0.7520325
#> 38 22 0.7520325
#> 39 22 0.7439024
#> 40 23 0.7439024
#> 41 23 0.7357724
#> 42 25 0.7357724
#> 43 25 0.7276423
#> 44 26 0.7276423
#> 45 26 0.7235772
#> 46 27 0.7235772
#> 47 27 0.7195122
#> 48 28 0.7195122
#> 49 28 0.7154472
#> 50 29 0.7154472
#> 51 29 0.7113821
#> 52 30 0.7113821
#> 53 30 0.7073171
#> 54 31 0.7073171
#> 55 31 0.7032520
#> 56 32 0.7032520
#> 57 32 0.6991870
#> 58 33 0.6991870
#> 59 33 0.6951220
#> 60 34 0.6951220
#> 61 34 0.6910569
#> 62 35 0.6910569
#> 63 35 0.6788618
#> 64 36 0.6788618
#> 65 36 0.6707317
#> 66 37 0.6707317
#> 67 37 0.6666667
#> 68 39 0.6666667
#> 69 39 0.6626016
#> 70 40 0.6626016
#> 71 40 0.6544715
#> 72 44 0.6544715
#> 73 44 0.6504065
#> 74 45 0.6504065
#> 75 45 0.6422764
#> 76 46 0.6422764
#> 77 46 0.6341463
#> 78 47 0.6341463
#> 79 47 0.6260163
#> 80 48 0.6260163
#> 81 48 0.6219512
#> 82 51 0.6219512
#> 83 51 0.6178862
#> 84 52 0.6178862