Generates synthetic choice data with nested logit probabilities computed
analytically (log-sum-exp over inclusive values), then samples choices from
the implied multinomial. The outside option (j = 0) sits in a singleton
nest with lambda = 1.
Arguments
- N
Number of choice situations.
- beta
Fixed coefficients for covariates
X, W(length 2 by default).- delta
Named numeric vector of ASCs for inside alternatives.
- nests
List of integer vectors defining nest membership for inside alternatives.
- lambdas
Numeric vector of dissimilarity parameters, one per nest.
- seed
Random seed (
NULLskipsset.seed()).
Value
A choicer_sim object. true_params includes beta, delta,
lambdas; settings includes the nest_structure. The returned
data retains a nest column (integer, with 0L for the outside
option) for convenient use with run_nestlogit().
Note
Unlike simulate_mnl_data() and simulate_mxl_data(), this
function does not expose outside_option or vary_choice_set flags.
The outside option (j = 0) is always present as a singleton nest with
lambda = 1, and every individual faces the full set of inside
alternatives. Add these flags if downstream use cases need them.
Examples
# \donttest{
sim <- simulate_nl_data(N = 2000, seed = 123)
print(sim)
#> <choicer_sim: nl>
#> settings:
#> N = 2000
#> J_inside = 5
#> nest_structure = (1,2), (3,4,5)
#> rows in $data: 12000
#> true_params: beta, delta, lambdas
# }