sample_odds_ratio#
- rojak.turbulence.metrics.sample_odds_ratio(first_var: DataArray, second_var: DataArray, sum_over: str, *, use_log: bool = True) DataArray[source]#
Sample odds ratio between two binary variables
An odds ratio (OR) is a statistic that quantifies the strength of the association between two events, A and B. The odds ratio is defined as the ratio of the odds of event A taking place in the presence of B, and the odds of A in the absence of B. Definition from Wikipedia.
- Parameters:
first_var (DataArray) – A binary xarray DataArray representing the exposure variable
second_var (DataArray) – A binary xarray DataArray representing the outcome variable
sum_over (str) – Name of the dimension to sum over when computing the 2x2 contingency table. This dimension will be aggregated to obtain cell counts (n_00, n_01, n_10, n_11).
use_log (bool) – If True (default), returns the natural logarithm of the odds ratio. Set to False to return the raw odds ratio. Default is True.
- Returns:
- The sample odds ratio (or log odds ratio if use_log=True).
Dimensions are preserved except for the summed dimension.
- Return type:
xr.DataArray
Notes
OR > 1 indicates increased odds of outcome with exposure
OR < 1 indicates decreased odds of outcome with exposure
OR = 1 indicates no association between exposure and outcome
The log odds ratio is often preferred for statistical analysis as it has better distributional properties