Simulate data from a (normally mixed) multinomial probit model
sim_mnp(
N,
Tp = 1,
J,
P,
b = stats::rnorm(P),
Omega = NULL,
Sigma = diag(J),
X = function(n, t) matrix(stats::rnorm(J * P), nrow = J, ncol = P),
seed = NULL
)
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
).
An integer
, the number of observations.
An integer
, the number of choice occasions.
By default, Tp = 1
.
An integer
, the number of alternatives.
Must be greater of equal 2
.
An integer
, the number of choice covariates.
A numeric
vector, the mean effects vector of length P
.
The first element must be 1
(for normalization).
A matrix
, the covariance matrix of the normal mixing distribution of
dimension P
times P
.
Set to NULL
(the default) for no mixing distribution.
A matrix
, the error term covariance matrix of dimension J
times J
.
A function
that samples the covariates of decider n
at choice
occasion t
. It must
have two arguments n
and t
,
return a numeric
matrix
of dimension J
times P
.
Optionally set a seed for the choice data simulation.
f_ll_mnp()
for computing the log-likelihood of a (normally mixed)
multinomial probit model.
sim_mnp(N = 3, J = 3, P = 2, b = c(1, -1), Omega = diag(2), Sigma = diag(3))
Run the code above in your browser using DataLab