Description Super classes Methods Examples
A multinomial logit model using mlogit
's formula and data structure.
dymiumCore::Generic
-> dymiumCore::Model
-> dymiumModel::ModelBase
-> ModelMultinomialLogit
new()
Initialisation function
ModelMultinomialLogit$new(params, formula, preprocessing_fn = NULL)
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.
NULL
predict()
This predict method returns probabilities generated from the parameters of this Model object.
ModelMultinomialLogit$predict(newdata, chooser_id_col, choice_id_col)
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
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$$).
clone()
The objects of this class are cloneable with this method.
ModelMultinomialLogit$clone(deep = FALSE)
deep
Whether to make a deep clone.
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.