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

new implementation of arguement utility_transform_type.

parent caa26fcc
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment