Two kinds of variables are used in logit models: alternative specific and
individual specific variables.
mFormula provides a relevant
class to deal with this specificity and suitable methods to extract
the elements of the model.
1 2 3 4 5 6 7 8
J being the number of alternatives. The formula may
include alternative-specific and individual specific variables. For
J-1 coefficients are estimated for each
variable. For the former, only one (generic) coefficient or
different coefficient may be estimated.
mFormula is a formula for which the right hand side may
contain three parts: the first one contains the alternative specific
variables with generic coefficient, i.e. a unique coefficient
for all the alternatives ; the second one contains the individual
specific variables for which one coefficient is estimated for all the
alternatives except one of them ; the third one contains the
alternative specific variables with alternative specific coefficients.
The different parts are separeted by a “
|” sign. If a
standard formula is writen, it is assumed that there are only
alternative specific variables with generic coefficients.
The intercept is necessarely alternative specific (a generic intercept
is not identified because only utility differences are
relevant). Therefore, it deals with the second part of the formula. As
it is usual in
R, the default behaviour is to include an
intercept. A model without an intercept (which is hardly meaningfull)
may be specified by includint
-1 in the second rhs
part of the formula.
-1 in the first and in the
third part of the formula are simply ignored.
Specific methods are provided to build correctly the model matrix and to
update the formula. The
mFormula function is not intended to be
use directly. While using the
mlogit function, the first
argument is automaticaly coerced to a
an object of class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
data("Fishing", package = "mlogit") Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode") # a formula with to alternative specific variables (price and catch) and # an intercept f1 <- mFormula(mode ~ price + catch) head(model.matrix(f1, Fish), 2) # same, with an individual specific variable (income) f2 <- mFormula(mode ~ price + catch | income) head(model.matrix(f2, Fish), 2) # same, without an intercept f3 <- mFormula(mode ~ price + catch | income + 0) head(model.matrix(f3, Fish), 2) # same as f2, but now, coefficients of catch are alternative specific f4 <- mFormula(mode ~ price | income | catch) head(model.matrix(f4, Fish), 2)