#JAGS Code to fit our covariate adjusted model write("data{ ## Data Construction for the Historical Likelihood ## for (i0 in 1:n0) { for (k in 1:K) { # indicates event-time in interval k zed0[i0,k] <- delta0[i0]*step(y0[i0] - kappa[k] - 0.00001)*step(kappa[k+1] - y0[i0]); # length of overlap of y0[i0] with interval k theta0[i0,k] <- (min(y0[i0], kappa[k+1]) - kappa[k])*step(y0[i0] - kappa[k]); } } ## Data Construction for the Current Likelihood ## for (i in 1:n) { for (k in 1:K) { # indicates event-time in interval k zed[i,k] <- delta[i]*step(y[i] - kappa[k] - 0.00001)*step(kappa[k+1] - y[i]); # length of overlap of y[i] with interval k theta[i,k] <- (min(y[i], kappa[k+1]) - kappa[k])*step(y[i] - kappa[k]); } } } model{ ## Historical Likelihoods ## for (i0 in 1:n0) { for (k in 1:K) { # define the likelihood mu0[i0,k] <- theta0[i0,k]*exp(alpha0[k]+inprod(beta0[],X0[i0,])) zed0[i0,k] ~ dpois(mu0[i0,k]); } } ## Current Likelihoods ## for (i in 1:n) { for (k in 1:K) { # define the likelihood #Use for gamma constant over time mu[i,k] <- theta[i,k]*exp(alpha[k]+inprod(beta[],X[i,])+inprod(gamma[],Z[i,])) #Use for time-dependent gamma #mu[i,k] <- theta[i,k]*exp(alpha[k]+inprod(beta[],X[i,])+inprod(gamma[k,],Z[i,])) zed[i,k] ~ dpois(mu[i,k]); } } #Vague Priors for Treatment Effect and Historical Log-Hazards #Commensurate Priors on Current Log-Hazards for (j in 1:p){ beta0[j] ~ dnorm(0,0.0001); beta[j] ~ dnorm(beta0[j],tau[j]); } for (j in 1:q){ #Use for constant gamma gamma[j] ~ dnorm(0,0.0001) #Use for time-dependent gamma #gamma[1,j] ~ dnorm(0,0.0001) xi[j] <- 1/(sigmaX[j]*sigmaX[j]); sigmaX[j] ~ dunif(0.01,100); } alpha0[1] ~ dnorm(0,0.0001); alpha[1] ~ dnorm(alpha0[1], tau[p+1]); v <- tau[p+1]/spike[2]; for (k in 2:K) { alpha0[k] ~ dnorm(alpha0[k-1], eta0); alpha[k] ~ dnorm(v*alpha0[k]+(1-v)*alpha[k-1], v*tau[p+1] + (1-v)*eta); #Use for time-dependent gamma #for(j in 1:q){ #gamma[k,j] ~ dnorm(gamma[k-1,j],xi[j]) #} } #Spike and Slab on Regression Coefficients for (j in 1:p){ t[j] ~ dbern(p0); slab[j] ~ dunif(l.slab,u.slab); tau[j] <- (1-t[j])*spike[1] + t[j]*slab[j]; } #Spike and Slab on Baseline Hazard t[p+1] ~ dbern(p0); slab[p+1] ~ dunif(l.slab,u.slab); tau[p+1] <- (1-t[p+1])*spike[2] + t[p+1]*slab[p+1]; eta0 <- 1/(sigma0*sigma0); sigma0 ~ dunif(0.01,100); eta <- 1/(sigma*sigma); sigma ~ dunif(0.01,100); }","OurModel.txt")