Feature/lago sensitivity - #94
Merged
Merged
Conversation
Adds an exported lago_sensitivity() that re-runs lago_optimization() across a sweep of one input and reports how the recommended intervention, its cost, and the estimated outcome move, so a user can see how robust the recommendation is to inputs they are unsure about. Pass the same arguments as lago_optimization() plus `parameter` (what to vary) and `values` (the sweep). `parameter` is either the name of a scalar numeric argument that affects the recommendation (e.g. "outcome_goal", "power_goal") or the special "cost_multiplier", which scales every cost coefficient by each value. Each run forces include_confidence_set = FALSE for speed and is wrapped so a failing run is recorded as NA with a status note rather than aborting the sweep; one warning names any failed values. Returns a tidy "lago_sensitivity" data frame (value, the recommended value of each component, rec_int_cost, est_outcome_goal, status) with print() and plot() methods. Confidence-set-only scalars such as confidence_set_alpha are rejected, since the confidence set is not computed during a sweep and sweeping them would return identical rows. Includes tests (cost_multiplier argmin-invariance, outcome_goal cost monotonicity, graceful single-run failure, and validation), roxygen with a runnable example, a README section, a vignette section, and pkgdown reference entries.
lago_optimization() now records its evaluated call arguments on the result (as a "lago_call_args" attribute, so the printed output and $-accessible fields are unchanged), and lago_sensitivity() gains an optional first `object` argument. Passing the fitted result reuses that call, so the whole optimization does not have to be retyped: `opt <- lago_optimization(...)` then `lago_sensitivity(opt, parameter = "outcome_goal", values = ...)`. Any arguments in ... override the stored ones. Calling lago_sensitivity() without a result (passing the arguments directly) still works exactly as before. The two forms produce identical results. Adds object-form tests (equivalence to the direct form, ... override, missing-attribute and non-lago errors), and updates the roxygen, README, and vignette to lead with the fit-then-sweep flow.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Adds
lago_sensitivity(), a robustness analysis for a LAGO recommendation, andlets it be driven by a fitted result.
lago_sensitivity()re-runslago_optimization()across a sweep of one inputand reports how the recommended intervention, its cost, and the estimated
outcome move — a stringency curve for the outcome goal, or a line for a uniform
cost rescaling.
parameteris a scalar numeric argument that affects therecommendation (e.g.
"outcome_goal","power_goal") or the special"cost_multiplier"(scales all costs);valuesis the sweep.lago_optimization()now records its call argumentson the result (as a
"lago_call_args"attribute, leaving the printed outputand
$fields unchanged), so you can pass the fitted result and skip retyping:opt <- lago_optimization(...); lago_sensitivity(opt, parameter=..., values=...)....overrides stored args; the direct-arguments form still works, identically."lago_sensitivity"data frame (value, the recommended valueof each component,
rec_int_cost,est_outcome_goal,status) withprint()and
plot()methods. Each run forcesinclude_confidence_set = FALSEforspeed and is wrapped so a failing run is
NA+ a status note (one warning),not an aborted sweep. Confidence-set-only scalars like
confidence_set_alphaare rejected.
section, pkgdown reference entries; NEWS updated.
Related issue
Closes #
Checklist
tests/testthat/(argmin-invariance, goal-cost monotonicity, graceful failure, validation, object-formequivalence + override + error paths)
devtools::document()run (newman/*.Rd, NAMESPACE export + S3methods)devtools::check()passes locally (suite 1319 pass / 0 fail; vignette knits; pkgdown clean)NEWS.mdupdated