| missingness_matrix | R Documentation |
Draws, for every row of data and every variable in specification, whether
that cell is missing, by comparing a uniform draw against the row's
probability. The mask is returned rather than applied, so the complete data
and the mask that hides part of it can both be kept; observed_data() joins
them.
missingness_matrix(
data,
specification,
id = NULL,
period = NULL,
seed = NULL,
envir = parent.frame()
)
data |
Complete base |
specification |
Definitions from |
id |
Optional unit identifier. A single string naming a column of
|
period |
Optional period variable that orders a unit's rows. A single
string naming a column of |
seed |
Optional random seed. A single number, or |
envir |
Environment the formulas are evaluated in after the data columns. Defaults to the caller's environment. |
A base data.frame with one row per row of data, holding the id
and period columns when they are given, or a single row column
numbering the rows when neither is, followed by one logical column per
target variable of specification, named after that variable. Variables of
data that specification says nothing about get no column.
data <- data.frame(id = 1:100, baseline = stats::rnorm(100), outcome = stats::rnorm(100))
specification <- define_missingnesses(
define_missingness("outcome", formula = "0.2")
)
mask <- missingness_matrix(data, specification = specification, seed = 1)
head(mask)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.