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()
]
Defines the random effects in the model. The expected format of elements inrandom_effects
is"<covariate>" = "<distribution>"
, where"<covariate>"
is the name of a variable on theformula
right-hand side. Every random effect must reference an explicit covariate (or"ASC"
for alternative-specific constants) that appears in the supplied model formula.Current options for
"<distribution>"
are:"cn"
: correlated (with other"cn"
random effects) normal distribution
To have random effects for the ASCs, use
"ASC"
for"<covariate>"
.- x
[
choice_formula
]
Achoice_formula
object.- ...
Currently not used.
Value
An object of class choice_formula
, which is a list
of the elements:
formula
The model formula.
error_term
The name of the model's error term specification.
choice
The name of the response variable.
covariate_types
The (up to) three different types of covariates.
ASC
Does the model have ASCs?
random_effects
The 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
choice
is the name of the discrete response variable,A
are names of alternative-specific covariates with a coefficient that is constant across alternatives,B
are names of covariates that are constant across alternatives,and
C
are 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
+ 0
in the second part, e.g.,choice ~ A | B + 0 | C
. To not include any covariates of the second type but to estimate ASCs, add1
in the second part, e.g.,choice ~ A | 1 | C
. The expressionchoice ~ A | 0 | C
is interpreted as no covariates of the second type and no ASCs.To not include covariates of any type, add
0
in 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 ~ A
is 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")
.