The choice_formula object defines the choice model equation.
Arguments
- formula
[
formula]
A symbolic description of the choice model, see details.- error_term
[
character(1)]
Defines the model's error term. Current options are:"probit"(default): errors are multivariate normally distributed"logit": errors follow a type-I extreme value distribution
- random_effects
[
character()]
Named vector defining random effects, see details.- x
[
choice_formula]
Achoice_formulaobject.- ...
Currently not used.
Value
An object of class choice_formula, which is a list of the elements:
formulaThe model formula.
error_termThe name of the model's error term specification.
choiceThe name of the response variable.
covariate_typesThe (up to) three different types of covariates.
ASCDoes the model have ASCs?
random_effectsThe names of covariates with random effects.
Specifying the model formula
The structure of formula is choice ~ A | B | C, i.e., a standard
formula object but with three parts on the right-hand
side, separated by |, where
choiceis the name of the discrete response variable,Aare names of alternative-specific covariates with a coefficient that is constant across alternatives,Bare names of covariates that are constant across alternatives,and
Care names of alternative-specific covariates with alternative-specific coefficients.
The following rules apply:
By default, intercepts (referred to as alternative-specific constants, ASCs) are added to the model. They can be removed by adding
+ 0in the second part, e.g.,choice ~ A | B + 0 | C. To not include any covariates of the second type but to estimate ASCs, add1in the second part, e.g.,choice ~ A | 1 | C. The expressionchoice ~ A | 0 | Cis interpreted as no covariates of the second type and no ASCs.To not include covariates of any type, add
0in the respective part, e.g.,choice ~ 0 | B | C.Some parts of the formula can be omitted when there is no ambiguity. For example,
choice ~ Ais equivalent tochoice ~ A | 1 | 0.Multiple covariates in one part are separated by a
+sign, e.g.,choice ~ A1 + A2.Arithmetic transformations of covariates in all three parts of the right-hand side are possible via the function
I(), e.g.,choice ~ I(A1^2 + A2 * 2). In this case, a random effect can be defined for the transformed covariate, e.g.,random_effects = c("I(A1^2 + A2 * 2)" = "cn").
Specifying random effects
Specify random effects as "<covariate>" = "<distribution>". Each covariate
must appear explicitly on the right-hand side of formula; use "ASC" for
alternative-specific constants.
Available distributions are:
"cn": correlated normal"n": uncorrelated normal"cln": positively signed correlated log-normal"ln": positively signed uncorrelated log-normal"cln-": negatively signed correlated log-normal"ln-": negatively signed uncorrelated log-normal
Examples
### specify a choice formula
choice_formula(
formula = choice ~ I(A^2 + 1) | B | I(log(C)),
error_term = "probit",
random_effects = c("I(A^2+1)" = "cn", "B" = "cn")
)
#>
#> ── Choice formula
#> • choice ~ I(A^2 + 1) | B | I(log(C))
#> • error term: probit
#> • random effects:
#> • I(A^2+1): cn
#> • B: cn
