Simulate data from a (normally mixed) multinomial probit model
Arguments
- N
An
integer, the number of observations.- Tp
An
integer, the number of choice occasions. By default,Tp = 1.- J
An
integer, the number of alternatives. Must be greater of equal2.- P
An
integer, the number of choice covariates.- b
A
numericvector, the mean effects vector of lengthP. The first element must be1(for normalization).- Omega
A
matrix, the covariance matrix of the normal mixing distribution of dimensionPtimesP. Set toNULL(the default) for no mixing distribution.- Sigma
A
matrix, the error term covariance matrix of dimensionJtimesJ.- X
A
functionthat samples the covariates of decidernat choice occasiont. It musthave two arguments
nandt,return a
numericmatrixof dimensionJtimesP.
- seed
Optionally set a seed for the choice data simulation.
Value
A data.frame. The first column (n) is the identifier for the
decider, the next column (t) the identifier for the choice occasion.
Next comes the column y with the indices of the chosen alternatives.
The last columns contain the column-wise entries of the covariate matrices.
The true model coefficients are added to the output via the attribute
"true". They are already normalized and can be directly compared with
the maximum likelihood estimate.
Additional attributes are "J" (the number of alternatives),
"P" (the number of choice covariates), and "mix" (a boolean
which is TRUE if Omega is not NULL).
See also
f_ll_mnp() for computing the log-likelihood of a (normally mixed)
multinomial probit model.
Examples
sim_mnp(N = 3, J = 3, P = 2, b = c(1, -1), Omega = diag(2), Sigma = diag(3))
#> n t y X.11 X.21 X.31 X.12 X.22 X.32
#> 1 1 1 2 -0.1769176 0.806234 -0.7450319 -0.6501459 -0.59548099 -0.54654143
#> 2 2 1 1 1.1600266 0.557720 -0.1063816 -1.3807541 -0.25282175 -0.62357520
#> 3 3 1 3 -0.5488223 0.451838 1.0941607 0.2423017 -0.09239966 0.03762956
