exactcond
Exact conditional reference distributions for tables and for linear models whose structure was selected from the same data. Pure C back-end, shared byte for byte with the Python package of the same name.
The one idea
A nuisance parameter is removed by conditioning on a statistic sufficient for it. What survives carries no nuisance, so a reference drawn from it is exact at every sample size, with no appeal to an asymptotic approximation and no bootstrap.
Two conditionings
Both margins fixed. In an r by c table the row and column totals are sufficient for the marginal parameters, so conditioning on both leaves the Fisher-Yates law. It is sampled exactly, and by an argument needing no appeal to Patefield's algorithm: the conditional law given both margins is precisely the law of the table formed by pairing a fixed vector of row labels with a uniformly random permutation of the column labels.
Direction only. Under a null in which the tested structure does not enter the data-generating process, a statistic invariant to the regression coefficients and to the error scale depends on the data only through the residual direction, which is uniform on the sphere of the residual space whatever those nuisance parameters are. The reference stays exact when the statistic is maximised over candidates, and so remains valid after a spatial weight matrix has been selected by fit.
Why the dispersion statistic
For nominal rows against an ordinal column, stat = "dispersion" is the between-row dispersion of
the mean score. Its components are the row mean scores themselves, so where the column score is a
signed difference the statistic is assembled out of the very contrasts being reported, and a reader
can follow the arithmetic from the table to the test. A rank test on such a variable answers a
different question, and answers it on data that are mostly ties.
Example
library(exactcond)
tab <- matrix(c(3, 228, 72, 10, 548, 67, 7, 276, 131), nrow = 3, byrow = TRUE)
ec_rc_test(tab, v = c(-1, 0, 1), B = 200000, seed = 4207)
Notes on honesty
ec_rc_test() reports the largest null draw alongside the p-value, and says so when the observed
statistic exceeded every draw: that is a resolution floor, not a p-value, and the two should not be
written the same way. Every p-value comes with a Wilson interval for the Monte Carlo error in the
number of draws actually taken.
ec_rc_two() samples the paired law directly rather than convolving two separately estimated null
distributions. The convolution needs the observed score to be reachable under no association; for a
strongly associated table it is not, at any number of draws, and the failure arrives precisely when
both tables are strongly associated, which is the case in which the correct answer is a large
p-value.
ec_multi_test() answers "does ANY of these items differ across the groups" with ONE exact test:
the sum or the maximum over items of a per-item statistic, referred to the law obtained by permuting
the group labels across respondents or, when a cluster is given, across clusters that keep their
members. This is Pesarin's nonparametric combination with the direct and Tippett combining functions: one
p-value for the whole battery, so nothing to correct for multiplicity, and the per-item statistics
referred to the same permutations for a closed follow-up in the manner of Westfall and Young. The sum has power against
many items moving a little, the maximum against one moving a lot, and the cluster permutation is the
exact treatment of an interviewer or fieldworker effect, at negligible cost when there is none.
ec_diffnet_test() carries the same idea to a network. A differential network normally rests on a
Gaussian null; here the edge statistic is unchanged and only its reference is, from a chi-square to
a permutation of the group labels, which is exact whatever the marginals are and distribution-free
on ranks. One p-value for the whole network, per-edge p-values from the same permutations, and a
cluster permutation for interviewer effects. The route is the established one (NetCoMi's diffnet,
the Network Comparison Test, exchangeability blocks); what is here is the implementation.
Reproducibility
Every replicate draws from its own stream, seeded from the base seed and the replicate index, so
results do not depend on the thread count and are identical across the R and Python fronts.
parity_exactcond.sh checks that agreement to fifteen significant figures.
Metadata
Release files for exactcond 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| exactcond-0.2.0.tar.gz | 22.3 kB | Details |
Built distributions (wheels)
Total release size: 401.3 kB
Release files / exactcond-0.2.0.tar.gz
| Download URL | exactcond-0.2.0.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1934853c89e412b4c9173d8a14233f0b284ebebfded3bd58cc5faec8891f2878
|
|
BLAKE2b-256 checksum How to use checksums |
c81fc0b0a4f4d87105af17f9d23aefd8582037da130b2364f9cf4946c17f4421
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | exactcond-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 58.0 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2dff2d61b63404eb805abad7e35ca052c53d14d2ef1753c2f85bc1f4364c5580
|
|
BLAKE2b-256 checksum How to use checksums |
aadad6ae9f698e050fe4918b25a46c83218df9043cb370fa1fa330813cb822ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | exactcond-0.2.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 36.8 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
faa1d23216d3a18229d755abe43a3458434798773ff9a2cbadb235ee71acc464
|
|
BLAKE2b-256 checksum How to use checksums |
bccaf13032efcd1908abb43215f0add05f187ddbf8d42240643762134457f49d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | exactcond-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 58.0 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e74c34341dae9fde1ca73f47f408d230a8596957a54c151deea6b410f4d96996
|
|
BLAKE2b-256 checksum How to use checksums |
53ac313df0d19d805b7d669f088ac194f5eeff1bd8c290a0c879e4f4d19aedfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | exactcond-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 36.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c37663eb3e114cbea3f587d1d77211b8813c74277e6ae5af480e05da51cd7085
|
|
BLAKE2b-256 checksum How to use checksums |
ca26fc0f464b4cf6e0b43312a6129d7a434d3b3dd7b1f74a8ea61214e2b54d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | exactcond-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 57.9 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
aec0487cdbff074a6aa9fe0de1ff4d2d483fc121facbe480675fbba580c15f7e
|
|
BLAKE2b-256 checksum How to use checksums |
80d6c78165871bca8dfa8ac456c2f5ef7acdefa499b2d258afe719a30fc9e3b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | exactcond-0.2.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 36.8 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6fd90bac98aef30124e6ab50ad1c0f34b06d7a3d844dd239c04ed4781233dac6
|
|
BLAKE2b-256 checksum How to use checksums |
18fb5f680551d3576262d76086f4a8215c735757992167d1a32449217b5805e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | exactcond-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 57.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
18ce28aed30ba0a619dbe6dfa408ea30a6d4f2df79866147b2a8ad95a9a142df
|
|
BLAKE2b-256 checksum How to use checksums |
ce9a939e0d8985a431b09cb6df3dfa7cdaa6675722254f0ed8498483d70f7d39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / exactcond-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | exactcond-0.2.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 36.8 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7b8b4264d46e507f247e07cbd4b6a6fa1d7042176a0efeea6efef88124ebcd7f
|
|
BLAKE2b-256 checksum How to use checksums |
fc14ebe465c63e3f8cfa8d1fa5ca2e3005de1bc4e46720e02931e5401bba0fc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|