Generates synthetic choice data with i.i.d. Gumbel errors, optionally with varying choice-set sizes and an outside option (alt = 0). Choices are determined by argmax of utility; covariates are drawn as Uniform(-1, 1).
Usage
simulate_mnl_data(
N = 5000,
J = 5,
beta = c(0.8, -0.6),
delta = NULL,
seed = 123,
outside_option = TRUE,
vary_choice_set = TRUE
)Arguments
- N
Number of choice situations.
- J
Number of inside alternatives.
- beta
Fixed coefficients for
x1..x{K_x}(lengthK_x = length(beta)).- delta
Alternative-specific constants for inside alternatives (length
J). Defaults to an alternating pattern ofc(0.5, -0.5).- seed
Random seed. Pass
NULLto skipset.seed()(useful insidemonte_carlo()where the caller manages RNG).- outside_option
Logical; if
TRUE(default) an outside option withalt = 0and zero covariates is added to every choice set.- vary_choice_set
Logical; if
TRUE(default) choice set size is sampled uniformly from2:J; ifFALSEevery individual faces allJinside alternatives.
Examples
# \donttest{
sim <- simulate_mnl_data(N = 1000, J = 5, seed = 123)
print(sim)
#> <choicer_sim: mnl>
#> settings:
#> N = 1000
#> J = 5
#> K_x = 2
#> outside_option = TRUE
#> vary_choice_set = TRUE
#> rows in $data: 4500
#> true_params: beta, delta
# }