View source: R/add_missingness.R
| add_missingness | R Documentation |
Create MCAR or MAR missingness on the predictor matrix x. Missingness is
generated column-wise so that each predictor receives approximately the same
missing-data proportion, matching the simulation strategy used in the
original work.
add_missingness(
x,
y,
mechanism = c("MCAR", "MAR"),
missing_prop,
seed = NULL,
mar_y_bias = 0.8
)
x |
Predictor matrix or data frame. |
y |
Numeric response vector. |
mechanism |
Missingness mechanism: |
missing_prop |
Missing-data proportion as a fraction ( |
seed |
Optional random seed. If supplied, it is used only for this call. |
mar_y_bias |
Proportion of missing values assigned to the upper
half of the observed |
A list with components x_incomplete, missing_mask,
missing_prop, mechanism, and seed.
sim <- simulate_pls_data(n = 20, p = 10, true_ncomp = 2, seed = 1)
miss <- add_missingness(sim$x, sim$y, mechanism = "MCAR", missing_prop = 10, seed = 2)
mean(is.na(miss$x_incomplete))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.