diff --git a/Projects/ValuGaps/parameters_valugaps.R b/Projects/ValuGaps/parameters_valugaps.R index 3136816180303f8c1269336b05edb3801a966da7..5ad0969c4d4a7afb015851e29bd179ab84ff41b6 100644 --- a/Projects/ValuGaps/parameters_valugaps.R +++ b/Projects/ValuGaps/parameters_valugaps.R @@ -118,10 +118,7 @@ u<-list( v2 =V.2~ basc + bb * alt2.protected + bb2 * alt2.protectedsq + bc * alt2.HNV + bc2 * alt2.HNVsq + bp * alt2.p , v3 =V.3~ bb * alt3.protected + bb2 * alt3.protectedsq + bc * alt3.HNV + bc2 * alt3.HNVsq ) -# u<-list( -# v1 =V.1~ basc + bb*alt1.b+ bc * alt1.c + bp * alt1.p , -# v2 =V.2~ basc + bb*alt2.b+ bc * alt2.c + bp * alt2.p , -# v3 =V.3~ 0) + ## this function will be called before the data is simulated diff --git a/functions.R b/functions.R index ac0a69144d5aa8e655f8255001a9618ad16c3b1e..9302e8d7c425c18ea28f1d63fe9b471d392eefae 100644 --- a/functions.R +++ b/functions.R @@ -42,7 +42,7 @@ sim_choice <- function(designfile, no_sim=10, respondents=330, mnl_U,utils=u ) { simulate_choices <- function(data=datadet) { #the part in dataset that needs to be repeated in each run -cat("does sou_gis exist") +cat("does sou_gis exist: ") print( exists("sou_gis")) # browser() @@ -60,22 +60,17 @@ cat("does sou_gis exist") - print("DANGER") + print(exists("final_set")) if(exists("final_set")) data = left_join(data,final_set, by = "ID") data <- data %>% - # rename(ID="RID") %>% group_by(ID) %>% - - #rename(ID ="RID") %>% - #rename_with(~ stringr::str_replace(.,pattern = "\\.","_"), everything()) %>% mutate(!!! manipulations , map_dfc(utils,by_formula)) %>% #our functions to create utility variables. They need to be entered as a formula list as an argument rename_with(~ stringr::str_replace(.,pattern = "\\.","_"), everything()) %>% - mutate(across(.cols=n,.fns = ~ rgumbel(setpp,loc=0, scale=1), .names = "{'e'}_{n}" ), across(starts_with("V_"), .names = "{'U'}_{n}") + across(starts_with("e_")) ) %>% ungroup() %>% mutate(CHOICE=max.col(.[,grep("U_",names(.))]) diff --git a/simulationcore_purrr.R b/simulationcore_purrr.R index a64f05705e0ac0aa1bf67661eaa44a3f3a87e8d7..fc9bb5b672de916023fd6eb07a3bce708e9618b5 100644 --- a/simulationcore_purrr.R +++ b/simulationcore_purrr.R @@ -15,7 +15,7 @@ source(params$file) designfile<-list.files(designpath,full.names = T) designname <- str_remove_all(list.files(designpath,full.names = F), - "(.ngd|_)") ## Make sure it designnames to not contain file ending and "_", as the may cause issues when replace + "(.ngd|_)") ## Make sure designnames to not contain file ending and "_", as the may cause issues when replace #plan(multisession, workers = 8)