Skip to main content

canbiplotme

Canonical biplot for grouped estimates measured with error — Python port of the R package gcbiplot (Gravity Canonical Biplot, formerly canbiplotME; Freire-Cadme, 2026, doctoral thesis Biplot canónico y modelo gravitacional de comercio: regímenes comerciales y exportadores medidos con error).

The individuals of a canonical (MANOVA) biplot are estimated coefficient vectors, each with its own measurement-error covariance, correlated within groups and with components that may be undefined for some individuals.

pip install canbiplotme            # core
pip install canbiplotme[all]       # + pyfixest (first stage) and matplotlib

Reproducing the thesis

import canbiplotme as cb
x = cb.load_gcb_trade()                               # 115 exporters, 6 regimes, 5 frictions
fit = cb.gcb(x, S_vars=["log_dist", "comlang_off"])   # trace 18.579
t = cb.gcb_test(fit, B=1999, seed=20251025 + 17000000)
print(t)                                              # p(trace) = 0.096; 2 of 15 pairs (Holm)

With an integer seed, gcb_test draws replicate b with cb.RRNG(seed + b), a generator that reproduces R's set.seed() and rnorm(): the replicates are those of gcbiplot::gcb_test() and of the thesis (differences below 1e-11). The gcb* names are aliases of the cbme* ones.

Minimal example

import canbiplotme as cb
x = cb.load_sim_me()
fit = cb.cbme(x, S_vars=["z1", "z2"])        # second stage
tt = cb.cbme_test(fit, B=1999, seed=1)       # G0 bootstrap: trace, largest root, pairs (Holm), S
rg = cb.cbme_regions(fit, seed=1)            # regions R1-R4
fit.plot(rg, region="R3")
cb.cbme_influence(fit, B_ref=200)            # jackknife + reference
cb.cbme_simulate_tests(fit, nsim=1000, B=199)  # validate the size in your own design

First stage from trade flows (needs pyfixest):

d = cb.load_sim_trade()
s1 = cb.gravity_by_individual(d, "flow", "orig", "dest", "year", ["ldist", "lang", "fta"], "regime", controls=["contig"])
bt = cb.pairs_bootstrap(s1, d, R=199)
cnt = cb.support_counts(d, "orig", "dest", ["lang", "fta"])
idn = cb.identify_d6(s1.beta, bt["V"], s1.id, cnt, ["lang", "fta"], components=s1.spec["frictions"])
fit = cb.cbme(cb.as_me_data(s1, bt, idn))

Validation against R

tests/test_vs_r.py compares with fixtures produced by the R package (tests/fixtures/make_fixtures.R):

  • second stage (heterogeneity, means and covariances, metric, eigenvalues, markers, structure correlations, statistics, D²) in four configurations: max. difference ~1e-14;
  • regions R1–R3 and jackknife ρ: < 1e-10;
  • first stage with pyfixest vs fixest: coefficients < 1e-7, also on a resampled bootstrap dataset and in the dynamic extension. Clustered covariances differ by ~0.1 % because of the small-sample degrees-of-freedom convention of each library (the analysis uses the bootstrap covariance).

Random draws (bootstrap, G0) use NumPy's generator, so p-values agree with R in distribution, not replicate by replicate. The REML comparator cbme_reml reproduces metafor::rma.mv (T < 6e-7, means < 2e-6, LRT < 1e-8). cbme_permutation_test is the permutation comparator.

mvmeta is a general multivariate random-effects meta-analysis and meta-regression (unstructured between-study covariance, missing outcomes, REML / ML / fixed), validated against mixmeta 1.2.2: coefficients, Psi, covariance of the coefficients, log-likelihood and Cochran's Q agree to < 1e-6 (REML with a badly scaled moderator, where the surface is flat: 4e-5 in the coefficients at the same log-likelihood).

Metadata

Release files for canbiplotme 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 canbiplotme 0.3.0
File Size Uploaded Provenance Actions
canbiplotme-0.3.0.tar.gz 1.6 MB With provenance Details for canbiplotme-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 3.2 MB

Release files / canbiplotme-0.3.0.tar.gz

Download URL canbiplotme-0.3.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
395622a0429b73341ce3a6c5bed8072b1e12f83bfddb1d02ce041502624ddcac
BLAKE2b-256 checksum
How to use checksums
7388e4da2f3113bc1b985a2e79bc253736dc868920ab96fce25695d2fabb5dad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

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

Download URL canbiplotme-0.3.0-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0012ed44f566b8e32da8575dfa93b0fd53a012b5bb7b4221712db1bfcfafa637
BLAKE2b-256 checksum
How to use checksums
fd055d2da5bca104dc5e84f518bf4832637d2eb26db2b2d867dd2a02966360cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for canbiplotme 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for canbiplotme-0.3.0.tar.gz

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 Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

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