Hello all,
I would like to have a good interpret for the credible interval for one treatment group in the clinical trial, what does that mean? and how I can compute that for different sample sizes with rstanarm package.
I simulated the event and treatment variables then I applied stan_glm with different prior. Does this true?
Thanks in advance
pi = 0.2 # event rate
n= c(30, 50, 100)
j=1
event = rep(1, n[j])
n0 = round(n[j]*pi,0)
event[sample(n[j],n0)] = 0
mydata= data.frame(event = event, trt= rep(1, length(event
)))
glm_prior <- normal(location = 0, scale = 0.2, autoscale = FALSE )
model.or <- stan_glm(event~trt, data = mydata,
family = "binomial",
prior = glm_prior,
prior_intercept = NULL,
#prior_aux = prior_aux,
QR=FALSE,
mean_PPD = FALSE,
seed = 123450,
chains=10,
#iter= 500,
#cores=ncores,
refresh = 0)
post = as.data.frame(model.or)
post = apply(post, 2, function(x) exp(x))
ci.beta.l = round(apply(post, 2, function(x) quantile(x, 0.025) ), 2)
ci.beta.u = round(apply(post, 2, function(x) quantile(x, 0.975) ), 2)
CI = cat("(", ci.beta.l, ",",ci.beta.u, ")" )