# The zip file contains the WinBUGS code to fit the shared parameter model to the HERS data and the R code to perform G-computation in the sensitivity analysis for the HERS data analysis. # 1. SPM_model.txt: The WinBUGS model file to fit the SPM to the HERS data # 2. postsample.Rdata: posterior samples of model parameters for the SPM fitted to the HERS data; to be used in G-computation. # 3. EV_skewednormaldist.R: R function to calculate the mean and Variance for a multivariate skewed normal disrtribution # 4. G-computation.R: R functions to perform the G-computation (using approxmiations and exact values of the posterior variance of random slopes). # 5. summary-G-computation.R: R code to summarize the G-computation results for sensitivity analysisd[i],1]+randombi[numsubjid[i],2]*lonx1[i] } ### drop-out process; for(j in 1:M) ### M is the number of subjects; { onesD[j]<-1 ### ones trick; for(kd in 1:numK) { quantD[j,kd]<-phi(lambdaD2[j,kd]) ##### NB: 1-step() to avoid confusion on threshhold; avoid numerical problems in probit lambdaD2[j,kd]<-lambdaD[j,kd]*step(lambdaD[j,kd]+7)*step(7-lambdaD[j,kd])+(-7)*(1-step(lambdaD[j,kd]+7))+7*(1-step(7-lambdaD[j,kd])) ##### survDx1-survDx5: baseline covariates ##### survDvisit: visits ##### survalphaD[1:9]: regression coefficients ##### survgammaD[1:2]: \gamma parameters linking the outcome and dropout processes lambdaD[j,kd]<-(survalphaD[1]+survalphaD[2]*survDx1[j]+survalphaD[3]*survDx2[j]+survalphaD[4]*survDx3[j]+survalphaD[5]*survDx4[j]+survalphaD[6]*survDx5[j]+survalphaD[7]*survDvisit[kd]+survalphaD[8]*pow(survDvisit[kd],2)+survalphaD[9]*survDvisit[kd]*survDx5[j]+survgammaD[1]*randombi[j,1]+survgammaD[2]*randombi[j,2]) } ##### survD: observed dropout time ##### survdeltaD: dropout indicator 1=dropout, 0=completer probD[j]<-(prod(quantD[j,1:survD[j]])*pow((1-quantD[j,survD[j]]),survdeltaD[j])/pow(quantD[j,(survD[j])],survdeltaD[j]))*survdeltaD[j]+(1-survdeltaD[j])*prod(quantD[j,1:11]) onesD[j]~dbern(probD[j]) #### random effects; randombi[j,1]~dnorm(0,taub1) ## random intercept; randombi[j,2]<-theta12*randombi[j,1]+e2[j] ## random slope: var(b2)=theta21^2*var(b1)+var(e2) e2[j]~dnorm(0,taub2) } ##################################### ### prior; ### lonalphaP: number of fixed effects in longitudinal model; for(p1 in 1:lonalphaP) {lonalpha[p1]~dnorm(0,1.0E-2)} ### survalphaDP= number of regression coefficients in the dropout model ; for(p2 in 1:survalphaDP) {survalphaD[p2]~dnorm(0,0.25)} ### survgammaDP: number of gamma parameters; for(p3 in 1:survgammaDP) {survgammaD[p3]~dnorm(0,0.25)} ###### variance parameters for random effects; taub1<-1/(sigmab11*sigmab11) taub2<-1/(sigmab22*sigmab22) sigmab11~dunif(0,5) sigmab22~dunif(0,5) theta12~dnorm(0,1.0E-2) ###### error variance tauepsilon~dgamma(0.001,0.001) sigma2epsilon<-1/tauepsilon sigma2b11<-1/taub1 ## variance of random intercepts sigma2b22<-sigma2b11*pow(theta12,2)+1/taub2 ### variance of random slopes sigma2b12<-theta12*sigma2b11 #### covariance rho12<-theta12*sqrt(sigma2b11)/sqrt(sigma2b22) #### correlation; }