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)forform="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 (seeandrey.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.Nonedraws them.
- Return type:
- Raises:
ValueError – If
rateorobservedis out of range,formis not one of the forms, orparentsnames 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,)),)