Merge results from additional or updated simulations
Source:R/merge_additional_sims.R
merge_additional_results.RdMerge results from additional or updated simulations
Usage
upsert_merge(x, y, by)
merge_additional_results(
old,
new,
design_names = NULL,
descriptive_regex = NULL
)Details
updates columns in x with values from matched rows in y and add
joins columns from y not present in x. Calls rows_upsert and then
full_join.
if design_names is omitted its value is taken from the
design_names attribute of the simulation results.
If descriptive_regex is given, columns matching the regular expression in
both datasets are compared, a warning is given, if the values of those
columns do not match. This is intended to compare descriptive statistics or
results of unchanged analysis methods to ensure, that both results stem
from an exact replication of the simulation results.
Examples
a <- data.frame(x=5:2, y=5:2, a=5:2)
b <- data.frame(x=1:4, y=1:4+10, b=1:4*10)
upsert_merge(a, b, by="x")
#> x y a b
#> 1 5 5 5 NA
#> 2 4 14 4 40
#> 3 3 13 3 30
#> 4 2 12 2 20
#> 5 1 11 NA 10
# \donttest{
condition <- merge(
assumptions_delayed_effect(),
design_fixed_followup(),
by=NULL
) |>
tail(4) |>
true_summary_statistics_delayed_effect(cutoff_stats = 15)
condition_1 <- condition[1:2, ]
condition_2 <- condition[3:4, ]
# runs simulations
sim_results_1 <- runSimulation(
design=condition_1,
replications=100,
generate=generate_delayed_effect,
analyse=list(
logrank = analyse_logrank(alternative = "one.sided"),
maxcombo = analyse_logrank(alternative = "one.sided")
),
summarise = create_summarise_function(
logrank = summarise_test(0.025),
maxcombo = summarise_test(0.025)
)
)
sim_results_2 <- runSimulation(
design=condition_2,
replications=100,
generate=generate_delayed_effect,
analyse=list(
logrank = analyse_logrank(alternative = "one.sided"),
maxcombo = analyse_logrank(alternative = "one.sided")
),
summarise = create_summarise_function(
logrank = summarise_test(0.025),
maxcombo = summarise_test(0.025)
)
)
sim_results_3 <- runSimulation(
design=condition,
replications=100,
generate=generate_delayed_effect,
analyse=list(
mwlrt = analyse_modelstly_weighted(t_star = m2d(24))
),
summarise = create_summarise_function(
mwlrt = summarise_test(0.025)
)
)
all_results <- sim_results_1 |>
merge_additional_results(sim_results_2) |>
merge_additional_results(sim_results_3)
all_results |>
subset(select=c(delay, logrank.rejection_0.025, maxcombo.rejection_0.025, mwlrt.rejection_0.025))
#> # A tibble: 4 × 4
#> delay logrank.rejection_0.025 maxcombo.rejection_0.025 mwlrt.rejection_0.025
#> <dbl> <dbl> <dbl> <dbl>
#> 1 121.75 0.9 0.9 0.89
#> 2 182.62 0.82 0.82 0.87
#> 3 243.5 0.82 0.82 0.86
#> 4 304.38 0.73 0.73 0.8
# }