Skip to content

Continuous variable choice set doesn't appear to be correct #14

@UrbanFercecNchain

Description

@UrbanFercecNchain

Dear Developers,

I am conducting a DCE experiment with 5 variables for which I would like to use your software to optimize the choice sets. For the first trial design, I have no priors, which means that values for all variable levels should be somewhat uniformly present in the result set. This appears to be the case for all discrete variables but isn't for my value of continuous variable. Specifically, in about 90% of all alternatives I get the lowest number while the highest is not even present, which to me seems like an error. I am providing you with my code below.

# Load necessary library
library(idefix)

# Set random seed for reproducibility
set.seed(123)

# Define levels for each attribute
cost_levels <- c("1.8€", "2.5€", "3.3€", "4.0", "4.5")
taste_levels <- c("Povprečen", "Dober", "Vrhunski")
environment_levels <- c("Slab", "Povprečen", "Dober", "Izjemen")
type_levels <- c("Klasična", "Posebna")
standard_levels <- c("Običajen", "Trajnostni")
code <- c("C", "D", "D", "D", "D")
alts <- 3
c_lvls <- list(c(1.8, 2.5, 3.3, 4.0, 4.5))
alt_cte <- c(0, 0, 1)

# Use 'Profiles' function to generate candidate profiles
profiles <- Profiles(lvls = c(5, 3, 4, 2, 2),
                     coding = code,
                     c.lvls = c_lvls)

# Assuming 'mu' and 'Sigma' are defined based on your prior beliefs or non-informative priors
mu <- rep(0, 9) #no prior beliefs
Sigma <- diag(rep(1, length(mu))) # Assuming independence and same variance

# Generate par.draws
draws <- MASS::mvrnorm(n = 500, mu = mu, Sigma = Sigma)

# Generate design using 'Modfed' function
design <- Modfed(cand.set = profiles,
                 n.sets = 12, # Number of choice sets to generate
                 n.alts = alts, # Including the "I want none" option
                 alt.cte = alt_cte, # Assuming the last alternative is "I want none"
                 par.draws = list(draws[, 1], draws[, 2:9]),
                 no.choice = TRUE)

# The 'design' object now contains your experimental design
print(design)

#Decode
lvls <- list(cost_levels, taste_levels, environment_levels, type_levels, standard_levels)
decode <- Decode(des = design$design,
                 lvl.names = lvls,
                 coding = code,
                 n.alts = alts,
                 c.lvls = c_lvls,
                 alt.cte = alt_cte,
                 no.choice = 3
                  )
print(decode)

If I run this, I get 1.8€ in 20 of alternatives and 3.3€ in 4. However, is it more then possible that I have made an error somewhere and that your software is working perfectly. That being said, I would kindly ask you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions