-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_estimations_and_save.R
74 lines (59 loc) · 2.03 KB
/
run_estimations_and_save.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
source("R/init.R")
source("R/refy.R")
source("R/refy_mult_factor.R")
source("R/refy_distributions.R")
source("R/save_ref_dist.R")
source("R/full_refy_estimate_save.R")
# 1) Create rm object
dt_ref <- refy(gls = gls,
dsm = dsm,
pinv = pinv,
dl_aux = dl_aux) |>
refy_mult_factor()
# 2) create full input list
full_list <-
lapply(as.list(dt_ref$country_code |> funique()),
FUN = \(x) {
l <- c(as.list(x),
list(dt_ref$reporting_year |>
funique()))
names(l) <- c("country_code", "year")
l
})
# 3) Test with specific, small choices:
full_refy_estimate_save(df_refy = dt_ref,
cntry_refy = list(list(country_code = "SYR",
year = 2007)),#,
#list(country_code = "COL",
#year = 2000:2005)),
path = output_dir_refy,
gls = gls)
# 4) Run entire saving process
t1 <- Sys.time()
full_refy_estimate_save(df_refy = dt_ref,
cntry_refy = full_list,
path = output_dir_refy,
gls = gls)
t2 <- Sys.time()
print(t2 - t1)
# Optional below
# 5) list from specific country: NGA
full_list_from_nga <-
lapply(as.list(funique(dt_ref$country_code)[
which(funique(dt_ref$country_code) == "NGA"):
length(funique(dt_ref$country_code))]),
FUN = \(x) {
l <- c(as.list(x),
list(dt_ref$reporting_year |>
funique()))
names(l) <- c("country_code", "year")
l
})
# 6) save from chosen country
t1 <- Sys.time()
full_refy_estimate_save(df_refy = dt_ref,
cntry_refy = full_list_from_nga,
path = output_dir_refy,
gls = gls)
t2 <- Sys.time()
print(t2 - t1)