For each point on the prediction grid: evaluates the forward model
to get predicted response and delta-method CI (via
curveRcore::compute_curve_ci()), then back-calculates concentration
and propagates uncertainty to get se_concentration and pcov.
Usage
predict_grid_freq(
grid,
fit,
model_name,
fixed_a = NULL,
se_response = 0,
cv_x_max = 150,
pcov_threshold = 20,
is_log_independent = TRUE,
is_log_response = TRUE,
independent_variable = "concentration",
verbose = FALSE
)Arguments
- grid
Data frame from
curveRcore::generate_prediction_grid(). Must contain anx_fitcolumn (grid points on the fitting scale).- fit
The best-fit
nlsLMobject.- model_name
Character. Model name (must be in
curveRcore::available_models()).- fixed_a
Numeric or NULL. Fixed lower asymptote on fitting scale. When non-NULL the
aparameter is removed fromthetaandSigmabefore gradient computation.- se_response
Numeric. Residual SE of the response on the fitting scale. Typically
summary(fit)$sigma. Default 0 (parameter uncertainty only).- cv_x_max
Numeric. Hard cap for
pcovandpcov_rmse(%). Values above this are clamped. Default 150.- pcov_threshold
Numeric. Precision threshold (%) used to set
pcov_pass. A grid point passes whenpcov < pcov_threshold. Default 20. Must be<= cv_x_max.- is_log_independent
Logical. Is the independent variable (x) on the log10 scale? When
TRUE, alog10_concentrationcolumn is written as an alias forx_fit, andpcovis computed asSE_x * log(10) * 100. DefaultTRUE.- is_log_response
Logical. Passed to
curveRcore::enrich_grid_with_d2y(). DefaultTRUE.- independent_variable
Character. Name of the independent variable column in
grid. Default"concentration".- verbose
Logical. Emit per-point diagnostic messages. Default
FALSE.
Value
The input grid data frame with the following columns appended:
log10_concentrationAlias for
x_fitwhenis_log_independent = TRUE; otherwiseNA_real_. Present unconditionally so downstream code can always reference it.predicted_responseForward model prediction \(\hat{y} = f(x, \hat{\theta})\) on the fitting scale.
ci_lower,ci_upperDelta-method 95\ scale.
predicted_concentrationBack-calculated concentration from \(\hat{y}\), on the fitting scale.
se_concentrationDelta-method SE of
predicted_concentration.pcovPercent CV of back-calculated concentration (\ at
cv_x_max.pcov_rmseRelative RMSE (\ bias of
predicted_concentrationvsx_fit. Capped atcv_x_max.pcov_passLogical.
TRUEwhenpcov < pcov_thresholdandpcovis finite.d2y_dx2Second derivative \(d^2(\log_{10} y)/d(\log_{10} x)^2\) at each grid point, added by
curveRcore::enrich_grid_with_d2y().
