Skip to main content

Exact inference via mosaic permutations

Project description

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},
}

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

mosaicperm-0.1.5.tar.gz (28.0 kB view details)

Uploaded Source

File details

Details for the file mosaicperm-0.1.5.tar.gz.

File metadata

  • Download URL: mosaicperm-0.1.5.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for mosaicperm-0.1.5.tar.gz
Algorithm Hash digest
SHA256 86d7c1546f2dce8453388b32019e7b9fa74b6c0728d96f6e905a4525b28590bb
MD5 2e0fe232f79222719edb27e1d44af564
BLAKE2b-256 9356447e414036eb30091b738014135fef994eb9cbd3abd7f3df803118430ef8

See more details on using hashes here.

Supported by

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