Learn R Programming

ino (version 1.0.2)

sim_mnp: Simulate data from a (normally mixed) multinomial probit model

Description

Simulate data from a (normally mixed) multinomial probit model

Usage

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
)

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).

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 equal 2.

P

An integer, the number of choice covariates.

b

A numeric vector, the mean effects vector of length P. The first element must be 1 (for normalization).

Omega

A matrix, the covariance matrix of the normal mixing distribution of dimension P times P. Set to NULL (the default) for no mixing distribution.

Sigma

A matrix, the error term covariance matrix of dimension J times J.

X

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.

seed

Optionally set a seed for the choice data simulation.

See Also

f_ll_mnp() for computing the log-likelihood of a (normally mixed) multinomial probit model.

Examples

Run this code
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