Constructs a one-sided participation model formula from the variables shared between the nonprobability sample (`sc`) and each reference survey, excluding the sampling weight column. Called by `est_pw()` when `p_formula = NULL`.
p_formula_construction(sc, sp, weight)A list with two elements:
A one-sided formula (one-reference case) or a named list of one-sided formulas (multi-reference case).
A character vector of messages describing the auto-generated formula(s), used for downstream printing when `verbose = TRUE`.
A data frame. The nonprobability sample.
A data frame (one-reference case) or a named list of data frames (multi-reference case). Each data frame contains the analysis variables of one reference survey, with design variables removed and a sampling weight column appended (as produced by `extract_analysis_data()`).
A single character string (one-reference case) or a character vector of the same length as `sp` (multi-reference case) giving the name of the sampling weight column in each reference survey data frame. This column is excluded from the candidate covariate set.
For each reference survey, the candidate covariates are the column names present in both `sc` and the reference survey data frame after dropping the sampling weight column named by `weight`. A one-sided formula of the form `~ var1 + var2 + ...` is built from the remaining shared variables. An error is raised if no shared covariates remain after excluding the weight column.
The function distinguishes the one-reference case from the multi-reference case by the type of `sp`: a plain data frame triggers the one-reference path; a list of data frames triggers the multi-reference path. Note that in R a `data.frame` is also a `list`, so the `is.data.frame()` check is performed first.