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

working again after errors

parent 90d79ed3
No related branches found
No related tags found
No related merge requests found
...@@ -36,3 +36,4 @@ u<-list( ...@@ -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, 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) v3 =V.3 ~ basc)
remotes::
\ No newline at end of file
...@@ -82,7 +82,7 @@ protected_areas <- mask(protected_areas, vect(germany_geo_c)) ...@@ -82,7 +82,7 @@ protected_areas <- mask(protected_areas, vect(germany_geo_c))
#### Define simulation parameters #### #### Define simulation parameters ####
resps = 96 # number of respondents 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 <- 15000
buffer_dist_ls <- list(10000, 15000, 25000, 50000) # define radius for the respondents in meter buffer_dist_ls <- list(10000, 15000, 25000, 50000) # define radius for the respondents in meter
......
...@@ -159,7 +159,7 @@ as.data.frame() ...@@ -159,7 +159,7 @@ as.data.frame()
pivot_wider(names_from = rowname, values_from = c(est, rob_pval0)) ) %>% pivot_wider(names_from = rowname, values_from = c(est, rob_pval0)) ) %>%
bind_rows(.id = "run") bind_rows(.id = "run")
output[["summary"]] <-describe(coefs[,-1], fast = TRUE) output[["summary"]] <-psych::describe(coefs[,-1], fast = TRUE)
output[["coefs"]] <-coefs output[["coefs"]] <-coefs
......
...@@ -6,8 +6,9 @@ rm(list=ls()) ...@@ -6,8 +6,9 @@ rm(list=ls())
rmarkdown::render("simulation_output.rmd", rmarkdown::render("simulation_output.rmd",
output_file = paste0(stringr::str_remove_all(file, output_file = paste0(
"parameters_|.R$"),".html"), stringr::str_remove_all(
file,"parameters_|.R$"),".html"),
params = list(file=file) params = list(file=file)
) )
......
...@@ -3,7 +3,7 @@ title: "Simulation experimental design" ...@@ -3,7 +3,7 @@ title: "Simulation experimental design"
author: "" author: ""
date: "2023-01-05" date: "2023-01-05"
params: params:
file: "parameters_d.R" file: "Projects/SE_DRIVE/parameters_SE_DRIVE.R"
format: format:
html: html:
embed-resources: true embed-resources: true
...@@ -20,41 +20,30 @@ knitr::opts_chunk$set(echo = TRUE) ...@@ -20,41 +20,30 @@ knitr::opts_chunk$set(echo = TRUE)
source("simulationcore_purrr.R" ,echo = TRUE) source("simulationcore_purrr.R" ,echo = TRUE)
# retrieve the values of the objects starting with "b" using mget() # retrieve the values of the objects starting with "b" using mget()
b_values <- mget(ls(pattern = "^b")) # b_values <- mget(ls(pattern = "^b"))
#
# combine the values into a named vector using c() # # combine the values into a named vector using c()
combined_vector <- c(b_values) # combined_vector <- c(b_values)
#
# add names to the vector based on the original object names # # add names to the vector based on the original object names
names(combined_vector) <- names(b_values) # names(combined_vector) <- names(b_values)
#
# print the resulting named vector # # print the resulting named vector
print(combined_vector) # print(combined_vector)
``` ```
The simulation has `r resps` respondents and `r nosim` runs. 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,])
```
......
...@@ -34,14 +34,14 @@ time <- tictoc::toc() ...@@ -34,14 +34,14 @@ time <- tictoc::toc()
print(time) print(time)
all_designs[["time"]]=time
powa <- map(all_designs, ~ .x$power) 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")) %>% dplyr::select(!ends_with("vars")) %>%
relocate(ends_with(c(".n", "mean","sd", "min" ,"max", "range" , "se" ))) 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")))) { ...@@ -70,5 +70,5 @@ for (att in names(dplyr::select(s,-c("design","run")))) {
do.call(grid.arrange,p) do.call(grid.arrange,p)
all_designs[["time"]]=time
#saveRDS(all_designs, file = paste0("output/",respondents,"_",no_sim,"runs_4designs_mixl.RDS")) #saveRDS(all_designs, file = paste0("output/",respondents,"_",no_sim,"runs_4designs_mixl.RDS"))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment