Extensions to mosaicperm: sign-flip inference, ridge-regularized residuals, and adaptive tiling for factor models.
Project description
extendedmosaicperm
Extended tools for Mosaic Permutation Tests — including:
- ✓ sign-flip inference
- ✓ ridge-regularized residuals
- ✓ adaptive tiling
- ✓ experiment utilities
All built as a thin, clean extension on top of the original mosaicperm package.
The goal is to explore faster, more robust, and more flexible randomization inference procedures for high-dimensional factor models.
Installation
Stable version (PyPI)
pip install extendedmosaicperm
Development version (GitHub)
pip install git+https://github.com/skonieczkak/extendedmosaicperm.git
Usage Examples
Basic — Sign-flip test
import numpy as np
from extendedmosaicperm.factor import ExtendMosaicFactorTest
import mosaicperm as mp
rng = np.random.default_rng(0)
T, p, k = 200, 50, 3
Y = rng.normal(size=(T, p))
L = rng.normal(size=(p, k))
test = ExtendMosaicFactorTest(
outcomes=Y,
exposures=L,
test_stat=mp.statistics.mean_maxcorr_stat,
sign_flipping=True,
)
test.fit(nrand=500)
print("p-value:", test.pval)
Adaptive tiling
from extendedmosaicperm.tilings import build_adaptive_tiling
tiling = build_adaptive_tiling(
outcomes=Y,
exposures=L,
batch_size=20,
seed=0
)
print(len(tiling.tiles))
Monte Carlo experiment
from extendedmosaicperm.experiments.sign_flip import SignFlipExperiment
exp = SignFlipExperiment(
n_sims=100,
nrand=200,
seed=123
)
exp.run()
df = exp.summarize()
print(df.head())
Documentation
Full documentation, including the API reference, usage examples, and theoretical background, is available at:
https://extendedmosaicperm.readthedocs.io
Testing
Run the unit tests:
pytest extendedmosaicperm/tests
License
MIT License — same as the parent mosaicperm project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file extendedmosaicperm-0.1.0.tar.gz.
File metadata
- Download URL: extendedmosaicperm-0.1.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a0ea8f3c222c92e5e89dab74ea6fd50044ef68b0fe19d419b29e5bcac778226
|
|
| MD5 |
450dc919c06458d2cd5441bd8dca045f
|
|
| BLAKE2b-256 |
a4bab6d79f27b80f290b54a49e188feb77958a76c4f99789aeaaaf50e7f45d5f
|
File details
Details for the file extendedmosaicperm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: extendedmosaicperm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e164169133a018df6add4e9d33247d9ead238d2b079e800a4f48d0f3f1883d9
|
|
| MD5 |
e49b5cdc4bbaf108689de90c6b127a24
|
|
| BLAKE2b-256 |
033b5c0989472ca74694d2b8b3c9c8bd0f3d26a0b7c4d060eada2a237dc792ee
|