rheon.corr.fisher_se

rheon.corr.fisher_se(n: float, rho: float | None = None, phi_a: float | None = None, phi_b: float | None = None) → float[source]

Compute the standard error of a correlation’s Fisher z, or of the correlation itself.

Use it to judge whether a correlation differs from another, or from 0, by more than its sampling error, on Fisher’s z scale or on the correlation’s own. Give the two series’ AR(1) coefficients to widen it for autocorrelated series.

Parameters

n

The number of observations the correlation is estimated from.

rho

Default None, the standard error of Fisher’s z. Given, the delta-method error of the correlation rho itself, from -1 to 1.

phi_a, phi_b

The two series’ AR(1) coefficients, given together or not at all. Given, the error is inflated for the pair’s autocorrelation (Notes).

Returns

A float:

se = 1 / sqrt(n - 3)                                  # of z
   * (1 - rho**2)                                     # with rho
   * sqrt((1 + phi_a phi_b) / (1 - phi_a phi_b))      # with both phi

It is nan at n <= 3.

Raises

ValueError

A rho outside [-1, 1], one phi without the other, since the inflation is a property of the pair, or phi_a * phi_b outside (-1, 1), at any n.

Examples

print(round(rp.corr.fisher_se(103), 4), round(rp.corr.fisher_se(103, rho=0.5), 4),
      round(rp.corr.fisher_se(103, phi_a=0.5, phi_b=0.5), 4))
0.1 0.075 0.1291

See also

  • to_z(), the z this is the error of.

  • signal_share(), the same sampling error against a correlation’s movement across blocks.

Notes

The AR(1) inflation follows from Bartlett’s formula, Var(r) ~ (1/n) sum_k rho_a(k) rho_b(k), and the geometric series 1 + 2 sum_{k>=1} (phi_a phi_b)**k. It holds under a true cross-correlation of 0 and linear dependence. It is not valid under ARCH-type innovations, where the variance of a sample correlation depends on the fourth moments and this understates it.