rheon.corr.signal_share

rheon.corr.signal_share(z_blocks: Any, n_kish_blocks: Any) → Any[source]

Estimate how much of a correlation’s movement across blocks is not sampling noise.

Use it to judge whether a correlation measured in each block, such as each week, really moves, or moves no more than its sampling error would make it. A share of 0 means the correlation moved no more than noise would.

Parameters

z_blocks

The Fisher z (to_z()) of each block’s correlation: a vector over B blocks for one pair, or a B x p array for p pairs.

n_kish_blocks

Each block’s sample size, a vector of B: Kish’s effective sample size (sum w)**2 / sum w**2, as gram()’s n_kish reports it, or a plain block’s row count. Not weight_sum, which is a weight, about half the Kish size in a steady state.

Returns

The share, per pair, with z_b and n_b block b’s:

clip(1 - mean_b(1 / (n_b - 3)) / var_b(z_b), 0, 1)

A scalar for a 1-d z_blocks (one pair), else an array of p. The share is nan where a block’s sample size is 3 or less, whose z has no such variance, and with fewer than two blocks.

Raises

ValueError

n_kish_blocks without one size per block.

Examples

z = rp.corr.to_z(np.array([0.10, 0.35, 0.05, 0.40]))   # one pair's weekly correlations
print(round(rp.corr.signal_share(z, [200, 200, 200, 200]), 3))
0.855

See also

Notes

1 / (n - 3) is the sampling variance of z, so the ratio is the share of the observed variance across blocks that sampling noise explains, and one minus it is what is left.