Skip to content
Snippets Groups Projects
Commit 3eecbb81 authored by dj44vuri's avatar dj44vuri
Browse files

working again after errors

parent bdb9338e
No related branches found
No related tags found
No related merge requests found
...@@ -118,10 +118,7 @@ u<-list( ...@@ -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 , 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 ) 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 ## this function will be called before the data is simulated
......
...@@ -42,7 +42,7 @@ sim_choice <- function(designfile, no_sim=10, respondents=330, mnl_U,utils=u ) { ...@@ -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 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")) print( exists("sou_gis"))
# browser() # browser()
...@@ -60,22 +60,17 @@ cat("does sou_gis exist") ...@@ -60,22 +60,17 @@ cat("does sou_gis exist")
print("DANGER")
print(exists("final_set")) print(exists("final_set"))
if(exists("final_set")) data = left_join(data,final_set, by = "ID") if(exists("final_set")) data = left_join(data,final_set, by = "ID")
data <- data %>% data <- data %>%
# rename(ID="RID") %>%
group_by(ID) %>% group_by(ID) %>%
#rename(ID ="RID") %>%
#rename_with(~ stringr::str_replace(.,pattern = "\\.","_"), everything()) %>%
mutate(!!! manipulations , 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 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()) %>% rename_with(~ stringr::str_replace(.,pattern = "\\.","_"), everything()) %>%
mutate(across(.cols=n,.fns = ~ rgumbel(setpp,loc=0, scale=1), .names = "{'e'}_{n}" ), 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() %>% across(starts_with("V_"), .names = "{'U'}_{n}") + across(starts_with("e_")) ) %>% ungroup() %>%
mutate(CHOICE=max.col(.[,grep("U_",names(.))]) mutate(CHOICE=max.col(.[,grep("U_",names(.))])
......
...@@ -15,7 +15,7 @@ source(params$file) ...@@ -15,7 +15,7 @@ source(params$file)
designfile<-list.files(designpath,full.names = T) designfile<-list.files(designpath,full.names = T)
designname <- str_remove_all(list.files(designpath,full.names = F), 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) #plan(multisession, workers = 8)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment