Detailed Dive: Variance Formulas and lambda-star
deep-dive-math.RmdMean estimator and PPI++
For labeled size and unlabeled size :
Estimator
Variance
Minimizing yields
lambda_opt <- function(n, N, cov_y_f, var_f) cov_y_f / ((1 + n / N) * var_f)
lambda_opt(n = 200, N = 5000, cov_y_f = 0.6, var_f = 0.6)
#> [1] 0.9615385Power and required
Given effect size
,
target power
,
and level
,
power_ppi_mean() solves
this directly; use it instead of hand algebra:
power_ppi_mean(
delta = 0.2,
N = 5000,
n = NULL,
power = 0.9,
sigma_y2 = 1.0,
sigma_f2 = 0.6,
cov_y_f = 0.6,
lambda_mode = "oracle"
)
#> [1] 109Metrics-to-moments mapping (binary)
For sensitivity/specificity
and prevalence
,
The helper
binary_moments_from_sens_spec() returns
,
,
and
:
binary_moments_from_sens_spec(p = 0.3, sens = 0.85, spec = 0.85)
#> $sigma_y2
#> [1] 0.21
#>
#> $sigma_f2
#> [1] 0.2304
#>
#> $cov_y_f
#> [1] 0.147
#>
#> $p_hat
#> [1] 0.36Use these outputs directly in power_ppi_mean().