% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/estpw_s3_process_na.R
\name{process_na_build}
\alias{process_na_build}
\title{Handle missing values at the build stage (first layer)}
\usage{
process_na_build(sc, sp, sp_des, p_formula, na.action, n_ref, verbose = FALSE)
}
\arguments{
\item{sc}{A data frame. The nonprobability sample (before NA removal).}

\item{sp}{A data frame (one-reference case) or a named list of data frames
(multi-reference case). Analysis data extracted from the reference
survey design(s).}

\item{sp_des}{A single survey design object (one-reference case) or a
named list of survey design objects (multi-reference case). Subsetted
to align with the filtered `sp`.}

\item{p_formula}{A one-sided formula (one-reference case) or a list of
one-sided formulas (multi-reference case) specifying the participation
model variables used to identify rows with missing values.}

\item{na.action}{A function (`stats::na.omit`, `stats::na.exclude`,
`stats::na.fail`, or `stats::na.pass`), an equivalent character string,
or `NULL` (which inherits from `getOption("na.action")`).}

\item{n_ref}{Integer. Number of reference surveys. Controls whether
one-reference or multi-reference logic is applied when subsetting
`sp_des` and computing `n_sp_orig`.}

\item{verbose}{Logical. If `TRUE`, prints per-dataset row counts and
exclusion totals via `message()`.}
}
\value{
A list with the following elements:
\describe{
  \item{`na_mode`}{Character string: one of `"omit"`, `"exclude"`,
    `"fail"`, or `"pass"`.}
  \item{`sc`}{The cleaned nonprobability sample data frame.}
  \item{`sp`}{The cleaned reference survey data frame(s).}
  \item{`sp_des`}{The subsetted survey design object(s).}
  \item{`keep_sc`}{Logical vector indicating which rows of the original
    `sc` are retained.}
  \item{`keep_sp`}{Logical vector (one-reference) or list of logical
    vectors (multi-reference) indicating which rows of each `sp` are
    retained.}
  \item{`n_sp_orig`}{Original row count(s) of `sp_des` before
    subsetting.}
  \item{`na_action_obj`}{An lm-style `na.action` attribute for `sc`,
    or `NULL` if no rows were removed.}
  \item{`log_messages`}{Character vector of per-variable NA detail
    messages from `handle_na_for_ipwm()`, suitable for appending to
    the running `log_messages` in `est_pw()`.}
  \item{`na_summary`}{A `pw_na_summary` object with row counts before
    and after NA removal, or `NULL` if no rows were excluded.}
}
}
\description{
Process NA for `est_pw()` before estimation step.
Resolves the `na.action` argument to a standard mode string, applies NA
filtering to `sc` and `sp`, subsets the survey design object(s) in
`sp_des` to match the filtered `sp`, and produces a summary of
exclusions.
}
\keyword{internal}
