View source: R/simulate_choices.R
simulate_choices | R Documentation |
This function simulates choice data from a probit model.
simulate_choices(
form,
N,
T = 1,
J,
re = NULL,
alternatives = NULL,
ordered = FALSE,
ranked = FALSE,
base = NULL,
covariates = NULL,
true_parameter = list()
)
form |
[
Multiple covariates (of one type) are separated by a In the ordered probit model ( |
N |
[ |
T |
[ |
J |
[ |
re |
[ |
alternatives |
[ If |
ordered |
[ |
ranked |
[ |
base |
[ Ignored and set to By default, |
covariates |
[ |
true_parameter |
[ See the vignette on model definition for definitions of these variables. |
See the vignette on choice data for more details.
An object of class RprobitB_data
.
check_form()
for checking the model formula
overview_effects()
for an overview of the model effects
create_lagged_cov()
for creating lagged covariates
as_cov_names()
for re-labelling alternative-specific covariates
prepare_data()
for preparing empirical choice data
train_test()
for splitting choice data into a train and test subset
### simulate data from a binary probit model with two latent classes
data <- simulate_choices(
form = choice ~ cost | income | time,
N = 100,
T = 10,
J = 2,
re = c("cost", "time"),
alternatives = c("car", "bus"),
true_parameter = list(
"alpha" = c(-1, 1),
"b" = matrix(c(-1, -1, -0.5, -1.5, 0, -1), ncol = 2),
"C" = 2
)
)
### simulate data from an ordered probit model
data <- simulate_choices(
form = opinion ~ age + gender,
N = 10,
T = 1:10,
J = 5,
alternatives = c("very bad", "bad", "indifferent", "good", "very good"),
ordered = TRUE,
covariates = list(
"gender" = rep(sample(c(0, 1), 10, replace = TRUE), times = 1:10)
)
)
### simulate data from a ranked probit model
data <- simulate_choices(
form = product ~ price,
N = 10,
T = 1:10,
J = 3,
alternatives = c("A", "B", "C"),
ranked = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.