This is an extension of the difference in difference analysis for longitudinal binary data discussed in this note. With the MONTH variable as a continuous predictor, one way to estimate the slopes is to compute average marginal effects within the pre- and post-intervention periods. This can be done with the Margins macro, which is also illustrated in the above note for difference in difference analysis. These statements fit a GEE model allowing for repeated binary measures on each ID and plot the fitted values on the mean (probability) scale and on the link (log odds) scale.
proc gee data=mydata;
class id iv;
model y(event="1") = iv|month / dist=bin;
repeated subject=id;
effectplot slicefit(x=month sliceby=iv);
effectplot slicefit(x=month sliceby=iv)/link;
run;
The Margins macro can also fit the model and request estimates of the mean (event probability) at each month.
%margins(data=mydata, class=id iv, response=y, roptions=event="1",
model=iv|month, dist=binomial,
geesubject=id, margins=month iv)
You can also use the Margins macro to compute the slope in each period as the average marginal effect over the months in the period.
%margins(data=mydata, class=id iv, response=y, roptions=event="1",
model=iv|month, dist=binomial,
geesubject=id, effect=month, within=iv=0)
%margins(data=mydata, class=id iv, response=y, roptions=event="1",
model=iv|month, dist=binomial,
geesubject=id, effect=month, within=iv=1)
If "PRE/POST GAP" means that you want to estimate the change over the two months immediately on either side of the intervention, then this can be done by estimating a contrast on the monthly margins. This code assumes there are 6 months with intervention between months 3 and 4.
data c;
length label f $32767;
infile datalines delimiter='|';
input label f;
datalines;
gap: month4-month3 | 0 0 -1 1 0 0
;
%margins(data=mydata, class=id iv, response=y, roptions=event="1",
model=iv|month, dist=binomial,
geesubject=id,
margins=iv month, contrasts=c)
... View more