dynamic {gfoRmulaICE}R Documentation

Dynamic

Description

This function specifies a dynamic intervention on the treatment variable specified in data. This function follows the treatment strategy specified in strategy_before until a user-defined condition that depends on covariate values is met. Upon the condition is met, the strategy specified in strategy_after is followed.

Usage

dynamic(
  condition,
  strategy_before,
  strategy_after,
  absorb = FALSE,
  id,
  time,
  data
)

Arguments

condition

a string that specifies a logical expression, upon which is met, the strategy specified in strategy_after is followed.

strategy_before

a function or vector of intervened values that specifies the strategy followed after condition is met. The vector of intervened values should be the same length as the number of rows in the data frame data.

strategy_after

a function or vector of intervened values that specifies the strategy followed before condition is met. The vector of intervened values should be the same length as the number of rows in the data frame data.

absorb

a logical value indicating whether the strategy specified in strategy_after becomes absorbing (always treat with the specified strategy) upon the first time when condition is met.

id

a string specifying the ID variable name in data.

time

a string specifying the time variable name in data.

data

a data frame containing the observed data.

Value

a vector containing the intervened value of the same size as the number of rows in data.

Examples

data <- gfoRmulaICE::compData
# Dynamic intervention example 1: 
# treat when L1 = 0, and not treat otherwise.
dynamic1 <- dynamic(
condition = "L1 == 0", 
strategy_before = static(0, data), 
strategy_after = static(1, data), 
absorb = FALSE, 
id = "id", 
time = "t0", 
data = data
)

# Dynamic intervention example 2: 
# never treat upon until L1 = 0, after which follows always treat.
dynamic2 <- dynamic(
condition = "L1 == 0", 
strategy_before = static(0, data), 
strategy_after = static(1, data), 
absorb = TRUE, 
id = "id", 
time = "t0", 
data = data
)

# Dynamic intervention example 3: 
# never treat upon until L1 = 0, after which follows natural course.
dynamic3 <- dynamic(
condition = "L1 == 0", 
strategy_before = static(0, data), 
strategy_after = natural_course(data, "A1"), 
absorb = FALSE, 
id = "id", 
time = "t0", 
data = data
)

[Package gfoRmulaICE version 0.1.0 Index]