Calculate average increase of events per visit and cumulative average increase.
Details
This is more stable than using mean cumulative patient count per visit as only a few patients will contribute to later visits. Here the impact of the later visits is reduced as they can only add or subtract to the results from earlier visits and not shift the mean independently.
Examples
df_visit <- sim_test_data_study(n_pat = 1000, n_sites = 10) %>%
dplyr::rename(
site_number = site_id,
patnum = patient_id,
n_ae = n_event
)
get_cum_mean_event_dev(df_visit)
#> # A tibble: 296 × 4
#> study_id site_number visit cum_mean_dev_ae
#> <chr> <chr> <int> <dbl>
#> 1 A S0001 1 0.94
#> 2 A S0001 2 2.93
#> 3 A S0001 3 5.16
#> 4 A S0001 4 6.71
#> 5 A S0001 5 8.18
#> 6 A S0001 6 9.54
#> 7 A S0001 7 10.2
#> 8 A S0001 8 10.7
#> 9 A S0001 9 11.0
#> 10 A S0001 10 11.2
#> # ℹ 286 more rows
get_cum_mean_event_dev(df_visit, group = "study_id")
#> # A tibble: 33 × 3
#> study_id visit cum_mean_dev_ae
#> <chr> <int> <dbl>
#> 1 A 1 0.957
#> 2 A 2 2.67
#> 3 A 3 4.70
#> 4 A 4 6.50
#> 5 A 5 7.93
#> 6 A 6 8.97
#> 7 A 7 9.66
#> 8 A 8 10.1
#> 9 A 9 10.4
#> 10 A 10 10.6
#> # ℹ 23 more rows