polars_online.corr.signal_share¶
- polars_online.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_blocksThe Fisher
z(to_z()) of each block’s correlation: a vector overBblocks for one pair, or aB x parray forppairs.n_kish_blocksEach block’s sample size, a vector of
B: Kish’s effective sample size(sum w)**2 / sum w**2, asgram()’sn_kishreports it, or a plain block’s row count. Notweight_sum, which is a weight, about half the Kish size in a steady state.
Returns
The share, per pair, with
z_bandn_bblockb’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 ofp. The share isnanwhere a block’s sample size is 3 or less, whosezhas no such variance, and with fewer than two blocks.Raises
ValueErrorn_kish_blockswithout one size per block.
Examples
z = po.corr.to_z(np.array([0.10, 0.35, 0.05, 0.40])) # one pair's weekly correlations print(round(po.corr.signal_share(z, [200, 200, 200, 200]), 3))
0.855
See also
fisher_se(), the sampling error of one correlation.
Notes
1 / (n - 3)is the sampling variance ofz, so the ratio is the share of the observed variance across blocks that sampling noise explains, and one minus it is what is left.