
Estimate precision weights from a curveR calibration result
Source:R/fit_precision_weights.R
fit_precision_weights.RdThe curveR-ecosystem entry point. Estimates the power-law relationship
between calibration-curve precision and residual variance,
\(\sigma_i = \phi\, se_i^{\beta_1}\), \(w_i = 1/\sigma_i^2\), using a
joint Bayesian location-scale model with a saturated cell-means location
(see fit_saturated_weight()). The default scale predictor is the uncapped
se_concentration from the calibration curve, so \(\phi = 1\) means
"se_concentration is a calibrated residual SD".
Usage
fit_precision_weights(
data,
design = NULL,
scale_predictor = c("se", "pcov"),
plate_col = NULL,
...
)Arguments
- data
Either the output of
as_weight_data()(classweight_data), or acalibration_result(_multiplate)/ plaindata.frame, in which casedesignis required andas_weight_data()is called internally.- design
Character vector of design-group columns (required unless
datais already aweight_data).- scale_predictor
"se"(default; uncapped log10-scale SD) or"pcov"(legacy, lossy because of the cap).- plate_col
Plate grouping column for the location random intercept. Defaults to
"curve_id"when present, elseNULL.- ...
MCMC controls and priors passed to
fit_saturated_weight()(e.g.iter,warmup,chains,cores,adapt_delta,seed).
Value
A precision_weights object: a list with $estimates
(phi, beta1, CIs, interpretation, diagnostics), $weights (data frame
keyed by obs_id/sampleid/curve_id with se,
pcov, sigma, w, w_norm), $design,
$scale (conc_scale + scale_predictor), and $fit (the brms
fit).
Examples
# \donttest{
# mp <- curveRfreq::fit_calibration_freq_multiplate(
# standards = std, samples = samples_with_design, ...)
# wd <- as_weight_data(mp, design = c("timeperiod", "cohort_arm"))
# pw <- fit_precision_weights(wd, iter = 1000, warmup = 500, chains = 2)
# pw$estimates$phi; pw$estimates$beta1
# }