Skip to main content

A python implementation of the mosaic permutation testing framework.

Installation

To install mosaicperm, just use pip:

pip install mosaicperm

Documentation

Documentation and tutorials are available at https://mosaicperm.readthedocs.io/.

Quickstart

Below, we give a simple example showing how to use mosaicperm to test whether a set of factor exposures explain the correlations among a matrix of outcomes variables.

	import numpy as np
	import mosaicperm as mp

	# synthetic outcomes and exposures
	n_obs, n_subjects, n_factors = 100, 200, 20
	outcomes = np.random.randn(n_obs, n_subjects)
	exposures = np.random.randn(n_obs, n_subjects, n_factors)
	# example of missing data
	outcomes[0:10][:, 0:5] = np.nan
	exposures[0:10][:, 0:5] = np.nan

	# fit mosaic permutation test
	mpt = mp.factor.MosaicFactorTest(
		outcomes=outcomes,
		exposures=exposures,
		test_stat=mp.statistics.mean_maxcorr_stat,
	)
	print(mpt.fit().summary())

	# produce a time series plot of this analysis
	mpt.fit_tseries(
		nrand=100, n_timepoints=20,
	).plot_tseries()

See the documentation for more details.

Reference

If you use mosaicperm in an academic publication, please consider citing our paper:

@article{mosaic2024,
  author = {Spector, Asher and Barber, Rina Foygel and Hastie, Trevor and Kahn, Ronald N. and Candès, Emmanuel},
  title = {The mosaic permutation test: an exact and nonparametric goodness-of-fit test for factor models},
  date = {2024},
  annotation = {2024f},
  eprint = {2404.15017},
  eprintclass = {stat.ME},
  eprinttype = {arXiv},
  url={https://arxiv.org/abs/2404.15017},
}

Release files for mosaicperm 0.1.5

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

Source distribution (sdist)

Source distribution for mosaicperm 0.1.5
File Size Uploaded
mosaicperm-0.1.5.tar.gz 28.0 kB Details

Release files / mosaicperm-0.1.5.tar.gz

Download URL mosaicperm-0.1.5.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
86d7c1546f2dce8453388b32019e7b9fa74b6c0728d96f6e905a4525b28590bb
BLAKE2b-256 checksum
How to use checksums
9356447e414036eb30091b738014135fef994eb9cbd3abd7f3df803118430ef8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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