
Prediction-Powered Generalized Linear Model (PPI / PPI++ / Calibrated)
Source:R/ppi_models.R
ppi_glm.RdFits an error-corrected canonical-link GLM (gaussian, binomial, or
poisson) combining a human-validated subset with a larger LLM-coded
unlabeled corpus via Angelopoulos et al. (2024) M-estimation PPI/PPI++ or
coordinate-wise control-variate calibration.
Arguments
- formula
Two-sided model formula
y ~ x1 + x2.- data
A
data.framecontaining the response, predictors, and LLM prediction column. Whenunlabeled = NULL, rows with missing response form the unlabeled set.- pred_col
Name of the LLM prediction column (numeric; for binomial models may be binary
{0, 1}or predicted probabilities in[0, 1]).- family
Canonical GLM family:
gaussian(),binomial(), orpoisson()(or matching string name). Defaultstats::binomial().- unlabeled
Optional separate
data.frameof unlabeled observations.- method
Estimation method:
"ppi++"(default, optimal power-tuning \(\hat{\lambda}^* \in [0, 1]\)),"ppi"(lambda = 1), or"calibrated"(coordinate-wise influence-function calibration).- lambda
Optional numeric override for scalar
lambdain[0, 1].- conf_level
Confidence level in
(0, 1). Default0.95.- max_iter
Maximum Newton-Raphson iterations. Default
60L.- tol
Convergence tolerance for gradient/step norm. Default
1e-9.
Examples
set.seed(7)
n_tot <- 800
x <- rnorm(n_tot)
p_true <- plogis(-0.3 + 1.1 * x)
y_true <- rbinom(n_tot, 1, p_true)
y_llm <- plogis(-0.3 + 1.1 * x + 0.7 + rnorm(n_tot, sd = 0.6))
df <- tibble::tibble(
x = x,
human_y = c(y_true[1:150], rep(NA_real_, n_tot - 150)),
llm_prob = y_llm
)
fit <- ppi_glm(human_y ~ x, data = df, pred_col = "llm_prob", family = binomial())
fit
#>
#> ── Prediction-Powered Inference (ppi++)
#> Labeled n = 150 | Unlabeled N = 650 | lambda = 0.162 | CI = 95%
#> # A tibble: 2 × 7
#> term estimate std_error conf_low conf_high p_value var_gain
#> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <dbl>
#> 1 (Intercept) -0.253 0.186 -0.619 0.112 0.1748 1.02
#> 2 x 1.06 0.228 0.612 1.51 <0.0001 1.06