vcov.mat[1:6 ,1:6 ] <-inverse(R[ 1:6, 1:6 ]) # priors for coefficients: vague normal:
for (j in 1:6) { betacon.time[j]~dnorm(0.0,1.0E-6) betacon.treat[j]~dnorm(0.0,1.0E-6) betacon.base[j]~dnorm(0.0,1.0E-6) } }
Second, joint model for response and withdrawal, under Model 1 - all misssing data treated as interim missing. model {
for (i in 1: npatients) { # 751 patients which we index by i # Model of for the 6 post randomisation FEV measurments is # multivariate normal
fev[i, 1:6] ~ dmnorm(mu[i, ], R[ , ] )
# Parameterise mean with full treatment time and # baseline time interaction
for (j in 1:6) {
mu[i,j]<- betacon.time[j] + betacon.treat[j]*treat[i] + betacon.base[j]*base[i]
} }
# Model for observing the response for(j in 2:6) {
resp[i,j] ~ dbin(p[i,j],1) # Response is 1 (yes) or #0 (no) on each occasion
# linear predictor depends on visit, treatment, previous reading # and the difference between the previous and current reading
logit(p[i,j]) <- alpha[j] + betadrop*treat[i] + gamma*fev[i,j-1] + 0.1*(fev[i,j]-fev[i,j-1])
# last term is log odds ratio of difference # which is fixed at 0.1
# Wishart prior for precision matrix R
R[1:6 , 1:6] ~ dwish(lambda[1:6 , 1:6 ], 6) # create an estimate of variance/covariance matrix:
vcov.mat[1:6 ,1:6 ] <-inverse(R[ 1:6, 1:6 ]) # priors for coefficients: vague normal:
for (j in 1:6) { betacon.time[j]~dnorm(0.0,1.0E-6) betacon.treat[j]~dnorm(0.0,1.0E-6) betacon.base[j]~dnorm(0.0,1.0E-6) alpha[j]~dnorm(0.0,1.0E-6) } betadrop~dnorm(0.0,1.0E-6) gamma~dnorm(0.0,1.0E-6) }
Third, model 2 for non-response: after a patient withdraws, they do not return.
model {
for (i in 1: npatients) { # 751 patients which we index by i # Model of for the 6 post randomisation FEV measurments is # multivariate normal
fev[i, 1:6] ~ dmnorm(mu[i, ], R[ , ] )
# Parameterise mean with full treatment time and # baseline time interaction
for (j in 1:6) {
mu[i,j]<- betacon.time[j] + betacon.treat[j]*treat[i] + betacon.base[j]*base[i]
} }
C.4 Code for Chapter6 173 # Model for observing the response
for (j in 2:lvisit[i]) { # variable lvisit is time of # list visit (2...6)
resp[i,j] ~ dbin(p[i,j],1) # Response is 1 (yes) till # withdrawal, then 0
# linear predictor depends on visit, treatment, # previous reading and the difference between the # previous and current reading
logit(p[i,j]) <- alpha[j] + betadrop*treat[i] + gamma*fev[i,j-1] + 0.1*(fev[i,j]-fev[i,j-1])
# last term is log odds ratio of difference # which is fixed at 0.1
}
# Wishart prior for precision matrix R
R[1:6 , 1:6] ~ dwish(lambda[1:6 , 1:6 ], 6) # create an estimate of variance/covariance matrix:
vcov.mat[1:6 ,1:6 ] <-inverse(R[ 1:6, 1:6 ]) # priors for coefficients: vague normal:
for (j in 1:6) { betacon.time[j]~dnorm(0.0,1.0E-6) betacon.treat[j]~dnorm(0.0,1.0E-6) betacon.base[j]~dnorm(0.0,1.0E-6) alpha[j]~dnorm(0.0,1.0E-6) } betadrop~dnorm(0.0,1.0E-6) gamma~dnorm(0.0,1.0E-6) } Example6.1
Example6.3
* First the SAS macro for adapting the imputations: * Author: Prof James H. Roger, [email protected] /*
Macro name: Modify Parameters;
Data= Name of original data set
Imp= Name of imputed data set
Out= Name of Output data set
Var= List of variables as used in Var statement for MI Delta= The amount to decrease imputed value by
S= SD for Normal distribution from which Change is sampled with mean Delta for each imputation
Trx= Name of variable holding treatment classification */
%macro modify(data= ,imp= ,out= ,var= ,delta= ,s= ,trx= ); %local i n;
%* Get number of elements in the Var List as macro variable n; %let i=1;
%let txt=%scan(&var, &i, %str( )); %do %while(%length(&txt)) ;
%let i=%eval(&i +1);
%let txt=%scan(&var, &i, %str( )); %end;
%let n=%eval(&i -1);
* Delete data sets before we use them; Proc datasets library=work;
delete Temp1 Temp2 Temp3; quit;
* Set up data set with indicator of whether data is missing; * This gets around issue of variables having same names in * original and imputed data sets;
* Add Row number so we can merge this with every imputed * data set;
data Temp1;
set &data;
array My_Var[1:&n] &Var;
array My_Ind[1:%eval(&n+1)] My_Ind1-My_Ind&n No; keep My_row My_ind1-My_Ind&n;
My_Row=_N_;
* Note that No is My_Ind[&n+1]; No=0;
C.4 Code for Chapter6 175 do i= &n to 1 by -1;
My_ind[i]= ( ((My_Var[i] > .z) + (My_ind[i+1])) > 0 ); end;
run;
* Add Row number of each record in the imputed data set * within the Imputation number;
data Temp2;
set &imp;
by _imputation_; retain My_Row 0;
if first._imputation_ then My_Row=0; My_Row=My_Row+1;
run;
* Merge the two data sets based on this Row number; proc sql;
create table Temp3 as select A.*, B.*
from Temp2 A left join Temp1 B on A.My_Row = B.My_Row
order by _imputation_, &Trx; quit;
* Now calculate the required changes in imputed values; * My_Ind=1 if data is Real;
* My_Ind=0 if data is Imputed; data &out;
set Temp3;
by _imputation_ &trx; array My_Var[1:&n] &Var;
array My_Ind[1:&n] My_Ind1-My_Ind&n; drop My_Row Change i My_ind1-My_Ind&n; retain delta;
*** Here is where the modfication is done ***; * Change allows us to build up delta
* within the subject;
* Reset Delta for each Imputation * Treatment level; if first.&trx then do;
Delta=&delta+&s*rannor(0); end;
Change=0; do i=1 to &n;
* If it is imputed then increase * Change by delta;
if My_ind[i]=0 then do;
Change=Change + delta; end;
* Do the change;
My_Var[i]=My_Var[i]-Change; end;
run; %mend modify;
* Now we apply it to the example: data two;
infile "...";
input id treat base fev1-fev6; run;
proc sort data=two out=twosort; by treat;
run;
* Multiple imputation
proc mi data =twosort seed=1 out=full nimpute=50; by treat;
MCMC nbiter=5000 niter=5000; var fev1-fev6;
mcmc impute=full; run;
proc sort data=full; by _imputation_ id; run;
* Estimate treatment effect at final time point using each * imputed data set
proc reg data=full outest=outreg covout noprint ; model fev6= base treat;
by _Imputation_; run;
proc mianalyze data=outreg;
modeleffects Intercept base treat; run;
* Now use modify macro (above) and redo analysis
* delta is the mean of the difference in slope after withdrawal, with * standard error s (ctd...)
C.4 Code for Chapter6 177 * For example, to obtain same results as MAR, set delta=0
and s to be tiny:
%modify(data=tensort, imp=full,
out=james, var= fev1 fev2 fev3 fev4 fev5 fev6, delta=0.0, trx=treat, s=0.0000005); proc reg data=james outest=outreg covout noprint ;
model fev6= base treat; by _Imputation_;
run;
proc mianalyze data=outreg;
modeleffects Intercept base treat; run;
References
Aitkin, M., Anderson, D., Francis, B. and Hinde, J. (1989) Statistical modelling in GLIM. Oxford: Oxford University Press.
Allison, P. D. (2000) Multiple imputation for missing data: a cautionary tale. Sociological methods and Research, 28, 301–309.
Barnard, J. and Rubin, D. (1999) Small-sample degrees of freedom with multiple imputation. Biometrika, pp. 948–955.
Brown, D. J. (2003) ICH E9 guideline ‘Statistical principles for clinical trials’: a case study. Response to A. Philips and V Haudiquet. Statistics in Medicine, 22, 13–17.
Burge, P. S., Calverley, P. M. A., Jones, P. W., Spencer, S., Anderson, J. A. and Maslen, T. K. (2000) Randomised, double blind, placebo controlled study of fluticasone pripionate in pa- tients with moderate to severe chronic obstructive pulmonary disease: the isolde trial. British Medical Journal, 320, 1297–1303.
Busse, W. W., Chervinsky, P., Condemi, J., Lumry, W. R., Petty, T. L., Rennard, S. and Townley, R. G. (1998) Budesonide delivered by Turbuhaler is effective in a dose-dependent fashion when used in the treatment of adult patients with chronic asthma. J Allergy Clin Immunol, 101, 457–463.
Callaham, M. L., Wears, R. L. and Waeckerle, J. F. (1998) Effect of attendance at a training session on peer reviewer quality and performance. Annals for Emerging Medicine, 32, 318– 322.
Callaham, M. L., Knopp, R. K. and Gallagher, E. J. (2002) Effect of written feedback by editors on quality of reviews. Journal of the American Medical Association, 287(21), 2781–2783. Carpenter, J., Pocock, S. and Lamm, C. J. (2002) Coping with missing data in clinical trials: a
model based approach applied to asthma trials. Statistics in Medicine, 21, 1043–1066. Carpenter, J., Kenward, M., Evans, S. and White, I. (2004) Letter to the editor: Last observation
carry forward and last observation analysis by J. Shao and B. Zhong, Statistics in Medicine, 2003, 22, 2429–2441. Statistics in Medicine, 23, 3241–3244.
Carpenter, J. R., Kenward, M. G. and Vansteelandt, S. (2006) A comparison of multiple impu- tation and inverse probability weighting for analyses with missing data. Journal of the Royal Statistical Society, Series A (Statistics in Society), 169, 571–584.
Carpenter, R. G. (1983) Scoring to provide risk-related primary health care: Evaluation and up-dating during use. Journal of the Royal Statistical Society, Series A (Statistics in Society), 146, 1–32.