diff --git a/Projects/SE_AGRI/parameters_SE Design-Agri.R b/Projects/SE_AGRI/parameters_SE Design-Agri.R index 52e7994e13c44d9a3e41447fe465e2fb08b51378..4942c18403d95dd552bd4ece02c4fb4eaa7aac14 100644 --- a/Projects/SE_AGRI/parameters_SE Design-Agri.R +++ b/Projects/SE_AGRI/parameters_SE Design-Agri.R @@ -36,3 +36,4 @@ u<-list( v2 =V.2 ~ bprof*alt2.professional + bexp * alt2.expert + bdomestic * alt2.domestic + bforeign * alt2.foreign + bdamage*alt2.damage + bprice * alt2.compensation, v3 =V.3 ~ basc) +remotes:: \ No newline at end of file diff --git a/Projects/SE_DRIVE/simulation_DRIVE_test_files/figure-html/run_code-1.png b/Projects/SE_DRIVE/simulation_DRIVE_test_files/figure-html/run_code-1.png deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Projects/ValuGaps/parameters_valugaps.R b/Projects/ValuGaps/parameters_valugaps.R index 44ac11fe4bd92dcc83f2253936737d20bad25bcd..3136816180303f8c1269336b05edb3801a966da7 100644 --- a/Projects/ValuGaps/parameters_valugaps.R +++ b/Projects/ValuGaps/parameters_valugaps.R @@ -82,7 +82,7 @@ protected_areas <- mask(protected_areas, vect(germany_geo_c)) #### Define simulation parameters #### resps = 96 # number of respondents -nosim=100 # number of simulations to run (about 500 is minimum) +nosim=1 # number of simulations to run (about 500 is minimum) #buffer_dist <- 15000 buffer_dist_ls <- list(10000, 15000, 25000, 50000) # define radius for the respondents in meter diff --git a/functions.R b/functions.R index 1a3bbe9992c508e3efdff2d6c87be8bd0874a74c..ac0a69144d5aa8e655f8255001a9618ad16c3b1e 100644 --- a/functions.R +++ b/functions.R @@ -159,7 +159,7 @@ as.data.frame() pivot_wider(names_from = rowname, values_from = c(est, rob_pval0)) ) %>% bind_rows(.id = "run") - output[["summary"]] <-describe(coefs[,-1], fast = TRUE) + output[["summary"]] <-psych::describe(coefs[,-1], fast = TRUE) output[["coefs"]] <-coefs diff --git a/generatemd.R b/generatemd.R index 8fa2e7b2c9fd3f0ac0dcc38e4902d8a9c912a3f9..76d97fc1aa895e0bd90206ac6844aa29f4ed9bdf 100644 --- a/generatemd.R +++ b/generatemd.R @@ -6,8 +6,9 @@ rm(list=ls()) rmarkdown::render("simulation_output.rmd", - output_file = paste0(stringr::str_remove_all(file, - "parameters_|.R$"),".html"), + output_file = paste0( + stringr::str_remove_all( + file,"parameters_|.R$"),".html"), params = list(file=file) ) diff --git a/simulation_output.rmd b/simulation_output.rmd index e5cc92bda0929caf761c1e8459525d11c7077e28..f6e9be268225e4c415589315fae117f37cf6778a 100644 --- a/simulation_output.rmd +++ b/simulation_output.rmd @@ -3,7 +3,7 @@ title: "Simulation experimental design" author: "" date: "2023-01-05" params: - file: "parameters_d.R" + file: "Projects/SE_DRIVE/parameters_SE_DRIVE.R" format: html: embed-resources: true @@ -20,41 +20,30 @@ knitr::opts_chunk$set(echo = TRUE) source("simulationcore_purrr.R" ,echo = TRUE) # retrieve the values of the objects starting with "b" using mget() -b_values <- mget(ls(pattern = "^b")) - -# combine the values into a named vector using c() -combined_vector <- c(b_values) - -# add names to the vector based on the original object names -names(combined_vector) <- names(b_values) - -# print the resulting named vector -print(combined_vector) +# b_values <- mget(ls(pattern = "^b")) +# +# # combine the values into a named vector using c() +# combined_vector <- c(b_values) +# +# # add names to the vector based on the original object names +# names(combined_vector) <- names(b_values) +# +# # print the resulting named vector +# print(combined_vector) ``` The simulation has `r resps` respondents and `r nosim` runs. -The total time for estimation is `r all_designs[["time"]]`. - -the parameters used for the simulation are: -```{r, echo=FALSE} +the parameters used for the simulation are: -# print the resulting named vector -print(combined_vector) -``` -The average frequencies of choices for each alternative are -```{r, eval =FALSE} -gr<-map_dfr(seq_along(1:nosim), ~ table(all_designs[["bayeff"]][[.]][["data"]][["CHOICE"]])/length(all_designs[["bayeff"]][[1]][["data"]][["CHOICE"]])) %>% mutate(across(everything(),as.numeric)) -print(summary(gr)[4,]) -``` diff --git a/simulationcore_purrr.R b/simulationcore_purrr.R index 465189bfc6ccdac084adc8c6c524caf6cc284b69..a64f05705e0ac0aa1bf67661eaa44a3f3a87e8d7 100644 --- a/simulationcore_purrr.R +++ b/simulationcore_purrr.R @@ -34,14 +34,14 @@ time <- tictoc::toc() print(time) -all_designs[["time"]]=time + powa <- map(all_designs, ~ .x$power) -summaryall <- as.data.frame(map(all_designs, ~.x$summary)) %>% +summaryall <- as.data.frame(purrr::map(all_designs, ~.x$summary)) %>% dplyr::select(!ends_with("vars")) %>% relocate(ends_with(c(".n", "mean","sd", "min" ,"max", "range" , "se" ))) @@ -70,5 +70,5 @@ for (att in names(dplyr::select(s,-c("design","run")))) { do.call(grid.arrange,p) - +all_designs[["time"]]=time #saveRDS(all_designs, file = paste0("output/",respondents,"_",no_sim,"runs_4designs_mixl.RDS")) \ No newline at end of file