-
Notifications
You must be signed in to change notification settings - Fork 0
/
model-score-evaluation.R
52 lines (45 loc) · 1.07 KB
/
model-score-evaluation.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
library(brms)
library(data.table)
library(targets)
library(purrr)
library(here)
source(here("R", "model-score-evaluation.R"))
tar_load("rwis")
rwis_retro <- rwis[id == 0]
rwis_scenario <- rwis[id != 0]
rwis_retro <- process_rwis(rwis_retro)
rwis_scenario <- process_rwis(rwis_scenario)
summarise_rwis(rwis_retro)
summarise_rwis(rwis_scenario)
retro_fit <- brm(
bf(
log(rwis) ~ overdispersion + variant_relationship +
s(horizon_minus_one, k = 4) + s(share_delta, k = 5)
),
family = student(),
data = rwis_retro,
backend = "cmdstanr",
chains = 4,
cores = 4,
adapt_delta = 0.99,
max_treedepth = 15
)
scenario_fit <- brm(
bf(
log(rwis) ~ overdispersion + variant_relationship +
s(horizon_minus_one, k = 4) + s(share_delta, k = 5, by = delta) +
seq_samples + delta
),
family = student(),
data = rwis_scenario,
backend = "cmdstanr",
chains = 4,
cores = 4,
adapt_delta = 0.99,
max_treedepth = 15
)
checks <- map(
list("retro" = retro_fit, "scenario" = scenario_fit),
fit_checks
)
checks <- rbindlist(checks, idcol = "model")