View source: R/choice_formula.R
| choice_formula | R Documentation |
The choice_formula object defines the choice model equation.
choice_formula(formula, error_term = "probit", random_effects = character())
## S3 method for class 'choice_formula'
print(x, ...)
formula |
[ |
error_term |
[
|
random_effects |
[ Current options for
To have random effects for the ASCs, use |
x |
[ |
... |
Currently not used. |
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.
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, add 1 in the
second part, e.g., choice ~ A | 1 | C. The expression
choice ~ 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 to choice ~ 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").
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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.