Learn R Programming

concrete (version 1.0.5)

formatArguments: formatArguments

Description

formatArguments() checks and reformats inputs into a form that can be interpreted by doConcrete(). makeITT() returns an Intervention list for a single, binary, point-treatment variable

Usage

formatArguments(
  DataTable,
  EventTime,
  EventType,
  Treatment,
  ID = NULL,
  TargetTime = NULL,
  TargetEvent = NULL,
  Intervention,
  CVArg = NULL,
  Model = NULL,
  MaxUpdateIter = 500,
  OneStepEps = 0.1,
  MinNuisance = 5/sqrt(nrow(DataTable))/log(nrow(DataTable)),
  Verbose = TRUE,
  GComp = TRUE,
  ReturnModels = TRUE,
  ConcreteArgs = NULL,
  RenameCovs = TRUE,
  ...
)

makeITT(...)

# S3 method for ConcreteArgs print(x, ...)

Value

a list of class "ConcreteArgs"

  • Data: data.table containing EventTime, EventType, Treatment, and potentially ID and baseline covariates. Has the following attributes

    • EventTime: the column name of the observed event or censoring time

    • EventType: the column name of the observed event type. (0 indicating censoring)

    • Treatment: the column name of the observed treatment assignment

    • ID: the column name of the observed subject id

    • RenameCovs: boolean whether or not covariates are renamed

  • TargetTime: numeric vector of target times to evaluate risk/survival

  • TargetEvent: numeric vector of target events

  • Regime: named list of desired regimes, each tagged with a 'g.star' attribute function

    • Regime[[i]]: a vector of desired treatment assignments

    • attr(Regime[[i]], "g.star"): function of Treatment and Covariates, outputting a vector of desired treatment assignment probabilities

  • CVFolds: list of cross-validation fold assignments in the structure as output by origami::make_folds()

  • Model: named list of model specifications, one for each unique 'EventType' and one for the 'Treatment' variable.

  • MaxUpdateIter: the number of one-step update steps

  • OneStepEps: list of cross-validation fold assignments in the structure as output by origami::make_folds()

  • MinNuisance: numeric lower bound for the propensity score denominator in the efficient influence function

  • Verbose: boolean to print additional information

  • GComp: boolean to return g-computation formula plug-in estimates

  • ReturnModels: boolean to return fitted models from the initial estimation stage

Arguments

DataTable

data.table (n x (d + (3:5)); data.table of the observed data, with rows n = the number of observations and d = the number of baseline covariates. DataTable must include the following columns:

  • "EventTime": numeric; real numbers > 0, the observed event or censoring time

  • "EventType": numeric; the observed event type, censoring events indicated by integers <= 0

  • "Treatment": numeric; the observed treatment value. Binary treatments must be coded as 0, 1

  • "Treatment": numeric; the observed treatment

May include

  • "ID": factor, character, or numeric; unique subject id. If ID column is missing, row numbers will be used as ID. For longitudinal data, ID must be provided

  • "Baseline Covariates": factor, character, or numeric;

EventTime

character: the column name of the observed event or censoring time

EventType

character: the column name of the observed event type. (0 indicating censoring)

Treatment

character: the column name of the observed treatment assignment

ID

character (default: NULL): the column name of the observed subject id longitudinal data structures

TargetTime

numeric: vector of target times. If NULL, the last observed non-censoring event time will be targeted.

TargetEvent

numeric: vector of target events - some subset of unique EventTypes. If NULL, all non-censoring observed event types will be targeted.

Intervention

list: a list of desired interventions on the treatment variable. Each intervention must be a list containing two named functions: 'intervention' = function(treatment vector, covariate data) and 'gstar' = function(treatment vector, covariate data) concrete::makeITT() can be used to specify an intent-to-treat analysis for a binary intervention variable

CVArg

list: arguments to be passed into do.call(origami::make_folds). If NULL, the default is list(n = nrow(DataTable), fold_fun = folds_vfold, cluster_ids = NULL, strata_ids = NULL)

Model

list (default: NULL): named list of models, one for each failure or censoring event and one for the 'Treatment' variable. If Model = NULL, then a template will be generated for the user to amend.

MaxUpdateIter

numeric (default: 500): the number of one-step update steps

OneStepEps

numeric (default: 1): the one-step tmle step size

MinNuisance

numeric (default: 5/log(n)/sqrt(n)): value between (0, 1) for truncating the g-related denominator of the clever covariate

Verbose

boolean

GComp

boolean (default: TRUE): return g-computation formula plug-in estimates

ReturnModels

boolean (default: TRUE): return fitted models from the initial estimation stage

ConcreteArgs

list (default: NULL, not yet ready) : Use to recheck amended output from previous formatArguments() calls. A non-NULL input will cause all other arguments to be ignored.

RenameCovs

boolean (default: TRUE): whether or not to rename covariates

...

additional arguments to be passed into print methods

x

a ConcreteArgs object

Functions

  • makeITT(): makeITT ...

  • print(ConcreteArgs): print.ConcreteArgs print method for "ConcreteArgs" class

Examples

Run this code
library(data.table)
library(concrete)

data <- as.data.table(survival::pbc)
data <- data[1:200, .SD, .SDcols = c("id", "time", "status", "trt", "age", "sex")]
data[, trt := sample(0:1, nrow(data), TRUE)]

# makeITT() creates a list of functions to specify intent-to-treat
#   regimes for a binary, single, point treatment variable
intervention <- makeITT()

# formatArguments() returns correctly formatted arguments for doConcrete()
#   If no input is provided for the Model argument, a default will be generated
concrete.args <- formatArguments(DataTable = data,
                                 EventTime = "time",
                                 EventType = "status",
                                 Treatment = "trt",
                                 ID = "id",
                                 TargetTime = 2500,
                                 TargetEvent = c(1, 2),
                                 Intervention = intervention,
                                 CVArg = list(V = 2))

# Alternatively, estimation algorithms can be provided as a named list
model <- list("trt" = c("SL.glm", "SL.glmnet"),
              "0" = list(Surv(time, status == 0) ~ .),
              "1" = list(Surv(time, status == 1) ~ .),
              "2" = list(Surv(time, status == 2) ~ .))
concrete.args <- formatArguments(DataTable = data,
                                 EventTime = "time",
                                 EventType = "status",
                                 Treatment = "trt",
                                 ID = "id",
                                 TargetTime = 2500,
                                 TargetEvent = c(1, 2),
                                 Intervention = intervention,
                                 CVArg = list(V = 2), 
                                 Model = model)

# 'ConcreteArgs' output can be modified and passed back through formatArguments()
# examples of modifying the censoring and failure event candidate regressions
concrete.args[["Model"]][["0"]] <-
    list(Surv(time, status == 0) ~ trt:sex + age)
concrete.args[["Model"]][["1"]] <-
    list("mod1" = Surv(time, status == 1) ~ trt,
         "mod2" = Surv(time, status == 1) ~ .)
formatArguments(concrete.args)

Run the code above in your browser using DataLab