# Longitudinal model over time # Piecewise linear time-course function # Fixed treatment effects for beta.1 # Fixed treatment effects for beta.2 # "piece" is a variable that denotes which linear piece a time point belongs to, with values at each time point in each study that takes 1 if the time is before the knot and 2 if located after (calculated outside of JAGS using a predetermined knot) # "knot" is a variable that contains the time point at which the knot between the two linear pieces is located model{ # Begin Model Code for(i in 1:NS){ # Run Through all NS trials mu.1[i] ~ dnorm(0,0.0001) delta.1[i,1] <- 0 mu.2[i] ~ dnorm(0,0.0001) delta.2[i,1] <- 0 alpha.1[i] ~ dnorm(0,0.0001) # prior for baseline nuisance parameter 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] <- (equals(piece[i,m],1) * alpha.1[i]) + (equals(piece[i,m],1) * (beta.1[i,k]*time[i,m])) + (equals(piece[i,m],2) * (alpha.2[i,k])) + (equals(piece[i,m],2) * (beta.2[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 } # Relative effects for time-course parameters beta.1[i,k] <- mu.1[i] + delta.1[i,k] beta.2[i,k] <- mu.2[i] + delta.2[i,k] alpha.2[i,k] <- alpha.2[i] + (beta.2[i,k]*knot) # Intercept for second linear piece 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]]) # Consistency equations for(k in 2:narm[i]){ delta.1[i,k] <- d.1[treat[i,k]] - d.1[treat[i,1]] delta.2[i,k] <- d.2[treat[i,k]] - d.2[treat[i,1]] } } d.1[1] <- 0 d.2[1] <- 0 # Priors on relative treatment effects for (k in 2:NT){ d.1[k] ~ dnorm(0,0.001) d.2[k] ~ dnorm(0,0.001) } totresdev <- sum(resstudydev[]) totdev <- sum(studydev[]) # Model ends }