prepare_SensIAT_data: Prepare Data for Sensitivity Analysis with Irregular...

View source: R/prepare_data.R

prepare_SensIAT_dataR Documentation

Prepare Data for Sensitivity Analysis with Irregular Assessment Times

Description

This function prepares the data for SensIAT analysis by transforming it into a format suitable for the SensIAT models.

Usage

prepare_SensIAT_data(
  data,
  id.var,
  time.var,
  outcome.var,
  End,
  add.terminal.observations = TRUE
)

Arguments

data

A data frame containing the data to be prepared.

id.var

The variable in data that identifies the subject.

time.var

The variable in data that identifies the time of the observation.

outcome.var

The variable in data that contains the outcome of interest.

End

The end time for the analysis. Observations with time greater than End will be filtered out.

add.terminal.observations

Logical indicating whether to add terminal observations to the data (TRUE), or terminal observations have already been added (FALSE).

Value

A data frame with the following transformations:

  • Data filtered to time less than or equal to End.

  • Observations are arranged by id.var and time.var.

  • Terminal observations added if add.terminal.observations is TRUE, with ..time.. set to End and ..outcome.. set to NA, if the subject has less observations than the maximum number of observations.

  • New variables created:

    • ..id.. aliases id.var,

    • ..time.. aliases time.var,

    • ..outcome.. aliases outcome.var,

    • ..visit_number.. is the visit number within each subject derived from time.var,

    • ..prev_outcome.., i.e. lag-outcome, the outcome from the previous visit,

    • ..prev_time.., i.e. lag-time, the time from the previous visit,

    • ..delta_time.., the difference in time between the current and previous visit.

Examples


prepare_SensIAT_data( SensIAT_example_data, Subject_ID, Time, Outcome, 830)

exdata <- tibble::tibble(ID=rep(1:2, c(3,5)),
                         Time=c(0, 30, 60,
                                0, 30, 60, 90, 120),
                         Outcome=floor(runif(8, 1, 100)))

prepare_SensIAT_data(exdata, ID, Time, Outcome, 120)


SensIAT documentation built on Sept. 9, 2025, 5:50 p.m.