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

new example csa and small fix in block, solved merge errors

parent 8b05b6fe
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,10 @@ readdesign <- function(design = designfile, designtype = destype) { ...@@ -33,7 +33,10 @@ readdesign <- function(design = designfile, designtype = destype) {
"spdesign" = as.data.frame(readRDS(design)) %>% "spdesign" = as.data.frame(readRDS(design)) %>%
dplyr::mutate(Choice.situation = 1:dplyr::n()) %>% dplyr::mutate(Choice.situation = 1:dplyr::n()) %>%
dplyr::rename_with(~ stringr::str_replace(., pattern = "_", "\\."), tidyr::everything()) %>% 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'.") stop("Invalid value for design. Please provide either 'ngene' or 'spdesign'.")
) )
} }
...@@ -9,23 +9,14 @@ ...@@ -9,23 +9,14 @@
#' #'
#' @examples \dontrun{simulate_choices(datadet, ut,setspp)} #' @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 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 ### unpack the bcoeff list so variables are accessible
for (key in names(bcoefficients)) { for (key in names(bcoefficients)) {
assign(key, bcoefficients[[key]]) assign(key, bcoefficients[[key]])
} }
>>>>>>> 0c1de67f1d4f2236d97e706a4b99a89bdba8a0b3
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment