API reference

andrey.data.missingness.mar#

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

Values missing at random.

Each indicator depends only on columns that are always observed.

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 and at least one; 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 always-observed column under "logistic", and one of them under "quantile".

  • parents (Mapping[int, Sequence[int]] | None) – The columns that can go missing, each mapped to the always-observed columns its indicator depends on, by column of the data: {3: [0]} makes column 3 go missing with column 0. Every other column is always observed, and no parent can go missing. "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 can go missing, a column without parents, or more than one parent under "quantile".

Examples

>>> from andrey.data.missingness import mar
>>> mar(0.2, form="quantile", parents={3: [0]}).parents
((3, (0,)),)