# Longitudinal model over time # Exponential time-course function # Random treatment effects model{ # Begin Model Code for(i in 1:NS){ # Run Through all NS trials mu[i] ~ dnorm(0,0.0001) delta[i,1] <- 0 # Prior on baseline nuisance parameter lambda0[i] <- exp(loglambda0[i]) loglambda0[i] ~ dnorm(0,0.0001) w[i,1] <- 0 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] <- lambda0[i] * exp(lambda1[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 } lambda1[i,k] <- mu[i] + delta[i,k] # Relative effects for time-course parameters resarmdev[i,k] <- sum(resdev[i,k,1:fups[i]]) armdev[i,k] <- sum(dev[i,k,1:fups[i]]) } resstudydev[i] <- sum(resarmdev[i, 1:narm[i]]) studydev[i] <- sum(armdev[i, 1:narm[i]]) for(k in 2:narm[i]){ # Random effects delta[i,k] ~ dnorm(md[i,k], taud[i,k]) md[i,k] <- d[treat[i,k]] - d[treat[i,1]] + sw[i,k] # Consistency equation # Multi-arm correction taud[i,k] <- tau * 2*(k-1)/k w[i,k] <- (delta[i,k] - d[treat[i,k]] + d[treat[i,1]]) sw[i,k] <- sum(w[i,1:(k-1)])/(k-1) } } d[1] <- 0 for (k in 2:NT){ d[k] ~ dnorm(0,0.0001) # Priors on relative treatment effects } totresdev <- sum(resstudydev[]) totdev <- sum(studydev[]) # Prior on between-study SD sd ~ dunif(0,10) tau <- pow(sd, -2) # Model ends }