forked from timbender-ncceh/ce_assessment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ce_montecarlo_weights.R
43 lines (30 loc) · 1.17 KB
/
ce_montecarlo_weights.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
#ce_montecarlo_weights
library(dplyr)
library(readr)
setwd("C:/Users/TimBender/Documents/R/ncceh/projects/ce_assessment")
runit <- 0
while(runit < 500){
runit <- runit + 1
rm(list=ls()[!ls() %in% c("runit")]);cat('\f');gc()
# fingerprints----
sim.fingerprint <- openssl::md5(as.character(Sys.time())) %>%
substr(., nchar(.) - 7, nchar(.))
git.raw.md5 <- read_file("https://raw.githubusercontent.com/timbender-ncceh/ncceh_data_tools/main/ce_assessment_micro.R") %>%
md5
gc()
# set weights----
override.weights <- T
weight.min <- 1
weight.max <- 10
mc.weights <- read_csv("https://raw.githubusercontent.com/timbender-ncceh/ce_assessment/main/MASTER_cw_qshortname.csv")
mc.weights$weight <- sample(weight.min:weight.max,
size = nrow(mc.weights),
replace = T) #%>% log()
for(i in 1:nrow(mc.weights)){
assign(x = mc.weights$short_name[i],
value = mc.weights$weight[i])
}
# run model----
source("https://raw.githubusercontent.com/timbender-ncceh/ce_assessment/main/ce_assessment_micro2.R")
rm(override.weights)
}