Description
Maximum Likelihood Models and Tools for Estimation, Prediction, and Testing.
Description
Provides a collection of maximum likelihood estimators with a consistent S3 interface. Supported models include Gaussian (linear and log-normal), logit, probit, Poisson, negative binomial (NB1 and NB2), gamma, and beta regression. A distinctive feature is flexible modeling of the scale parameter (variance, dispersion, precision, or shape) alongside the location/mean parameters. The package offers unified predict() methods, multiple variance-covariance estimators (observed information, outer product of gradients, robust/Huber-White, cluster-robust, bootstrap, jackknife), and a full suite of hypothesis tests (Wald, likelihood ratio, information matrix, Vuong, overdispersion, and goodness-of-fit). It is fully compatible with 'marginaleffects' for post-estimation analysis. Methods implemented include Cameron and Trivedi (1990) <doi:10.1016/0304-4076(90)90014-K>, for Poisson overdispersion testing, Manjon and Martinez (2014) <doi:10.1177/1536867X1401400406>, for goodness-of-fit testing of count data models, Vuong (1989) <doi:10.2307/1912557>, for non-nested likelihood ratio testing, and White (1982) <doi:10.2307/1912526>, for information matrix tests.
README.md
mlmodels: Maximum Likelihood Models for R
mlmodels provides a consistent and flexible framework for maximum likelihood estimation in R. It includes a wide range of models with a unified S3 interface, support for modeling scale parameters (heteroskedasticity), rich post-estimation tools, and excellent compatibility with the marginaleffects package.
Key Features
- Consistent interface across models:
ml_lm(),ml_logit(),ml_probit(),ml_poisson(),ml_negbin(),ml_gamma(),ml_beta(), etc. - Flexible modeling of the scale parameter (variance, dispersion, precision, or shape) alongside the mean.
- Rich
predict()method with many output types (response, mean, variance, probabilities, etc.). - Multiple variance-covariance estimators: OIM, OPG, robust, cluster-robust, bootstrap, and jackknife.
- Comprehensive hypothesis testing: Wald, likelihood ratio, information matrix, Vuong, overdispersion, and goodness-of-fit tests.
- Full compatibility with
marginaleffectsfor marginal effects and predictions.
Installation
You can install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("alfisankipan/mlmodels")
(The package will soon be available on CRAN.)
Documentation
- Getting Started
- Count Data Models
- Diagnostic Tools
- Fractional Response Outcomes
- Gamma and Lognormal Models
- Predictions and Marginal Effects
- Variance Estimators and Inference
Quick Example
library(mlmodels)
data("mroz")
fit <- ml_logit(inlf ~ age + I(age^2) + huswage + educ + unem,
data = mroz)
summary(fit, vcov.type = "robust")
Acknowledgements
This package builds on the excellent maxLik package by Arne Henningsen and others for the underlying optimization engine.