The WLW Macro

The WLW macro uses the method of Wei, Lin, and Weissfeld (1989) to produce tests and partial likelihood estimates for multivariate survival data, for example, repeated events. This method produces standard errors and test statistics that correct for possible dependence among the observations. The macro incorporates a SAS/IML program, written by Ying So, that appears in SAS/STAT Software: Changes and Enhancements, Release 6.10. The input data set must have one record for each spell (a time interval from origin to death or censoring). Multiple spells for a single individual must have a common identification number. Additional background is provided in The WLW Method in Chapter 8, “Heterogeneity, Repeated Events, and Other Topics,” which also gives an example of usage. The WLW macro cannot be used with time dependent covariates, although the method could, in principle, be employed with such covariates. The macro will not work with SAS releases earlier than 6.10 because it uses the DFBETA statistics.

Parameters

DV=specifies the two-part dependent variable, in the usual syntax for PROC PHREG.
CV=specifies a list of covariates (the maximum number is 20).
EVCNT=specifies the name of a variable that contains the number of the event in the individual’s sequence.
ID=IDspecifies the name of a variable containing a unique identifier for each individual (either character or numeric).
MAX=specifies the maximum number of events among all individuals. If you don’t wish to analyze the higher order events (because of small subsample sizes), just enter a smaller number for MAX.
DATA=_LAST_specifies the name of data set to be analyzed.
TIES=EFRONspecifies the method for handling ties (BRESLOW, EFRON, EXACT, or DISCRETE).

Program

%macro wlw(dv=,cv=,evcnt=,id=id,max=,data=_last_,ties=efron);

/*Preliminary operations on parameter specifications*/
%do i=l %to 20;
%let var&i=%scan(&cv,&i);
%if &&var&i=%then %goto out;
%if %length(&&var&i) > 6 %then %let vv&i=%substr(&&var&i,1,6);
%else %let vv&i=&&var&i;
%end;
%out: %let i=%eval(&i-1);
%let tot=%eval(&i*&max);
%do j=1 %to &i;
%let vdef&j=arr&j(_i_)=&&var&j*(evcnt=_i_);
%let cvd&j=&&vv&j..1-&&vv&j..&max;
%let ar&j=array arr&j(*) &&vv&j..1-&&vv&j..&max;
%end;

/*Create data set with covariate by time interactions*/
data expand;
ncv=&i;
set &data;
evcnt=&evcnt;
%do j=1 %to &i;
&&ar&j;
%end;
do _i_=1 to &max;
  %do j=1 %to &i;
    &&vdef&j;
  %end;
end;
run;

/*Do PHREG model for all events*/
proc phreg data=expand outest=_a_ noprint;
model &dv=
%do j=1 %to &i;
    &&cvd&j
  %end;
/ties=&ties;
output out=_out1_ dfbeta=dt1-dt&tot/order=data;
id &id;
strata &evcnt;
run;

/*Sum the DFBETA statistics*/
proc sort data=_out1_;
by &id;
run;
proc means data=_out1_ noprint;
by &id;
var dt1-dt&tot;
output out=_out2_(drop=id _type_ _freq_) sum=dt1-dt&tot;

/*Calculate the robust covariance matrix, perform tests*/
proc iml;
names={&cv};
nvar=ncol(names);
use _a_;
read all var _num_ into b;
b=b`;
use _out2_;
read all into x;
do i=1 to nvar;
stop=i*&max;
start=stop-&max+l;
bi=b[start:stop];
xi=x[,start:stop];
v=xi` * xi;
iv=inv(v);
se=sqrt(vecdiag(v));
reset noname;
cname={"Estimate", " Std Error"};
cname2={"Event"};
indx=(1:&max)`;
tmpprt=bi || se;
print / "Results For" (names[i]);
print indx[colname=cname2] tmpprt[colname=cname format=10.5];
print "Estimated Joint Covariance Matrix",, v;

/* H0: All coefficients equal to 0 */
chisq=bi` * iv * bi;
df=nrow(bi);
p=1-probchi(chisq,df) ;
print ,,"Testing H0: no treatment effects for" (names[i]), ,
"Wald Chi-Square = " chisq, "DF = " df,
"p-value = "p[format=5.4],;

/* H0: All coefficients equal to each other */
c=j(df-1,df,0);
do k=1 to df-1;
c[k,k]=1;
c[k,k+1]=-1;
end;
chisq= bi`*c`*inv(c*v*c`)*c * bi;
df=df-1;
p=1-probchi(chisq,df);
print ,,"Testing H0:Equal Coefficients for" (names[i]), ,
"Wald Chi-Square = " chisq, "DF = " df,
"p-value = "p[format=5.4],;

/* Assume coefficients equal. Estimate the common value */
nparm=nrow(bi);
e=j(nparm,1,1);
h=inv(e` * iv * e) * iv * e;
b1=h` * bi;
se=sqrt(h` * v * h);
zscore=b1 / se;
p=1- probchi( zscore * zscore, 1);
print ,,"Estimation of the Common Parameter for" (names[i]),,
"optimal weights = "h,
"Estimate = " b1,
"Standard Error = " se,
"z-score =" zscore,
"2-sided p-value = " p[format=5.4];
end;
quit;
run;

%mend wlw;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.211.92