% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add_missingness.R
\name{add_missingness}
\alias{add_missingness}
\title{Add missing values to a predictor matrix}
\usage{
add_missingness(
  x,
  y,
  mechanism = c("MCAR", "MAR"),
  missing_prop,
  seed = NULL,
  mar_y_bias = 0.8
)
}
\arguments{
\item{x}{Predictor matrix or data frame.}

\item{y}{Numeric response vector.}

\item{mechanism}{Missingness mechanism: \code{"MCAR"} or \code{"MAR"}.}

\item{missing_prop}{Missing-data proportion as a fraction (\code{0.05}) or a
percentage (\code{5}).}

\item{seed}{Optional random seed. If supplied, it is used only for this call.}

\item{mar_y_bias}{Proportion of missing values assigned to the upper
half of the observed \code{y} values under the MAR mechanism.}
}
\value{
A list with components \code{x_incomplete}, \code{missing_mask},
\code{missing_prop}, \code{mechanism}, and \code{seed}.
}
\description{
Create MCAR or MAR missingness on the predictor matrix \code{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.
}
\examples{
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))
}
