API reference

andrey.data.missingness.mnar#

andrey.data.missingness.mnar(rate, *, observed=0.3, form='logistic', parents=None)[source]#

Values missing not at random.

Each indicator depends on other columns that can go missing, never on its own column.

Parameters:
  • rate (float) – The expected share of missing values in each column that can go missing, in (0, 1); in (0.01, 0.9) for form="quantile".

  • observed (float) – The share of the columns that are always observed, in [0, 1), rounded to a whole number of columns; at least two columns must be able to go missing. Which ones is drawn. parents, when given, decides the columns instead.

  • form (str) – How an indicator depends on its parents (see andrey.data.missingness). Drawn parents are every other column that can go missing under "logistic", and one of them under "quantile".

  • parents (Mapping[int, Sequence[int]] | None) – The columns that can go missing, each mapped to the other columns that can go missing its indicator depends on, by column of the data: {3: [5], 5: [3]}. Every other column is always observed. "quantile" takes one parent per column. None draws them.

Return type:

Mechanism

Raises:

ValueError – If rate or observed is out of range, form is not one of the forms, or parents names a parent that is not another column that can go missing, a column without parents, or more than one parent under "quantile".

Examples

>>> from andrey.data.missingness import mnar
>>> mnar(0.2, parents={3: [5], 5: [3]}).name
'mnar'