Skip to contents

Creates choice model experimental designs according to a given algorithm.

Usage

choice_model_design(
  design.algorithm = c("Random", "Shortcut", "Efficient", "Balanced overlap",
    "Partial profiles", "Complete enumeration"),
  attribute.levels = NULL,
  prior = NULL,
  n.questions,
  n.versions = 1,
  alternatives.per.question,
  prohibitions = NULL,
  none.alternatives = 0,
  labeled.alternatives = FALSE,
  n.constant.attributes = NULL,
  output = "Labeled design",
  seed = 54123
)

Arguments

design.algorithm

The algorithm used to create the design. One of "Random", "Shortcut", "Balanced overlap", "Complete enumeration", "Efficient" and Partial profiles.

attribute.levels

list of vectors containing the labels of levels for each attribute, with names corresponding to the attribute labels; or a character matrix with first row containing attribute names and subsequent rows containing attribute levels.

prior

Character matrix containing prior values for the model coefficients; only used for design.algorithm == "Efficient"; see Details.

n.questions

Integer; the number of questions asked to each respondent.

n.versions

Integer; the number of versions of the survey to create.

alternatives.per.question

Integer; the number of alternative products shown in each question. Ignored if "labeled.alternatives" is TRUE.

prohibitions

Character matrix where each row is a prohibited alternative consisting of the levels of each attribute. If a level is "" or is "All" then all levels of that attribute in combination with the other specified attribute levels are prohibited.

none.alternatives

Integer; the number of 'None' in all questions.

labeled.alternatives

Logical; whether the first attribute labels the alternatives.

n.constant.attributes

Integer; the number of attributes to keep constant.

output

One of "Labeled design" or "Inputs".

seed

Integer; random seed to be used by the algorithms.

Value

A list with components

  • design - a numeric array of dimensions (number of questions by alternatives per question by number of attributes) where each value is the index of a level. Ignoring any none alternatives.

  • design.with.none - as per design except one additional row per none alternative is added to each question with NA for all attribute levels.

  • labeled.design - as per design.with.none except indices of levels are replaced by their labels.

  • design.algorithm - as per input.

  • attribute.levels - as per input.

  • prohibitions - as per input.

  • n.questions - as per input.

  • n.versions - as per input.

  • alternatives.per.question - as per input.

  • none.alternatives - as per input.

  • output - as per input.

  • db.error - the Db-error of design.

  • d.error - the D-error of design.

  • model.matrix - the model matrix of dummy coded variables for each alternative in every choice set.

  • balances.and.overlaps a list with components

    • singles a list of the counts of each level per attribute.

    • pairs a list of the counts of pairwise occurences of levels for each pair of attributes.

    • overlaps a vector of the percentage of questions that include one or more duplicated level per attribute.

Details

If prior is supplied and design.algorithm == "Efficient", the number of coefficients must correspond to the number of attributes/attribute levels specified in attribute.levels. If prior is NULL, the prior for the coefficients is assumed to be identically zero. If the supplied matrix contains two columns, the first column is taken as the prior mean for the coefficients and the second is taken to be the prior variances. If only one column is present, the prior for the coefficients is assumed to be centered at those values.

Examples

# "Balanced overlap"
design_bo <- choice_model_design(
  design.algorithm = "Balanced overlap",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
#> Warning: subscript out of bounds, not all 'rhs' available
#> Warning: mlogit model failed: system is computationally singular: reciprocal condition
#> number = 7.95808e-17
design_bo$labeled.design
#> # A tibble: 200 × 5
#>    Version Question Alternative brand       price_tier
#>      <dbl>    <dbl>       <dbl> <fct>       <fct>     
#>  1       1        1           1 o_organics  high      
#>  2       1        1           2 kroger      low       
#>  3       1        1           3 bowl_basket medium    
#>  4       1        1           4 NA          NA        
#>  5       1        2           1 sargento    medium    
#>  6       1        2           2 best_yet    high      
#>  7       1        2           3 o_organics  low       
#>  8       1        2           4 NA          NA        
#>  9       1        3           1 kroger      medium    
#> 10       1        3           2 sargento    low       
#> # ℹ 190 more rows

# "Random"
design_rn <- choice_model_design(
  design.algorithm = "Random",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
#> Warning: subscript out of bounds, not all 'rhs' available
#> Warning: mlogit model failed: system is computationally singular: reciprocal condition
#> number = 8.78686e-17
design_rn$labeled.design
#> # A tibble: 200 × 5
#>    Version Question Alternative brand       price_tier
#>      <dbl>    <dbl>       <dbl> <fct>       <fct>     
#>  1       1        1           1 best_yet    high      
#>  2       1        1           2 best_yet    medium    
#>  3       1        1           3 sargento    high      
#>  4       1        1           4 NA          NA        
#>  5       1        2           1 kroger      medium    
#>  6       1        2           2 bowl_basket high      
#>  7       1        2           3 kroger      low       
#>  8       1        2           4 NA          NA        
#>  9       1        3           1 sargento    low       
#> 10       1        3           2 bowl_basket medium    
#> # ℹ 190 more rows

# "Shortcut"
design_sh <- choice_model_design(
  design.algorithm = "Shortcut",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
#> Warning: subscript out of bounds, not all 'rhs' available
#> Warning: mlogit model failed: system is computationally singular: reciprocal condition
#> number = 1.46288e-17
design_sh$labeled.design
#> # A tibble: 200 × 5
#>    Version Question Alternative brand       price_tier
#>      <dbl>    <dbl>       <dbl> <fct>       <fct>     
#>  1       1        1           1 best_yet    high      
#>  2       1        1           2 bowl_basket medium    
#>  3       1        1           3 kroger      low       
#>  4       1        1           4 NA          NA        
#>  5       1        2           1 o_organics  high      
#>  6       1        2           2 sargento    medium    
#>  7       1        2           3 bowl_basket low       
#>  8       1        2           4 NA          NA        
#>  9       1        3           1 o_organics  high      
#> 10       1        3           2 best_yet    low       
#> # ℹ 190 more rows

# "Complete enumeration"
design_ce <- choice_model_design(
  design.algorithm = "Complete enumeration",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
#> Warning: subscript out of bounds, not all 'rhs' available
#> Warning: mlogit model failed: system is computationally singular: reciprocal condition
#> number = 7.95808e-17
design_ce$labeled.design
#> # A tibble: 200 × 5
#>    Version Question Alternative brand       price_tier
#>      <dbl>    <dbl>       <dbl> <fct>       <fct>     
#>  1       1        1           1 o_organics  high      
#>  2       1        1           2 kroger      low       
#>  3       1        1           3 bowl_basket medium    
#>  4       1        1           4 NA          NA        
#>  5       1        2           1 sargento    medium    
#>  6       1        2           2 best_yet    high      
#>  7       1        2           3 o_organics  low       
#>  8       1        2           4 NA          NA        
#>  9       1        3           1 kroger      medium    
#> 10       1        3           2 sargento    low       
#> # ℹ 190 more rows

# "Efficient"
if (FALSE) { # \dontrun{
design_ef <- choice_model_design(
  design.algorithm = "Efficient",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
design_ef$labeled.design

# "Partial profiles"
design_pp <- choice_model_design(
  design.algorithm = "Partial profiles",
  attribute.levels = list(
    brand = c("best_yet", "bowl_basket", "kroger", "o_organics", "sargento"),
    price_tier = c("low", "medium", "high")),
  n.questions = 10,
  n.versions = 5,
  alternatives.per.question = 3,
  none.alternatives = 1,
  labeled.alternatives = FALSE,
  n.constant.attributes = 0,
  seed = 1)
design_pp$labeled.design
} # }