Created
February 18, 2013 16:05
-
-
Save gertvv/4978453 to your computer and use it in GitHub Desktop.
Convert GeMTC posterior samples for the log odds-ratio to samples for the log risk-ratio using an assumed baseline probability. The baseline could also be a vector of samples from a distribution for the baseline probability. For the given example probability (p = 0.3), the LRR and LOR differ substantially. For p = 0.01 they are nearly identical.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network <- ... # wherever your network comes from | |
model <- mtc.model(network) | |
result <- mtc.run(model) | |
result <- relative.effect(result, t1="A") # make sure everything is relative to the same reference | |
# transform the LOR to the LRR using an assumed probability for the reference treatment A | |
lor.to.lrr <- function(lor, p.A) { | |
lo.A <- log(p.A / (1 - p.A)) | |
lo.B <- lo.A + lor # absolute log-odds of B | |
p.B <- exp(lo.B) / (1 + exp(lo.B)) # inverse logit: absolute probability of B | |
log(p.B / p.A) # the log-RR | |
} | |
p <- 0.3 # assume a 30% probability of treatment response with A | |
# Calculate the log-RR | |
lrr.samples <- as.mcmc.list(lapply(result$samples, function(chain) { | |
cols <- grep("^d\\.", colnames(chain)) # find the "difference (d.X.Y)" parameters | |
chain[, cols] <- lor.to.lrr(chain[, cols], p) | |
as.mcmc(chain) | |
})) | |
summary(lrr.samples) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment