-
Notifications
You must be signed in to change notification settings - Fork 0
/
sbc.R
89 lines (89 loc) · 2.21 KB
/
sbc.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
sbc_targets <- list(
tar_target(
sbc_one_prior_simulations,
do.call(
generate_obs,
c(
retro_args,
list(
obs = retro_validation_obs,
datasets = sbc_datasets,
strains = 1,
model = single_model,
overdispersion = overdispersion_scenarios
)
)
)[, `:=`(
strains = 1,
overdispersion = overdispersion_scenarios
)
],
cross(retro_validation_obs, overdispersion_scenarios)
),
tar_target(
sbc_two_prior_simulations,
do.call(
generate_obs,
c(
retro_args,
list(
obs = retro_validation_obs,
datasets = sbc_datasets,
strains = 2,
model = two_model,
overdispersion = overdispersion_scenarios,
variant_relationship = variant_relationship_scenarios
)
)
)[, `:=`(
strains = 2,
overdispersion = overdispersion_scenarios,
variant_relationship = variant_relationship_scenarios
)
],
cross(retro_validation_obs, variant_relationship_scenarios,
overdispersion_scenarios)
),
tar_target(
sbc_one_posteriors,
sbc_one_prior_simulations[,
forecast := list(do.call(
forecast_data,
c(
stan_args,
list(
data = data[[1]],
strains = 1,
model = one_model
)
),
))],
map(sbc_one_prior_simulations)
),
tar_target(
sbc_two_posteriors,
sbc_two_prior_simulations[,
forecast := list(do.call(
forecast_data,
c(
stan_args,
list(
data = data[[1]],
strains = 2,
model = two_model
)
),
))],
map(sbc_two_prior_simulations)
),
# calculate coverage for one and two strain models across simulations
tar_target(
one_strain_coverage,
sbc_coverage(sbc_one_posteriors, by = c("strains", "overdispersion"))
),
tar_target(
two_strain_coverage,
sbc_coverage(sbc_two_posteriors, by = c("strains", "overdispersion",
"variant_relationship"))
)
)