# Longitudinal model over time # Emax time-course function # Random treatment effects for ET50 # Random treatment effects for Emax # Bivariate correlation between ET50 and Emax treatment effects with multi-arm correction model{ # Begin Model Code for (i in 1:NS){ # Run Through all NS trials l.E0[i] ~ dnorm(0,0.0001) # prior for baseline nuisance parameter mu.Emax[i] ~ dnorm(0,0.0001) mu.ET50[i] ~ dnorm(0,0.0001) for (k in 1:narm[i]){ for (m in 1:fups[i]) { # Run through all observations within a study y[i,k,m] ~ dnorm(theta[i,k,m], prec[i,k,m]) # Normal likelihood prec[i,k,m] <- pow(se[i,k,m], -2) theta[i,k,m] <- exp(l.E0[i]) + (Emax[i,k] * time[i,m]) / (exp(l.ET50[i,k]) + time[i,m]) # Time-course function resdev[i,k,m] <- pow((y[i,k,m] - theta[i,k,m]),2) * prec[i,k,m] # residual deviance for normal likelihood dev[i,k,m] <- -2* (log(pow((prec[i,k,m]/(2*3.14159)),0.5) * exp(-0.5*(pow((y[i,k,m]-theta[i,k,m]),2)*prec[i,k,m])))) # deviance for normal likelihood } resarmdev[i,k] <- sum(resdev[i,k,1:fups[i]]) armdev[i,k] <- sum(dev[i,k,1:fups[i]]) } # Reference treatment effects Emax[i,1] <- mu.Emax[i] l.ET50[i,1] <- mu.ET50[i] for (k in 2:narm[i]) { # Relative effects for time-course parameters Emax[i,k] <- mu.Emax[i] + delta[i,(k-1)] l.ET50[i,k] <- mu.ET50[i] + delta[i,((k-1)*2)] # Consistency equations md[i,(k-1)] <- d.Emax[treat[i,k]] - d.Emax[treat[i,1]] md[i,((narm[i]-1)+k-1)] <- d.ET50[treat[i,k]] - d.ET50[treat[i,1]] } resstudydev[i] <- sum(resarmdev[i, 1:narm[i]]) studydev[i] <- sum(armdev[i, 1:narm[i]]) # Generate matrix of relative effects (uses dmnorm.vcov function from JAGS 4.3.0) delta[i,1:((narm[i]-1)*2)] ~ dmnorm.vcov(md[i,1:((narm[i]-1)*2)], cov.mat[i,1:((narm[i]-1)*2),1:((narm[i]-1)*2)]) # Covariance matrix diagonals for (r in 1:(narm[i]-1)) { cov.mat[i,r,r] <- pow(sd.Emax,2) } for (r in (1+(narm[i]-1)):((narm[i]-1)*2)) { cov.mat[i,r,r] <- pow(sd.ET50,2) } } #### Covariance matrix for 2-arm studies for (i in (NS.mult+1):NS) { cov.mat[i,1,2] <- sd.Emax * sd.ET50 * rho # Upper triangle cov.mat[i,2,1] <- cov.mat[i,1,2] # Lower triangle } #### Covariance matrix upper triangle for multi-arm studies for (i in 1:NS.mult) { # Upper triangle - Covariances within outcome between arms (multi-arm correction) for (c in 1:(narm[i]-2)) { for (r in (c+1):(narm[i]-1)) { cov.mat[i,c,r] <- pow(sd.Emax,2) * 0.5 } } for (c in (narm[i]):((2*narm[i])-3)) { for (r in (c+1):((narm[i]-1)*2)) { cov.mat[i,c,r] <- pow(sd.ET50,2) * 0.5 } } # Upper triangle - Covariances between-outcome within-arms for (c in 1:(narm[i]-1)) { cov.mat[i,c,(c+narm[i]-1)] <- 2* rho * sd.Emax * sd.ET50 } # Upper triangle - Covariances between-outcome between-arms for (c in 1:(narm[i]-2)) { for (r in (c+narm[i]):((narm[i]-1)*2)) { cov.mat[i,c,r] <- rho * sd.Emax * sd.ET50 # Top upper diagonal } } for (c in 2:(narm[i]-1)) { for (r in (narm[i]):(narm[i]-2+c)) { cov.mat[i,c,r] <- rho * sd.Emax * sd.ET50 # Bottom upper diagonal } } # Lower triangle for (c in 1:((2*narm[i])-3)) { for (r in (c+1):((narm[i]-1)*2)) { cov.mat[i,r,c] <- cov.mat[i,c,r] } } } d.Emax[1] <- 0 d.ET50[1] <- 0 # Priors on relative treatment effects for (k in 2:NT){ d.Emax[k] ~ dnorm(0,0.001) d.ET50[k] ~ dnorm(0,0.001) } # Priors on between-study SDs sd.Emax ~ dunif(0,2) tau.Emax <- pow(sd.Emax, -2) sd.ET50 ~ dunif(0,2) tau.ET50 <- pow(sd.ET50, -2) # Prior on correlation between Emax and ET50 rho ~ dunif(-1,1) totresdev <- sum(resstudydev[]) totdev <- sum(studydev[]) # Model ends }