Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbc_choices() with an outside good (no_choice = TRUE) #31

Open
jhelvy opened this issue Oct 12, 2023 · 0 comments
Open

cbc_choices() with an outside good (no_choice = TRUE) #31

jhelvy opened this issue Oct 12, 2023 · 0 comments

Comments

@jhelvy
Copy link
Owner

jhelvy commented Oct 12, 2023

When I use cbc_choices() with a design where no_choice = TRUE, the choices get simulated, but the model always has NA for the standard errors. There may need to be a special argument for handling the no_choice variable, similar to the prior_no_choice argument in cbc_design(). Here is an example:

# Load libraries
library(cbcTools)
library(logitr)

# Define profiles with attributes and levels
profiles <- cbc_profiles(
    price       = c(15, 20, 25), # Price ($1,000)
    fuelEconomy = c(20, 25, 30),   # Fuel economy (mpg)
    accelTime   = c(6, 7, 8),      # 0-60 mph acceleration time (s)
    powertrain  = c("Gasoline", "Electric")
)

# Make a full-factorial design of experiment
design <- cbc_design(
    profiles = profiles,
    n_resp   = 1000, # Number of respondents
    n_alts   = 3,    # Number of alternatives per question
    n_q      = 8,     # Number of questions per respondent
    no_choice = TRUE
)

# Simulate choices according to an assumed utility model
data <- cbc_choices(
    design = design,
    obsID = "obsID",
    priors = list(
        price       = -0.7,
        fuelEconomy = 0.1,
        accelTime   = -0.2,
        powertrain_Electric = -4.0,
        no_choice = -2
    )
)

# Estimate a model 
model <- logitr(
  data   = data,
  outcome = "choice",
  obsID  = "obsID",
  pars   = c(
      "price", "fuelEconomy", "accelTime", "powertrain_Electric", "no_choice"
  )
)

summary(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant