diff --git a/R/readdesign.R b/R/readdesign.R index 889094835f13a6b0a00ebe6e0c5227ae0e4a1352..781b964d98dc81f5dd6fa6c49a04a87fa49601a0 100644 --- a/R/readdesign.R +++ b/R/readdesign.R @@ -33,7 +33,10 @@ readdesign <- function(design = designfile, designtype = destype) { "spdesign" = as.data.frame(readRDS(design)) %>% dplyr::mutate(Choice.situation = 1:dplyr::n()) %>% dplyr::rename_with(~ stringr::str_replace(., pattern = "_", "\\."), tidyr::everything()) %>% - dplyr::rename(Block=block), + dplyr::rename_with(~ dplyr::case_when( + . == "block" ~ "Block", + TRUE ~ . + ), tidyr::everything()), stop("Invalid value for design. Please provide either 'ngene' or 'spdesign'.") ) } diff --git a/R/simulate_choices.R b/R/simulate_choices.R index 4066d356b1f850eac8166ab1bf4e240c822f2a05..5cb9a34be0e5d1c537cfbafcf25931dc78a78aa9 100644 --- a/R/simulate_choices.R +++ b/R/simulate_choices.R @@ -9,23 +9,14 @@ #' #' @examples \dontrun{simulate_choices(datadet, ut,setspp)} simulate_choices <- function(data, utility, setspp, destype, bcoefficients) { #the part in dataset that needs to be repeated in each run -<<<<<<< HEAD - -### unpack the bcoeff list - bsq <- bcoefficients$bsq - bredkite <- bcoefficients$bredkite - bdistance <- bcoefficients$bdistance - bcost <- bcoefficients$bcost - bfarm2 <- bcoefficients$bfarm2 - bfarm3 <- bcoefficients$bfarm3 - bheight2 <- bcoefficients$bheight2 - bheight3 <- bcoefficients$bheight3 -======= + + + ### unpack the bcoeff list so variables are accessible for (key in names(bcoefficients)) { assign(key, bcoefficients[[key]]) } ->>>>>>> 0c1de67f1d4f2236d97e706a4b99a89bdba8a0b3 + diff --git a/tests/manual-tests/csa.R b/tests/manual-tests/csa.R new file mode 100644 index 0000000000000000000000000000000000000000..0a7b25004f30c0d4fe9589f5b3c5cb37e0f87962 --- /dev/null +++ b/tests/manual-tests/csa.R @@ -0,0 +1,43 @@ + +rm(list=ls()) +devtools::load_all() + +#place your utility functions here + + + +set.seed(3393) + +designpath<- system.file("extdata","CSA" ,package = "simulateDCE") +#notes <- "This design consists of different heuristics. One group did not attend the methan attribute, another group only decided based on the payment" + +notes <- "No Heuristics" + +resps =240 # number of respondents +nosim=2 # number of simulations to run (about 500 is minimum) + + +bcoeff<-list( + bx1 =0.1, + bx2 =0.3, + bx3 =0.1, + bx4 =-0.2) + + +destype <- "spdesign" + + +#place your utility functions here +ul<- list(u1= list( + v1 =V.1 ~ bx1 * alt1.x1 + bx2 * alt1.x2 + bx3 * alt1.x3 + bx4 * alt1.x4, + v2 =V.2 ~ bx1 * alt2.x1 + bx2 * alt2.x2 + bx3 * alt2.x3 + bx4 * alt2.x4 +) +) + + + +csa <- simulateDCE::sim_all(nosim = nosim, resps=resps, destype = destype, + designpath = designpath, u= ul, bcoeff = bcoeff) + + +