The choice_covariates object defines the choice model covariates.
generate_choice_covariates()samples covariates.covariate_names()gives the covariate names for givenchoice_effects.design_matrices()builds design matrices.
Usage
choice_covariates(
data_frame,
format = "wide",
column_decider = "deciderID",
column_occasion = NULL,
column_alternative = NULL,
column_ac_covariates = NULL,
column_as_covariates = NULL,
delimiter = "_",
cross_section = is.null(column_occasion)
)
generate_choice_covariates(
choice_effects = NULL,
choice_identifiers = generate_choice_identifiers(N = 100),
labels = covariate_names(choice_effects),
n = nrow(choice_identifiers),
marginals = list(),
correlation = diag(length(labels)),
verbose = FALSE,
delimiter = "_"
)
covariate_names(choice_effects)
design_matrices(
x,
choice_effects,
choice_identifiers = extract_choice_identifiers(x)
)Arguments
- data_frame
[
data.frame]
Contains the choice covariates.- format
[
character(1)]
Format ofdata_frame. Use"wide"when covariates for all alternatives are stored in a single row per occasion and"long"when each alternative forms a separate row.- column_decider
[
character(1)]
Column name with decider identifiers.- column_occasion
[
character(1)|NULL]
Column name with occasion identifiers. Set toNULLfor cross-sectional data.- column_alternative
[
character(1)|NULL]
Column name with alternative identifiers whenformat = "long".- column_ac_covariates
[
character()|NULL]
Column names with alternative-constant covariates.- column_as_covariates
[
character()|NULL]
Column names with alternative-specific covariates indata_frame.- delimiter
[
character(1)]
Delimiter separating alternative identifiers from covariate names in wide format. May consist of one or more characters.- cross_section
[
logical(1)]
Treat choice data as cross-sectional?- choice_effects
[
choice_effects|NULL]
Optionalchoice_effectsobject used to align covariate labels.- choice_identifiers
[
choice_identifiers]
Achoice_identifiersobject describing the simulated panel.- labels
[
character()]
Unique labels for the regressors.- n
[
integer(1)]
The number of values per regressor.- marginals
[
list()]
Optionally marginal distributions for regressors. If not specified, standard normal marginal distributions are used.Each list entry must be named according to a regressor label, and the following distributions are currently supported:
- discrete distributions
-
Poisson:
list(type = "poisson", lambda = ...)categorical:
list(type = "categorical", p = c(...))
- continuous distributions
-
normal:
list(type = "normal", mean = ..., sd = ...)uniform:
list(type = "uniform", min = ..., max = ...)
- correlation
[
matrix()]
A correlation matrix of dimensionlength(labels), where the(p, q)-th entry defines the correlation between regressorlabels[p]andlabels[q].- verbose
[
logical(1)]
Print information about the simulated regressors?- x
A
choice_dataorchoice_covariatesobject.
Design matrices
A covariate design matrix contains the choice covariates of a decider at a
choice occasion. It is of dimension J x P, where J is
the number of choice alternatives and P the number of effects. See
compute_P to compute the number P.
Examples
choice_effects <- choice_effects(
choice_formula = choice_formula(
formula = choice ~ price | income | comfort,
error_term = "probit",
random_effects = c(
"price" = "cn",
"income" = "cn"
)
),
choice_alternatives = choice_alternatives(J = 3)
)
ids <- generate_choice_identifiers(N = 3, Tp = 2)
choice_covariates <- generate_choice_covariates(
choice_effects = choice_effects,
choice_identifiers = ids
)
