I read the paper entitled "Recommendations for presenting analyses of effect modification and interaction" published by Knol MJ and VanderWeele TJ Link to download the paper.
I would like to follow their recommendations. I think I get everything to follow their recommendation (1), (2), and (4). However, I do not know how to calculate the measure of effect modification on "additives scale" and "multiplicative scale" using a coxph?
I wrote a simple example.
Can anybody help me out here?
library(survival)
library(Hmisc)
library(papeR)
#########################################################
# loading and preparing data
#########################################################
data(colon)
d <- colon[, Cs(time, status, rx, surg)]
rm(colon)
names(d) <- Cs(time, status, group, modifier)
d$group <- ifelse(d$group == "Obs", 0, 1)
d$group.4.stata <- NA
d$group.4.stata <- ifelse(d$group==0 & d$modifier==0, 0, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==0 & d$modifier==1, 1, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==1 & d$modifier==0, 2, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==1 & d$modifier==1, 3, d$group.4.stata)
d$group.4.stata <- factor(d$group.4.stata, 0:3, c("control + short", "control + long", "intervention + short", "intervention + long"))
#########################################################
# number of patients in each stratum
#########################################################
table(d$group.4.stata)
#########################################################
# Recommendation (1)
# HR for each statum of exposure (control=0 versus intervention=1) and potential effect modifier (time from surgery to registration: 0=short, 1=long)
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group.4.stata, data=d)), digits=3)
#########################################################
# Recommendation (2)
# HR for each statum of exposure (control=0 versus intervention=1) within stata of potential effect modifier (time from surgery to registration: 0=short, 1=long)
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group, data=d[which(d$modifier==0),])), digits=3)
prettify(fit <- summary(coxph(Surv(time, status) ~ group, data=d[which(d$modifier==1),])), digits=3)
#########################################################
# Recommendation (3)
# meassure of effect modification on "additives scale" or "multiplicative scale"?
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group*modifier, data=d)), digits=3) # What kind of measure is this?
# And how can I calculate the other measure?
Update #1
The answer of AdamO works fine Thank you a lot! However, it does not work with a multivariable model adjusted for several covariables. May you please show how one have to adapt your code in this situation?
library(survival)
library(Hmisc)
library(papeR)
library(epiR)
#########################################################
# loading and preparing data
#########################################################
data(colon)
d <- colon[, Cs(time, status, rx, surg, sex, age, node4)]
rm(colon)
names(d) <- Cs(time, status, group, modifier, covariate1, covariate2, covariate3)
d$group <- ifelse(d$group == "Obs", 0, 1)
d$group.4.stata <- NA
d$group.4.stata <- ifelse(d$group==0 & d$modifier==0, 0, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==0 & d$modifier==1, 1, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==1 & d$modifier==0, 2, d$group.4.stata)
d$group.4.stata <- ifelse(d$group==1 & d$modifier==1, 3, d$group.4.stata)
d$group.4.stata <- factor(d$group.4.stata, 0:3, c("control + short", "control + long", "intervention + short", "intervention + long"))
#########################################################
# number of patients in each stratum
#########################################################
table(d$group.4.stata)
#########################################################
# HR for each statum of exposure (control=0 versus intervention=1) and potential effect modifier (time from surgery to registration: 0=short, 1=long)
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group.4.stata+covariate1+covariate2+covariate3, data=d)), digits=3)
#########################################################
# HR for each statum of exposure (control=0 versus intervention=1) within stata of potential effect modifier (time from surgery to registration: 0=short, 1=long)
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group+covariate1+covariate2+covariate3, data=d[which(d$modifier==0),])), digits=3)
prettify(fit <- summary(coxph(Surv(time, status) ~ group+covariate1+covariate2+covariate3, data=d[which(d$modifier==1),])), digits=3)
#########################################################
# meassure of effect modification on "additives scale" or "multiplicative scale"?
#########################################################
prettify(fit <- summary(coxph(Surv(time, status) ~ group*modifier+covariate1+covariate2+covariate3, data=d)), digits=3) # What kind of measure is this?
# And how can I calculate the other measure?
#########################################################
# calculating RERI
#########################################################
f <- function(parms) exp(sum(parms)) - exp(parms[1]) - exp(parms[2]) + 1
df <- function(parms) c( ## derivative of RERI for use in delta-method
exp(sum(parms)) - exp(parms[1]), ## or use bootstrap
exp(sum(parms)) - exp(parms[2]),
exp(sum(parms))
)
fit <- coxph(Surv(time, status) ~ group*modifier+covariate1+covariate2+covariate3, data=d)
parms <- coef(fit)
reri <- f(parms)
v.reri <- t(df(parms)) %*% vcov(fit) %*% matrix(df(parms))
## RERI and 95% CI
reri + c(0,-1,1)*1.96*c(sqrt(v.reri))