diff --git a/R/sim_all.R b/R/sim_all.R index 671e767240f6f2509bb47575d999f737a268c1db..e61449c0cea0d2e6d8a2eae60c4fe66cce3f446c 100644 --- a/R/sim_all.R +++ b/R/sim_all.R @@ -27,7 +27,7 @@ #' bheight2=0.25, #' bheight3=0.50) #' -sim_all <- function(nosim=2, resps, destype=NULL, designpath, u, bcoeff, decisiongroups = c(0,1), manipulations = list(), estimate = TRUE, chunks=1){ +sim_all <- function(nosim=2, resps, destype=NULL, designpath, u, bcoeff, decisiongroups = c(0,1), manipulations = list(), estimate = TRUE, chunks=1, utility_transform_type = "simple"){ ################################################# ########## Input Validation Test ############### @@ -116,7 +116,7 @@ sim_all <- function(nosim=2, resps, destype=NULL, designpath, u, bcoeff, decisio tictoc::tic() all_designs<- purrr::map(designfile, sim_choice, - no_sim= nosim,respondents = resps, destype=destype, ut=u, bcoefficients = bcoeff, decisiongroups = decisiongroups, manipulations = manipulations, estimate = estimate, chunks =chunks) %>% ## iterate simulation over all designs + no_sim= nosim,respondents = resps, destype=destype, ut=u, bcoefficients = bcoeff, decisiongroups = decisiongroups, manipulations = manipulations, estimate = estimate, chunks =chunks, utility_transform_type = utility_transform_type) %>% ## iterate simulation over all designs stats::setNames(designname) diff --git a/R/sim_choice.R b/R/sim_choice.R index a131f85045f5c4b487f2e851448ebfe55b106a04..84db8cdfcf6574d6764e748c18e87b3605ad990e 100644 --- a/R/sim_choice.R +++ b/R/sim_choice.R @@ -34,6 +34,18 @@ sim_choice <- function(designfile, no_sim=10, respondents=330,ut ,destype=destyp } + + mnl_U <- switch( + utility_transform_type, + "simple" = transform_util(), + "exact" = transform_util2(), + stop("Invalid utility_transform_type. Use 'simple' or 'exact'.") + ) + + #### Print selected utility function + cat("Transformed utility function (type:", utility_transform_type, "):\n") + print(mnl_U) + #### Function to simulate and estimate #### estimate_sim <- function(run=1) { #start loop