tmle_prob: Compute TMLE of survival probability with efficiency gains

View source: R/funs_prob.R

tmle_probR Documentation

Compute TMLE of survival probability with efficiency gains

Description

Compute TMLE of survival probability with efficiency gains

Usage

tmle_prob(data, tau)

Arguments

data

A long form data frame (e.g., the output of transformData*())

tau

A time of interest

Value

Survival estimate for each treatment arm with influence function based standard error for the difference

Examples

library(survival)
library(tidyverse)
library(dummies)

data <- colon %>% dummy.data.frame(c('differ', 'extent')) %>%
  filter(rx != 'Obs') %>%
  mutate(A = rx == 'Lev+5FU', id = as.numeric(as.factor(id)),
         nanodes = is.na(nodes), nodes = ifelse(is.na(nodes), 0, nodes)) %>%
  select(-rx) %>%  group_by(id) %>% summarise_all(funs(min)) %>% select(-study) %>%
  rename(T = time, D = status)

dlong <- transformData(data, 30)

fitL <- glm(Lm ~ A * (m + sex + age + obstruct + perfor + adhere + nodes + D +
                        differ1 + differ2 + differ3 + differNA + extent1 + extent2 +
                        extent3 + extent4 + surg + node4 + etype),
            data = dlong, subset = Im == 1, family = binomial())
fitR <- glm(Rm ~ A * (as.factor(m) + sex + age + obstruct + perfor + adhere + nodes + D +
                        differ1 + differ2 + differ3 + differNA + extent1 + extent2 +
                        extent3 + extent4 + surg + node4 + etype),
            data = dlong, subset = Jm == 1, family = binomial())
fitA <- glm(A ~ sex + age + obstruct + perfor + adhere + nodes + D +
              differ1 + differ2 + differ3 + differNA + extent1 + extent2 +
              extent3 + extent4 + surg + node4 + etype,
            data = dlong, subset = m == 1, family = binomial())

dlong <- mutate(dlong,
                gR1 = bound01(predict(fitR, newdata = mutate(dlong, A = 1), type = 'response')),
                gR0 = bound01(predict(fitR, newdata = mutate(dlong, A = 0), type = 'response')),
                h1 = bound01(predict(fitL, newdata = mutate(dlong, A = 1), type = 'response')),
                h0 = bound01(predict(fitL, newdata = mutate(dlong, A = 0), type = 'response')),
                gA1 = bound01(predict(fitA, newdata = mutate(dlong, A = 1), type = 'response')))

tau <- max(dlong$m)

tmle_prob(dlong, tau)

idiazst/survtmlerct documentation built on Aug. 28, 2023, 10:13 a.m.