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.
You can install the development version of choicer with:
pak::pkg_install("fpcordeiro/choicer")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| 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().
There are multiple R packages that offer similar functionalities: