tmle_prob | R Documentation |
Compute TMLE of survival probability with efficiency gains
tmle_prob(data, tau)
data |
A long form data frame (e.g., the output of transformData*()) |
tau |
A time of interest |
Survival estimate for each treatment arm with influence function based standard error for the difference
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.