set_switch_weight_model {TrialEmulation} | R Documentation |
Set switching weight model
Description
Usage
set_switch_weight_model(object, numerator, denominator, model_fitter, ...)
## S4 method for signature 'trial_sequence'
set_switch_weight_model(
object,
numerator,
denominator,
model_fitter,
eligible_wts_0 = NULL,
eligible_wts_1 = NULL
)
## S4 method for signature 'trial_sequence_ITT'
set_switch_weight_model(object, numerator, denominator, model_fitter)
Arguments
object |
A trial_sequence object. |
numerator |
Right hand side formula for the numerator model |
denominator |
Right hand side formula for the denominator model |
model_fitter |
A te_model_fitter object, such as stats_glm_logit |
... |
Other arguments used by methods. |
eligible_wts_0 |
Name of column containing indicator (0/1) for observation to be excluded/included in weight model. |
eligible_wts_1 |
Exclude some observations when fitting the models for the inverse probability of treatment
weights. For example, if it is assumed that an individual will stay on treatment for at least 2 visits, the first 2
visits after treatment initiation by definition have a probability of staying on the treatment of 1.0 and should
thus be excluded from the weight models for those who are on treatment at the immediately previous visit. Users can
define a variable that indicates that these 2 observations are ineligible for the weight model for those who are on
treatment at the immediately previous visit and add the variable name in the argument |
Value
object
is returned with @switch_weights
set
Examples
trial_sequence("PP") |>
set_data(data = data_censored) |>
set_switch_weight_model(
numerator = ~ age_s + x1 + x3,
denominator = ~ x3 + x4,
model_fitter = stats_glm_logit(tempdir())
)