Skip to main content

bayesfm - Bayesian Fama-MacBeth

⚠️ DEPRECATED: bayesfm is no longer maintained. The same classes (BFM, BFMGLS, BFMOMIT) are now available in empfin. Please migrate by running pip install empfin and replacing import bayesfm with import empfin.

Implementation of "Bayesian Fama-MacBeth Regressions" from Bryzgalova, Huang and Julliard (2024). As presented by the authors, this methodology provides reliable risk premia estimates for both tradable and nontradable factors, detects those weakly identified, delivers valid credible intervals for all objects of interest, and is intuitive, fast and simple to implement.

Installation

pip install bayesfm

Usage

There is a self-contained example file using the Fama-French 25 sorted portfolios and their 5 factors.

There are 3 classes available:

  • BFM: Bayesian Fama-MacBeth
  • BFMGLS: Bayesian Fama-MacBeth with the GLS precision matrix for the cross-sectional step
  • BFMOMIT: Bayesian Fama-MacBeth with omitted factors
    • As noted by the authors, the use of this model requires us to include a sufficient number of latent factors in the cross-sectional step, which is chosen with the p argument of this class

All three class save the draws of all elements of interest as attributes, and have a method called plot_lambda, which plots the posteriors of the risk premia parameters. This method outputs the chart below, where the blue density are the posterior draws and the orange lines are the canonical Fama-MacBeth two-pass OLS regression estiamtes.

Risk Premia Posterior

Release files for bayesfm 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayesfm 0.3.0
File Size Uploaded
bayesfm-0.3.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bayesfm 0.3.0
File Interpreter ABI Platform
bayesfm-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size:12.6 kB

Release files / bayesfm-0.3.0.tar.gz

Download URL bayesfm-0.3.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1cc7c13c84da96a2d207de739df502985a4462496ad09ba5d2f8c9f49b48f400
BLAKE2b-256 checksum
How to use checksums
c8e49443d05d1d57f88fec12f8fe67c1399c7101680e6970bf1f6bc19ad16e11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Release files / bayesfm-0.3.0-py3-none-any.whl

Download URL bayesfm-0.3.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23287db08ef461dec42f7b27ba084bf3496416090fac03c8aa3a7134b0c18089
BLAKE2b-256 checksum
How to use checksums
12df346f0a3b1a7b3bfae6f8f698b1a0c383460fc0c2f630d077dcb32301151d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page