ModelMultinomialLogit: A light weight implementation of 'mlogit"s mlogit model.

Description Super classes Methods Examples

Description

A multinomial logit model using mlogit's formula and data structure.

Super classes

dymiumCore::Generic -> dymiumCore::Model -> dymiumModel::ModelBase -> ModelMultinomialLogit

Methods

Public methods

Inherited methods

Method new()

Initialisation function

Usage
ModelMultinomialLogit$new(params, formula, preprocessing_fn = NULL)
Arguments
params

a named numeric vector.

formula

a formula object of class mlogit::mFormula(), Formula::Formula, or formula.

preprocessing_fn

a pre-processing function that gets applied to the data given to the predict method before making the prediction.

Returns

NULL


Method predict()

This predict method returns probabilities generated from the parameters of this Model object.

Usage
ModelMultinomialLogit$predict(newdata, chooser_id_col, choice_id_col)
Arguments
newdata

(data.frame())
new data to generate probabilities conditioned on its explanatory variables.

chooser_id_col

(character(1))
column name of the chooser id

choice_id_col

(character(1))
column name of the choice id

Returns

a data.frame object with three columns: chooser_id (integer()), choice_id (integer()), linear_comb (numeric()), prob (numeric()). Note that, 'linear_comb' stands for linear combination (i.e. $$B1 * x1 + B2 * x2$$).


Method clone()

The objects of this class are cloneable with this method.

Usage
ModelMultinomialLogit$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

1
2
3
4
5
6
if (requireNamespace('mlogit')) {
 data("Fishing", package = "mlogit")
 .data_dfidx <- dfidx::dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode")
 mod <- mlogit::mlogit(mode ~ price + catch, data = .data_dfidx)
 Mod <- ModelMultinomialLogit$new(params = mod$coefficients, formula = mod$formula)
}

dymium-org/dymiumModel documentation built on June 23, 2020, 11:01 a.m.