
Prediction-Powered Mean Estimation (PPI / PPI++ / Active IPW-PPI)
Source:R/ppi_models.R
ppi_mean.RdEstimates the population mean \(\theta^* = \mathbb{E}[Y]\) by combining
a human-validated sample (truth_col observed) with a larger LLM-coded
unlabeled sample (pred_col only). Implements both standard PPI
(lambda = 1) and power-tuned PPI++ (lambda = "auto"), and supports
Horvitz-Thompson inverse-probability-weighted (IPW) active/stratified
validation designs via weights or inclusion_prob (e.g., produced by
select_validation_sample()).
Usage
ppi_mean(
data,
truth_col = "human_score",
pred_col = "llm_score",
unlabeled = NULL,
lambda = "auto",
conf_level = 0.95,
clip_lambda = FALSE,
weights = NULL,
inclusion_prob = NULL
)Arguments
- data
A
data.frame(orllm_coded_data) containingtruth_colandpred_col. Whenunlabeled = NULL, rows with non-missingtruth_colform the labeled validation set and rows withis.na(truth_col)form the unlabeled set.- truth_col
Name of the numeric human gold-standard column.
- pred_col
Name of the numeric LLM prediction column.
- unlabeled
Optional separate
data.frameof unlabeled observations containingpred_col.- lambda
Power-tuning parameter:
"auto"(default, optimal PPI++),1(standard PPI),0(human-only), or any finite numeric scalar.- conf_level
Confidence level in
(0, 1). Default0.95.- clip_lambda
Logical; if
TRUE, constrains auto-tunedlambdato[0, 1]. DefaultFALSE(unconstrained optimal regression control variate is always convex for mean estimation).- weights
Optional Horvitz-Thompson sampling weights \(w_i > 0\) for stratified/active validation sampling: either a column name in
dataor a numeric vector aligned withdata(or the labeled subset). Mutually exclusive withinclusion_prob.- inclusion_prob
Optional validation inclusion probabilities \(\pi_i \in (0, 1]\) (converting to \(w_i = 1 / \pi_i\)): either a column name in
dataor a numeric vector. Mutually exclusive withweights.
Value
An S3 object of class c("llm_ppi_mean", "llm_ppi") containing
$estimates, $benchmarks, $efficiency, $lambda, $vcov, and S3
methods (print(), summary(), coef(), vcov(), confint(),
autoplot()).
Examples
set.seed(42)
n_tot <- 600
y_true <- rnorm(n_tot, mean = 3.5, sd = 1.2)
y_llm <- 0.8 + 0.75 * y_true + rnorm(n_tot, sd = 0.6)
df <- tibble::tibble(
human_score = c(y_true[1:100], rep(NA_real_, n_tot - 100)),
llm_score = y_llm
)
fit <- ppi_mean(df, truth_col = "human_score", pred_col = "llm_score")
fit
#>
#> ── Prediction-Powered Inference (ppi++)
#> Labeled n = 100 | Unlabeled N = 500 | lambda = 0.814 | CI = 95%
#> # A tibble: 1 × 7
#> term estimate std_error conf_low conf_high p_value var_gain
#> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <dbl>
#> 1 (Mean) 3.52 0.0789 3.37 3.67 <0.0001 2.51