Learn R Programming

TrialEmulation (version 0.0.4.2)

weight_model_data_indices: Data used in weight model fitting

Description

[Experimental]

Usage

weight_model_data_indices(
  object,
  type = c("switch", "censor"),
  model,
  set_col = NULL
)

Value

If set_col is not specified a logical data.table column is returned. Otherwise

Arguments

object

A trial_sequence object

type

Select a censoring or switching model

model

The model name

set_col

A character string to specifying a new column to contain indicators for observations used in fitting this model.

Examples

Run this code
trial_pp <- trial_sequence("PP") |>
  set_data(data_censored) |>
  set_switch_weight_model(
    numerator = ~age,
    denominator = ~ age + x1 + x3,
    model_fitter = stats_glm_logit(tempdir())
  ) |>
  calculate_weights()
ipw_data(trial_pp)
show_weight_models(trial_pp)

# get logical column for own processing
i <- weight_model_data_indices(trial_pp, "switch", "d0")

# set column in data
weight_model_data_indices(trial_pp, "switch", "d0", set_col = "sw_d0")
weight_model_data_indices(trial_pp, "switch", "d1", set_col = "sw_d1")
ipw_data(trial_pp)

Run the code above in your browser using DataLab