choice_preferences: Define choice preferences

View source: R/choice_preferences.R

choice_preferencesR Documentation

Define choice preferences

Description

The choice_preferences object defines the deciders' preferences in the choice model.

  • choice_preferences() constructs a choice_preferences object.

  • generate_choice_preferences() samples choice preferences at random.

Usage

choice_preferences(data_frame, column_decider = colnames(data_frame)[1])

generate_choice_preferences(
  choice_effects,
  choice_parameters = NULL,
  choice_identifiers = generate_choice_identifiers(N = 100)
)

Arguments

data_frame

[data.frame]
Contains the deciders' preferences.

column_decider

[character(1) | NULL]
The column name of data_frame with the decider identifiers. If NULL, decider identifiers are generated.

choice_effects

[choice_effects]
A choice_effects object.

choice_parameters

[choice_parameters]
A choice_parameters object.

choice_identifiers

[choice_identifiers]
A choice_identifiers object.

Value

An object of class choice_preferences, which is a data.frame with the deciders' preferences. The column names are the names of the effects in the choice model. The first column contains the decider identifiers.

Examples

### generate choice preferences from choice parameters and effects
choice_effects <- choice_effects(
  choice_formula = choice_formula(
    formula = choice ~ price | income | comfort,
    error_term = "probit",
    random_effects = c(
      "price" = "cn",
      "income" = "cn"
    )
  ),
  choice_alternatives = choice_alternatives(J = 3)
)

choice_parameters <- generate_choice_parameters(
  choice_effects = choice_effects
)

ids <- generate_choice_identifiers(N = 4)

(choice_preferences <- generate_choice_preferences(
  choice_parameters = choice_parameters,
  choice_effects = choice_effects,
  choice_identifiers = ids
))

### inspect decider-specific preference vectors
head(choice_preferences)

choicedata documentation built on Nov. 5, 2025, 5:46 p.m.