Package 'mlogitExtras'

Title: Some extras for the mlogit package
Description: Some extras for the mlogit package. I started this package because I could not make the predict function in mlogit robustly work without errors for mixed logit models. The function ml_predict can be used as a replacment (but still only works for a subset of random parameter specifications.)
Authors: Sebastian Kranz
Maintainer: Sebastian Kranz <[email protected]>
License: GPL >= 2.0
Version: 0.1.0
Built: 2024-08-24 02:29:45 UTC
Source: https://github.com/skranz/mlogitExtras

Help Index


Density function of triangular distribution

Description

Density function of triangular distribution

Usage

dtri(x, min = 0, max = 1)

Extract Cholesky decomposition matrix of correlated random variables of an mlogit model

Description

Extract Cholesky decomposition matrix of correlated random variables of an mlogit model

Usage

ml_chol(mod)

Draw random coefficients of individuals for an estimated mixed logit model

Description

Note that the function is still restricted and does not yet work for all sorts of random parameter distributions that mlogit supports.

Usage

ml_draw_betas(mod, num.draws = 100, use.halton = FALSE, scale = NA)

Arguments

mod

the estimated models

num.draws

the number of individuals for which random coefficients shall be drawn

use.halton

shall Halton sequences be used instead of psedudo-random numbers?

Value

A matrix with num.draws rows and one column for each explanatory variable that has random coefficients


Alternative predict function for mlogit objects

Description

Currently only works for models without alternative specific constants or alternative specific interaction effects.

Usage

ml_predict(mod, newdata, num.draws = 1000, use.halton = TRUE)

Arguments

mod

An estimated mlogit model

newdata

A data set for the prediction in long format. The data set should have a column alt the indexed the alternative. The data set must be ordered first by choice situation and each choice situation must have the same number of alternatives in the same order. You may simply add a column chid specifying choice situation then arrange by chid, alt.

num.draws

Number of simulated consumers to compute market shares (relevant for mixed logit models only)

use.halton

Should Halton sequences instead of pseudo-random numbers be used to simulate consumers (default TRUE)

Value

A matrix of predicted choice probabilities with one row per choice situation and one column for each alternative. Each row sums up to 1.


Get tidy output of estimated coefficients of mlogit model as data frame

Description

Get tidy output of estimated coefficients of mlogit model as data frame

Usage

ml_tidy(mod, scale = NA)

Arguments

mod

the estimated model

scale

A numeric value or variable name used to scale coefficients and standard errors. Typical application would be a "price" variable if you estimated a product choice. Then utilities can be interpreted as willingness to pay.


Quantile function of triangular distribution

Description

Quantile function of triangular distribution

Usage

qtri(p, min = 0, max = 1)

Helper function to show changes in choice probabilities / market shares

Description

Helper function to show changes in choice probabilities / market shares

Usage

show_P_changes(org, new, digits = 1)