The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

choicer: fast discrete-choice models with a focus on economic applications

Lifecycle: stable R-CMD-check

choicer provides fast estimation of discrete-choice models for applied economics. Likelihoods, analytical gradients and Hessians are implemented in C++ with OpenMP parallelism, scaling efficiently to specifications with many alternative-specific constants. Post-estimation routines return predicted shares, own- and cross-price elasticities, diversion ratios, and the BLP contraction. Supports multinomial logit (MNL), mixed logit (MXL), and nested logit (NL); more models will be added.

Installation

You can install the development version of choicer with:

pak::pkg_install("fpcordeiro/choicer")

Example

Estimate a multinomial logit model and compute elasticities and diversion ratios:

library(choicer)
library(data.table)

# Estimate
fit <- run_mnlogit(
    data = dt,
    id_col = "id",
    alt_col = "alt",
    choice_col = "choice",
    covariate_col = c("x1", "x2")
)

summary(fit)

# Post-estimation
predict(fit, type = "shares")        # predicted market shares
elasticities(fit, elast_var = "x1")  # own- and cross-price elasticities
diversion_ratios(fit)                # diversion ratio matrix

Supported models

Model Function Post-estimation
Multinomial Logit run_mnlogit() predict(), elasticities(), diversion_ratios(), blp()
Mixed Logit run_mxlogit() predict(), elasticities(), diversion_ratios(), blp()
Nested Logit run_nestlogit()

All fitted models support summary(), coef(), vcov(), logLik(), AIC(), BIC(), and nobs().

Alternative packages

There are multiple R packages that offer similar functionalities:

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.