knitr::opts_chunk$set(echo = TRUE, eval = FALSE)

User interface

After expansion, we need to fit the outcome model. Before that we need to prepare the outcome data set. This might involve sampling, or some other filtering or variable derivation.

trial_itt <- trial_sequence(...) |> ... |> set_outcome_model(...) |> expand_trials()

simple case

with small data it should just work

fit_msm(trial_itt)

This would load the full expanded data and fit the model

with sampling

-> Maybe delete sample_controls and just have a single method like load_trial_data()

This should be done simply

trial_itt <- sample_controls(trial_itt, p_control = 0.3, seed = 444)
fit_msm(trial_itt)

simple filtering

with small data it should just work

trial_itt <- load_trial_data(trial_itt, period = 1:100, subset_condition = "age > 30", p_control = NULL, seed = NULL)
fit_msm(trial_itt)

some complex filtering

model_data(trial_itt) <- model_data(trial_itt) |> group_by() |> mutate()
fit_msm(trial_itt)

Internal Representation

Currently the input data has a slot @data and a class te_data which has some validation, eg on columns.

We could have a second slot eg @model_data. We would need a different or modified te_data class, at least the validation. Alternatively we could directly have the data.table in the slot and validation could occur in the getter/setter methods.

Option: data.table

Remove te_data class and do all validation in setter methods.

Option: te_data classes

Modify class

Option: te_data_model, te_data_input

More subclasses which inherit from te_data

Internal flow

If we have the two data slots, @data, @model_data

Chosen Design



CAM-Roche/RandomisedTrialsEmulation documentation built on April 14, 2025, 7:44 a.m.