if (FALSE) {
# Example with data from Riksstroke (the Swedish stroke register)
data(RSdata)
# Probit mediator and outcome models:
med.model <- glm(lowered.consc ~ AF + age.cat + sex, data = RSdata,
family = binomial(link = 'probit'))
out.model <- glm(cf.3mo ~ AF + lowered.consc + age.cat + sex, data = RSdata,
family = binomial(link = 'probit'))
# First we estimate marginal NIE, NDE with sensitivity analyses to mediator-outcome
# confounding:
sensmed <- sensmediation(med.model, out.model, exp.name = "AF1", med.name = "lowered.consc",
Rho = seq(0, 0.5, 0.1))
# Then we also estimate NIE, NDE conditional on male sex without reestimating the regression
# coefficients:
sensmed.cond <- more.effects(sensmed.object = sensmed, covariates = list(sex = 1))
summary(sensmed.cond)
plot(sensmed.cond)
}
Run the code above in your browser using DataLab