| simulate_hmnl_data | R Documentation |
Generates synthetic panel choice data from the hierarchical (random
coefficients + alternative-level random effects) logit DGP: respondents
i = 1..N face T choice situations each, with utilities
U_{ijt} = x_{ijt}'\gamma_i + \delta_j + \epsilon_{ijt}, \qquad
U_{iot} = \epsilon_{iot},
i.i.d. Gumbel shocks (including a shock on the outside option, whose
systematic utility is 0), \beta_i \sim N(\beta, W) with
\gamma_{ik} = \beta_{ik} or \exp(\beta_{ik}) per rc_dist,
and \delta_j = z_j'\theta + \xi_j with
\xi_j \sim N(0, \sigma_d^2). Covariates are Uniform(-1, 1); the
alternative-level covariates z* are constant within each alternative.
simulate_hmnl_data(
N = 500,
T = 10,
J = 4,
beta = c(0.8, -0.6),
W = NULL,
theta = c(0.5, -0.4),
sigma_d = 0.5,
Z = NULL,
rc_dist = NULL,
include_outside = TRUE,
seed = 123,
vary_choice_set = FALSE
)
N |
Number of respondents. |
T |
Number of choice situations per respondent. |
J |
Number of inside alternatives. |
beta |
Population means of the structural random coefficients
(length |
W |
Covariance of the random coefficients ( |
theta |
Mean-function coefficients for
|
sigma_d |
Standard deviation of the alternative-level effects
|
Z |
Optional |
rc_dist |
Integer vector (length |
include_outside |
Logical; if |
seed |
Random seed ( |
vary_choice_set |
Logical; if |
Log-normal coordinates are reported on the chain (log) scale in
true_params$beta — the scale on which the estimator's hierarchy
operates — while entering utility as exp(beta_ik).
A choicer_sim object. true_params contains beta, W,
theta, sigma_d, the realized delta and xi vectors, the full
mean-function design Z (intercept first), and rc_dist.
sim <- simulate_hmnl_data(N = 100, T = 4, J = 4, seed = 123)
print(sim)
sim$true_params$delta
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.