Skip to main content

Generalized M-Estimation

Project description

delicatessen

Delicatessen

tests version docs Downloads

The one-stop sandwich (variance) shop in Python. delicatessen is a Python 3.8+ library for the generalized calculus of M-estimation.

Citation: Zivich PN, Klose M, Cole SR, Edwards JK, & Shook-Sa BE. (2022). Delicatessen: M-Estimation in Python. arXiv:2203.11300 [stat.ME]

M-Estimation and Estimating Equations

Here, we provide a brief overview of M-estimation theory. For a detailed introduction to M-estimation, see Chapter 7 of Boos & Stefanski (2013). M-estimation is a generalization of likelihood-based methods. M-estimators are solutions to estimating equations. To apply the M-estimator, we solve the estimating equations using observed data. This is similar to other approaches, but the key advantage of M-Estimators is estimation of the variance via the sandwich variance.

While M-Estimation is a powerful tool, the derivatives and matrix algebra can quickly become unwieldy. This is where delicatessen comes in. delicatessen takes an array estimating equations and data, and solves for the parameter estimates, numerically approximates the derivatives, and does the matrix calculations. Therefore, M-estimators can be more widely adopted without by-hand calculations. We can let the computer do all the math for us.

delicatessen also comes with a variety of built-in estimating equations. See the delicatessen website for the full set of available estimating equations and how to use them.

Installation

Installing:

You can install via python -m pip install delicatessen

Dependencies:

The dependencies are: numpy, scipy

To replicate the tests located in tests/, you will additionally need to install: panda, statsmodels, and pytest

While versions of delicatessen prior to v1.0 were compatible with older versions of Python 3 and NumPy and SciPy, the v1.0+ releases are only available for Python 3.8+ with NumPy v1.18.5+ and SciPy v1.9.0. This change was made to use a better numerical approximation procedure for the derivative. If you want to use with older versions of those packages or older versions of Python, install v0.6 instead.

Getting started

Below is a simple demonstration of calculating the mean with delicatessen

import numpy as np
y = np.array([1, 2, 3, 1, 4, 1, 3, -2, 0, 2])

Loading the M-estimator functionality, building the estimating equation, and printing the results to the console

from delicatessen import MEstimator

def psi(theta):
    return y - theta[0]

estr = MEstimator(psi, init=[0, ])
estr.estimate()

print(estr.theta)     # Estimate of the mean
print(estr.variance)  # Variance estimator for the mean

For further details on using delicatessen, see the full documentation and worked examples available at delicatessen website or in the examples folder.

References

Boos DD, & Stefanski LA. (2013). M-estimation (estimating equations). In Essential Statistical Inference (pp. 297-337). Springer, New York, NY.

Stefanski LA, & Boos DD. (2002). The calculus of M-estimation. The American Statistician, 56(1), 29-38.

Zivich PN, Klose M, Cole SR, Edwards JK, & Shook-Sa BE. (2022). Delicatessen: M-Estimation in Python. arXiv preprint arXiv:2203.11300.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

delicatessen-1.2.tar.gz (48.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

delicatessen-1.2-py2.py3-none-any.whl (72.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file delicatessen-1.2.tar.gz.

File metadata

  • Download URL: delicatessen-1.2.tar.gz
  • Upload date:
  • Size: 48.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.4

File hashes

Hashes for delicatessen-1.2.tar.gz
Algorithm Hash digest
SHA256 1ffe22012e5330a18e9413c6fe8d9296354705143dc82ffbceccb5eb38b0a66e
MD5 f749dd09342e2fe0b2db0697354fb0c7
BLAKE2b-256 48712f2778aaa25c1a6118114944b4f24abf8d4ff7df35b218ca1969d591d3d3

See more details on using hashes here.

File details

Details for the file delicatessen-1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: delicatessen-1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 72.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.4

File hashes

Hashes for delicatessen-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 af82fae3b70f5bd6b221385dab85e6ba36d01293de5c88701aaf9f1fbca91437
MD5 4130183e481e19007dcc7f36060703b7
BLAKE2b-256 667710b2b1fca7e18c4dff06fd1b132840b1eb019cc4cf0dad9cea756d7535ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page