0

I have use some binomial count data and have run stan_glm using the default prior. I'm interested in getting the odds ratio (OR) and 95% credible intervals. This works well with the default vague priors.

library(rstan) 
library(rstanarm)
library(bayesplot)
library(tidyverse)

# drug A (grp2=0) had 10 good outcomes among 62 patients 
# drug B (grp2=1)had 14 good outcomes among 70 patients 
data_bin2 <- data.frame(N = c(62,70), y = c(10,14), grp2 = c(0,1))

fit_bin <- stan_glm(y/N ~ grp2, family = binomial(), data = data_bin2,
                weights = N, seed = 123, refresh = 0)
monitor(fit_bin$stanfit)
prior_summary(fit_bin) #show the default priors which seem to be log based

draws_bin <- as.data.frame(fit_bin) %>%
  mutate(theta1 = plogis(`(Intercept)`),
         theta2 = plogis(`(Intercept)` + grp2),
         oddsratio = (theta2/(1-theta2))/(theta1/(1-theta1)))
mcmc_hist(draws_bin, pars='oddsratio', binwidth = .01)

mcmc_median <- median(draws_bin$oddsratio)
mcmc_ci95 <- round(posterior_interval(as.matrix(draws_bin), prob = 0.95, pars = "oddsratio"),2)

But I would also like to use the following data from a previous study as informative priors -

drug A had 1 good outcomes among 15 patients drug B had 6 good outcomes among 14 patients and here I'm uncertain how to proceed.

Presumably I use the arguments prior_intercept = and prior = but does the prior_intercept require only the drug A data (grp2=0) and prior only uses drug B data (grp2=1)? Or do I assign the prior OR to the prior_intercept function? Also most commonly I have seen prior_intercept = normal(mean, scale). I can use the normal approximation to this binomial data but with small sample sizes this seems unsatisfactory. I don't think a binomial () exists in rstanarm. Also are the mean and scale log transformed before being used by these functions? Any help on precisely showing how to incorporate this prior binomial information would be much appreciated.

0 Answers0