| lago_app | R Documentation |
Opens a Shiny app in your web browser that runs the whole LAGO optimization
without writing R code. You load a dataset, choose the outcome and the goal,
choose the intervention components with their bounds and costs, and say how
the model accounts for centers and time. The app then finds the recommended
intervention with lago_optimization() and shows the result, the confidence
set and the R code that reproduces the run. From that result it can sweep
one input with lago_sensitivity(), find the best outcome for a budget with
lago_budget(), and save a report with lago_report().
lago_app(data = NULL, launch.browser = interactive(), port = NULL)
data |
A data.frame to start with, a |
launch.browser |
Whether to open the app in your web browser. By default it opens in an interactive session. |
port |
The port to listen on, or |
The app runs on your own computer and is reachable only from it, at
127.0.0.1. Nothing is sent over the network.
The app has these steps.
Data: the data you pass, the bundled BB_data or
main_pulesa_data, R's mtcars, or a CSV file you upload. Each example
opens on a setup that runs as is. Each row is one patient, or one center
in one period with a total, which sets input_data_structure.
Outcome and goal: outcome_name, outcome_type, outcome_goal,
outcome_goal_intention, and for a binary outcome the power goal:
power_goal, num_centers_in_next_stage,
patients_per_center_in_next_stage, power_goal_approach, icc and
power_goal_cluster_id. The app builds the group column from the
treatment arm column you choose. For center level data the outcome comes
from a successes or proportion column and a total column, from which the
app builds the proportion and center_sample_size columns. Under
"Outcome model" are glm_family
for a continuous outcome, link, and weights from a column you choose.
Intervention and costs: intervention_components, their bounds, and
the costs as unit_costs with default_cost_fxn_type and
unit_cost_doses, or as cost_list_of_vectors. The "Shape the costs
visually" button opens the cost designer of visualize_cost() in a dialog,
which starts on the costs in use and puts the shaped costs in as cost
coefficients. Interaction terms set
include_interaction_terms and main_components, and the app builds each
product column. Under "Confidence set" are include_confidence_set,
confidence_set_alpha as a confidence level, and
confidence_set_grid_step_size. Under "Optimizer" are
optimization_method and optimization_grid_search_step_size, and under
"Previous stage" is prev_recommended_interventions.
Centers, time and covariates: center_characteristics with their
values, or fixed center effects with include_center_effects and
center_effects_optimization_values or your own
center_weights_for_outcome_goal, fixed time effects with
include_time_effects and time_effect_optimization_value, and
additional_covariates. The app builds the center and period columns
from the columns you choose.
A step that needs attention says what to change, and the run button stays off until every step is ready. Warnings from the package are listed with the result.
After a run, these tabs start from its result.
Results: the recommendation, the confidence set with a CSV download,
the outcome model, the intervention test, and the report download of
lago_report(), which needs the rmarkdown, knitr and jsonlite packages
and pandoc.
Sensitivity: lago_sensitivity() with parameter and values. It
varies the outcome goal, a multiplier of all costs, and with a power goal
the power goal, the centers and patients of the next stage, and the ICC.
With time effects it varies the period. The values are even steps from a
start to an end, or a typed list. A plot, a table and a CSV download show
the result.
Budget: lago_budget() with budget and n_grid. The budget starts
at the cost of the recommendation. The best outcome it buys can be put in
as the outcome goal.
R code: the code of the run, followed by the code of the last sweep and budget search of that result.
Save settings downloads every setting as an .rds file, without the
data, and Load settings puts them back on the same data. Started from a
lago result, the app opens on the settings of its call and lists any it
cannot show. A grid step that the call left to the package is put in as
the step the package used, so a new run gives the same result.
A column name of an uploaded file that R cannot use is changed to one it can, and a name with letters that are not ASCII, such as an accent, is changed to ASCII, so the shown code runs in any locale. Step 1 lists the names that changed.
Invisibly, when you click Done or close the browser tab, a list
with the last result of lago_optimization() for the settings in the
app (or NULL if nothing was run since a reset, a new dataset or loaded
settings, or the last run failed), the last sensitivity of
lago_sensitivity() and budget of lago_budget() run from it (or NULL), the R code of all of them as a
character vector, and the arguments of the optimization. The same list
is stored in the lago_app_result option.
lago_optimization() for the function the app runs,
lago_sensitivity(), lago_budget() and lago_report() for the tabs
that start from its result, and visualize_cost() for the cost designer.
if (interactive()) {
out <- lago_app()
out$result
cat(out$code, sep = "\n")
# change a setting of that result and run it again
lago_app(out$result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.