hs3city / surveypie

MIT License
5 stars 1 forks source link

Abul Naga and Yalcin Index #29

Closed SimonMolinsky closed 7 months ago

SimonMolinsky commented 1 year ago

Abul Naga and Yalcin indices

Create a function to calculate Abul Naga and Yalcin indices from ordinal data. The function definition is:


def any_index(ds: Iterable, a_param: Optional[int] = 1, b_param: Optional[int] = 1):
    pass

where:

Parameters a_param and b_param are designed to put different weights to inequalities below and above the median (see example below).

Steps

The algorithm has five steps:

  1. Calculate the median value $m$ from ds. It must be an integer!
  2. Get the number of categories $n$.
  3. Build cumulative distribution for each category $P{i}$, where the last category $P{n}$ should be equal to 1.
  4. Calculate the index based on the equation:
I_{\alpha , \beta} = \frac{\sum_{i < m}{P_{i}^{\alpha}} - \sum_{i \ge m}P_{i}^{\beta} + (n+1-m)}{k_{\alpha , \beta} + (n+1-m)}

where:

and:

$$k_{\alpha , \beta}=(m-1)(\frac{1}{2})^{\alpha}-[1-(n-m)(\frac{1}{2})^{\beta}]$$

With $(\alpha=\beta)$ inequality is at a minimum when everyone is in the same category and at a maximum when half of the population lies in the lowest category and half in the highest category. Different calibrations of the parameters $\alpha$ and $\beta$ allow the researcher to give different weights to inequalities above and below the median of the responsiveness distribution - for higher values of $\alpha$ ($\beta$), less weight is given to inequalities below (above) the median. However, by design, the index can only be used to compare distributions with the same median category [1].

Returns

Abul Naga and Yalcin index: float

Bibliography

SimonMolinsky commented 1 year ago

@Arturstrag, how is it going? Would you like some help with this task?

SimonMolinsky commented 7 months ago

@Arturstrag I'd like to take this issue from you :) If this is okay, then on Monday (5th of Feb), I'll change the assignment of the issue.

Arturstrag commented 7 months ago

Ok