rm(list = ls(all = TRUE)) #Get package for Experimental design ready #install.packages("spdesign") #install.packages("stats") library(spdesign) library(stats) # Define list of utility functions ---- utility <- list( alt1 = "b_x1[0.1] * x1[seq(1, 100, by = 25)] + b_x2[0.3] * x2[c(0, 1)] + b_x3[0.1] * x3[c(0, 1)] + b_x4[-0.2] * x4[seq(1, 1.5, 0.1)]", alt2 = "b_x1 * x1 + b_x2 * x2 + b_x3 * x3 + b_x4 * x4" ) # Use the full factorial as the candidate set candidate_set <- full_factorial( list( alt1_x1 = seq(1, 100, by = 25), alt1_x2 = c(0, 1), alt1_x3 = c(0, 1), alt1_x4 = seq(1, 1.5, 0.1), alt2_x1 = seq(1, 100, by = 25), alt2_x2 = c(0, 1), alt2_x3 = c(0, 1), alt2_x4 = seq(1, 1.5, 0.1) ) ) #candidate_set <- candidate_set[!(candidate_set$alt1_x1 == 2 & candidate_set$alt1_x2 == 0 & candidate_set$alt1_x3 == 0), ] #candidate_set <- candidate_set[!(candidate_set$alt2_x2 == 1 & candidate_set$alt2_x3 == 1), ] # Generate designs ---- design <- generate_design(utility, rows = 20, model = "mnl", efficiency_criteria = "d-error", algorithm = "federov", draws = "scrambled-sobol", candidate_set = candidate_set) #Summary summary(design) saveRDS(design$design, "Projects/CSA/Designs/design1.RDS") write.csv2(design$design, "Projects/CSA/Designs/design1.csv")