prepare_longitudinal_surrogate_data: Prepare data for longitudinal surrogate modeling

View source: R/prepare_longitudinal_data.R

prepare_longitudinal_surrogate_dataR Documentation

Prepare data for longitudinal surrogate modeling

Description

This function standardizes a long-format data set to the internal variables used by the longitudinal model-fitting functions.

Usage

prepare_longitudinal_surrogate_data(
  data,
  id,
  treatment,
  time,
  endpoint,
  outcome,
  surrogate_label,
  true_label,
  treatment_levels = c(0, 1),
  baseline = NULL,
  covariates = character(0)
)

Arguments

data

A data.frame in long format.

id

Character name of the subject identifier column.

treatment

Character name of the treatment column.

time

Character name of the measurement-time column.

endpoint

Character name of the endpoint-label column.

outcome

Character name of the observed outcome column.

surrogate_label

Label identifying the surrogate endpoint.

true_label

Label identifying the true endpoint.

treatment_levels

Two treatment values, ordered as control then active.

baseline

Optional character name of an endpoint-specific baseline value.

covariates

Optional character vector of additional baseline covariates.

Value

A standardized data.frame.

Examples

data(Schizo_PANSS_BPRS)
dat <- prepare_longitudinal_surrogate_data(
       data = Schizo_PANSS_BPRS,
       id = "Id",
       treatment = "Treat",
       time = "Time_cont",
       endpoint = "Endpoint",
       outcome = "Response_log",
       baseline = "Baseline_log",
       surrogate_label = "BPRS",
       true_label = "PANSS",
       treatment_levels = c(0, 1))


Surrogate documentation built on Oct. 16, 2026, 9:07 a.m.