Mass Imputation#
Execution: banff.massimp()
SDE function type: Review, Selection, Treatment
Input status flags: None
Output status flags: IMAS
Description#
Performs donor imputation for a block of variables using a nearest neighbour approach or random selection.
The massimp
procedure is intended for use when a large block of variables is missing for a set of respondents, typically when detailed information is collected only for a subsample (or second phase sample) of units. While the donorimp
procedure uses both system and user matching fields, mass imputation only considers user matching fields to find a valid record (donor) that is most similar to the one which needs imputation (recipient).
Mass imputation considers a recipient any record for which all the variables to impute (must_impute
) are missing on indata
, and considers a donors any record for which none of the listed variables are missing. If matching fields (must_match
) are provided by the user, the massimp
procedure uses them to find the nearest donor using the same distance function as donorimp
. If matching fields are not provided, a donor is selected at random.
Unlike donorimp
, the massimp
procedure does not use edits. Before running the procedure, users should ensure that the pool of potential donors do not include any errors, including outliers or consistency errors.
Users may create by-groups by specifying by
variables. These by-groups act as imputation classes. Use the min_donors
and percent_donors
parameters to ensure an appropriate number or ratio of recipients and donors exist in each imputation class before performing imputation.
For a full mathematical description of the procedure methods, with examples, please see the Functional Description.
Input and output tables#
Descriptions of input and output tables are given below. Banff supports a number of input and output formats; please see the Banff User Guide for more information.
Input Table |
Description |
---|---|
indata |
Input statistical data. Mandatory. |
Output Table |
Description |
---|---|
outdata |
Output statistical table containing imputed data. |
outstatus |
Output status file identifying imputed fields with IMAS status flags, and their values after imputation. |
outdonormap |
Output table of recipient-donor pairs for successfully imputed records. |
For details on the content of output tables, please see the Output Tables document.
Parameters#
Parameter |
Python type |
Description |
---|---|---|
unit_id |
str |
Identify key variable (unit identifier) on indata. Mandatory. |
must_impute |
str |
Variables(s) to be imputed. Mandatory. |
must_match |
str |
User defined matching field(s). |
random |
bool |
Random selection of donors. |
min_donors |
int |
Minimum number of donors required to perform imputation. Default=30. |
percent_donors |
float |
Minimum percentage of donors required to perform imputation. Default=30. |
n_limit |
int |
Maximum number of times a donor can be used. |
mrl |
float |
Multiplier ratio limit. |
seed |
int |
Specify the root for the random number generator. |
accept_negative |
bool |
Treat negative values as valid. Default=False. |
by |
str |
Variable(s) used to partition indata into by-groups for independent processing. |
presort |
bool |
Sorts input tables before processing, according to procedure requirements. Default=True. |
no_by_stats |
bool |
Reduces log output by suppressing by-group specific messages. Default=False. |
Notes#
Nearest neighbour or random donor#
The parameters must_match
and random
determine whether the nearest-neighbour algorithm or random selection is used to select donors. The following table shows how specifying these parameters affects mass imputation.
|
|
Syntax |
Imputation |
---|---|---|---|
No |
No |
Incorrect |
Results in an error, no imputation is performed. |
No |
Yes |
Correct |
Random selection of donors. |
Yes |
No |
Correct |
Nearest neighbour selection using |
Yes |
Yes |
Correct |
Nearest neighbour selection using |
If a recipient has missing values for some but not all must_match
variables, the distance to the closest donor will be based only on the must_match
variables that have valid values. If a recipient has missing values for all must_match
variables, then it will be randomly matched to a donor if the random
parameter is specified, and it will not be matched to any donor if the random
parameter is not used.
Multiple equivalent solutions#
In some cases, for a given recipient, there may be multiple equidistant donors (i.e. having the same distance from the recipient) whose values would allow the recipient to pass the edits. When this occurs, the procedure selects one of these solutions at random.
For development or testing purposes, users may wish to produce consistent results over multiple runs of the procedure, and may do so using the seed
parameter. It ensures that the same solutions will be selected from one run to the next, if executed on the same set of inputs. Note that if seed
is not specified, the system generates a default seed.
This parameter can also be used to replicate results when random donor selection is performed.
Limiting the repeated use of donors#
Users may limit the repeated use of donors with the interrelated n_limit
and mrl
parameters. The donor limit is calculated as follows, depending on whether one or both are specified:
|
|
Donor Limit |
---|---|---|
No |
No |
Number of times a donor can be used is unlimited. |
No |
Yes |
round( |
Yes |
No |
|
Yes |
Yes |
round(max( |
When limiting the number of donors with the n_limit
parameter, the number of remaining donors may end up being less than min_donors
. In such a case, mass imputation will continue and ignore min_donors
which was validated at the beginning. The same applies for percent_donors
.