Description Usage Arguments Details Value Author(s) Examples

View source: R/logitform.R View source: R/logitform.R

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 | ```
mFormula(object)
## S3 method for class 'formula'
mFormula(object)
is.mFormula(object)
## S3 method for class 'mFormula'
model.matrix(object, data, ...)
## S3 method for class 'mFormula'
model.frame(formula, data, ..., lhs = NULL, rhs = NULL)
``` |

`object` |
for the |

`formula` |
a |

`data` |
a |

`lhs` |
see |

`rhs` |
see |

`...` |
further arguments. |

Let `J`

being the number of alternatives. The formula may
include alternative-specific and individual specific variables. For
the latter, `J-1`

coefficients are estimated for each
variable. For the former, only one (generic) coefficient or `J`

different coefficient may be estimated.

A `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 `+0`

or `-1`

in the second rhs
part of the formula. `+0`

or `-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 `mFormula`

object.

an object of class `mFormula`

.

Yves Croissant

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)
``` |

```
Loading required package: Formula
Loading required package: maxLik
Loading required package: miscTools
Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.
If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
boat:(intercept) charter:(intercept) pier:(intercept) price catch
1.beach 0 0 0 157.93 0.0678
1.boat 1 0 0 157.93 0.2601
boat:(intercept) charter:(intercept) pier:(intercept) price catch
1.beach 0 0 0 157.93 0.0678
1.boat 1 0 0 157.93 0.2601
boat:income charter:income pier:income
1.beach 0.000 0 0
1.boat 7083.332 0 0
price catch income:boat income:charter income:pier
1.beach 157.93 0.0678 0.000 0 0
1.boat 157.93 0.2601 7083.332 0 0
boat:(intercept) charter:(intercept) pier:(intercept) price
1.beach 0 0 0 157.93
1.boat 1 0 0 157.93
boat:income charter:income pier:income beach:catch boat:catch
1.beach 0.000 0 0 0.0678 0.0000
1.boat 7083.332 0 0 0.0000 0.2601
charter:catch pier:catch
1.beach 0 0
1.boat 0 0
```

mlogit documentation built on April 20, 2018, 5:03 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.