impact_statistics#
- rojak.atmosphere.feature_composite.impact_statistics(counts, *, min_count=10, haldane=False)[source]#
How the feature changes traffic and the probability of each event, relative to the controls.
The counts are summed over
chunkfirst; every other dimension, includingcontrol, is kept. Each eventewith a pair of variablesfeature_n_<e>andcontrol_n_<e>gets its own measures, from the 2x2 tablen_11 = E_feat: events about the feature,n_10 = N_feat - E_feat: observations about the feature that are not events,n_01 = E_ctl: events in the control,n_00 = N_ctl - E_ctl: observations in the control that are not events,
where
Nisfeature_n_obsorcontrol_n_obsandEisfeature_n_<e>orcontrol_n_<e>.A zero in a denominator gives NaN, never infinity, while a zero in a numerator is a real 0.
- Parameters:
counts (xarray.Dataset) – Per-chunk counts as returned by the pipeline, with
feature_n_obs,control_n_obs,n_centres,n_controlsand any event pairs. Computed here if lazy.min_count (float) – Bins where the observations summed over chunks are fewer than this, about the feature or in the control, are NaN: in
p_feature_<e>orp_control_<e>for that side, and in the ratios for either side.traffic_per_centreandtraffic_per_controlare not masked.haldane (bool) – If
True, add 0.5 to every cell of the table before the odds ratio (the Haldane correction), so that it is finite where a cell is zero. The other measures are not corrected.
- Returns:
In memory, with:
traffic_per_centre:N_feat / n_centres, observations per bin per centre.traffic_per_control:N_ctl / n_controls, observations per bin per control.traffic_ratio: their ratio. Above 1 means more traffic about the feature than without it.p_feature_<e>/p_control_<e>:E / N, probability of the event per observation.relative_risk_<e>:p_feature_<e> / p_control_<e>, fromrelative_risk_from_table().odds_ratio_<e>:n_11 n_00 / (n_10 n_01), fromodds_ratio_from_table().
- Return type: