BookmarkSubscribeRSS Feed
pronabesh
Fluorite | Level 6

Hi SAS Users,

I am trying to do a multilevel mediation analysis using a 2x4 RCT design, where there are 2 conditions (control vs. experimental) and 4 time points (baseline, 1 month, 3 month and 6 month). A cut of the person-time dataset is shown below.

ObsIdnumcondtimeMediatorOutcome
1200011, control0 Baseline406.75
2200011, control1 month386.75
3200011, control3 month387.75
4200011, control6 month205.50
5200051, control0 Baseline63.25
6200051, control1 month42.25
7200051, control3 month22.50
8200051, control6 month121.75
9200061, control0 Baseline126.00
10200061, control1 month146.00
11200061, control3 month126.50
12200061, control6 month125.25
13200071, control0 Baseline107.75
14200071, control1 month87.00
15200071, control3 month27.00
16200071, control6 month67.50
17200082, experimental0 Baseline345.00
18200082, experimental1 month407.50
19200082, experimental3 month385.25
20200082, experimental6 month404.25
21200091, control0 Baseline123.75
22200091, control1 month23.25
23200091, control3 month204.75
24200091, control6 month204.00
25200102, experimental0 Baseline206.25

26

200102, experimental1 month205.75
27200102, experimental3 month182.25
28200102, experimental6 month104.75

The intervention cond id coded as 0 and 1; putative mediator and outcome were  measured at baseline and all follow ups.

Is there a way to evaluate mediation effects using this longitudinal data set with time varying measures?

If so, what is the best way of measuring the direct and indirect effects?

I used a random residual statement to account for within subject correlation, but the issue is that this solution of fixed effects is the marginal means. I need to evaluate the temporal effects as well, i.e., intervention -> mediates the intermediary putative mediator between 1 and 3 month -> changes outcome at 6 month.

This may be complicated but any help is much appreciated!

10 REPLIES 10
SteveDenham
Jade | Level 19

Can you share the GLIMMIX/GENMOD code that you are currently using?  At least for me, it is easier to adapt what you already have in hand, rather than starting from square one.  The mediator variable intrigues me--it is a response variable, but is also a covariate of sorts.  There might be a way to use PROC PHREG, since it is set up for time-dependent covariates, but we are rapidly moving towards the edge of my experience.

Steve Denham

pronabesh
Fluorite | Level 6

Steve,

The code I am tying to test is below. Also there is a correction in the post, the condition is codes 1 and 2 not 0 and 1.


/*-----------------------------------------------------*/
/* Mediation model 1                          */
/* Intervention on Outcome                 */
/*-----------------------------------------------------*/

proc glimmix data=work;
    class idnum cond time;
    model outcome = cond time cond*time / s;
    random time/ subject=idnum type=un residual;

     lsmeans cond*time;
run;

/*-----------------------------------------------------*/
/* Mediation model 2                          */
/* Intervention on Mediator                  */
/*-----------------------------------------------------*/

proc glimmix data=work;
    class idnum cond time;
    model mediator = cond time cond*time / s;
    random time/ subject=idnum type=un residual;

     lsmeans cond*time;
run;

/*-----------------------------------------------------*/
/* Mediation model 3                         */
/* Intervention and Mediator on Outcome*/
/*-----------------------------------------------------*/

proc glimmix data=work;
    class idnum cond time;
    model outcome = cond time cond*time mediator mediator*time / s;
    random time/ subject=idnum type=un residual;

     lsmeans cond*time;

     lsmeans mediator*time;
run;

I have added the interaction terms with time to test the time dependent fixed effects.

Here is the scenario: lets assume that the intervention changes the mediator at 3 months which then mediates a change in the outcome at 6 months. If I set the reference category to baseline, it is possible to test the fixed effects for these changes: (1) cond*time (where cond=experimental and time=6 month in Model 1); (2) cond*time (where cond=experimental and time=3 month in Model 2) and (3) mediator*time in Model 3.

However, it is complicated to get the direct and indirect effects from this.

SteveDenham
Jade | Level 19

Parts 1 and 2 certainly make sense to me.  In model 3, however, we run into the problem that mediator is a continuous covariate.  Consequently, I would attack things just a bit differently.

First, since we are in GLIMMIX, I would use type=chol for the Cholesky root of the unstructured matrix--guarantees positive semidefinite G matrix.

Second, I would have the second lsmeans statement with multiple AT mediator= values, if the time by mediator interaction is significant:

lsmeans time/AT mediator=mean;

lsmeans time/AT mediator=<lowest value observed>;

lsmeans time/AT mediator=<highest value observed>;

If the time by mediator interaction is not significant, well, then I would seriously consider dropping it from the model, as now the slopes are parallel, so comparisons will not depend on the values that mediator takes on.

Steve Denham

pronabesh
Fluorite | Level 6

Thank You Steve! Is there any way to get the direct and indirect effects? Otherwise, I might just have to report the betas and p-values. 

SteveDenham
Jade | Level 19

Look at the solution vector (the betas).  Which do you consider direct?  I would say condition and time and their interaction.  To get the indirect effect, look at the change in these betas when mediator is added in (this includes all mediator and mediator interaction terms).  If this is missing your point entirely, then I think you may need to work this through a structural equation model approach (PROC CALIS for example, or PROC MODEL in SAS/ETS) that specifies direct and indirect effects more specifically.

Steve Denham

pronabesh
Fluorite | Level 6

Hello Steve,

Sorry for not following up on this earlier.

I took your suggestion and tried two methods: (1) using a person time data set and modeled the time, cond and mediator interaction using GLIMMIX. I used a random residual statement to account for within subject correlation (code shown below).

/*-----------------------------------------------------*/

/* Mediation model 1                          */

/* Intervention on Outcome                 */

/*-----------------------------------------------------*/

proc glimmix data=work;

  class idnum cond time;

    model &outcome = cond|time/s;

    random time/ subject=idnum type=chol residual;

    lsmeans cond*time;

run;

/*-----------------------------------------------------*/

/* Mediation model 2                          */

/* Intervention on Mediator                  */

/*-----------------------------------------------------*/

proc glimmix data=work;

  class idnum cond time;

    model &med = cond|time / s;

    random time/ subject=idnum type=chol residual;

    lsmeans cond*time;

run;

/*-----------------------------------------------------*/

/* Mediation model 3                          */

/* Intervention and Mediator on Outcome*/

/*-----------------------------------------------------*/

proc glimmix data=work;

  class idnum cond time;

    model &outcome = cond|time|&med / s;

    random time/ subject=idnum type=chol residual;

    lsmeans cond*time;

    lsmeans time/AT &med=12.9236111 /*mean*/;

    lsmeans time/AT &med=12 /*median*/;

run;

pronabesh
Fluorite | Level 6

The solution of fixed effects and type II test of fixed effects from the final model (Model 3) is shown below. The reference was set as baseline and  DASS_anxiety is the mediator.

Solutions for Fixed Effects
EffectConditiontimeEstimateStandard ErrorDFt ValuePr > |t|
Intercept 4.96220.12166741.01<.0001
cond1, control -0.0570.1681667-0.340.7347
cond2, experimental 0....
time 1 month-0.50480.10921691-4.62<.0001
time 3 month-0.60540.1271691-4.77<.0001
time 6 month-0.84720.13571691-6.24<.0001
time Baseline (reference group)0....
cond*time1, control1 month0.29160.150116911.940.0522
cond*time1, control3 month0.16610.175416910.950.3437
cond*time1, control6 month0.50230.185716912.710.0069
cond*time1, controlBaseline (reference group)0....
cond*time2, experimental1 month0....
cond*time2, experimental3 month0....
cond*time2, experimental6 month0....
cond*time2, experimentalBaseline (reference group)0....
DASS_ANXIETY 0.035090.00823316914.26<.0001
DASS_ANXIETY*cond1, control 0.01770.0117216911.510.131
DASS_ANXIETY*cond2, experimental 0....
DASS_ANXIETY*time 1 month0.016970.00949816911.790.0741
DASS_ANXIETY*time 3 month0.019060.0115916911.640.1004
DASS_ANXIETY*time 6 month0.026870.0127416912.110.0352
DASS_ANXIETY*time Baseline (reference group)0....
DASS_ANXIE*cond*time1, control1 month-0.013770.012971691-1.060.2886
DASS_ANXIE*cond*time1, control3 month-0.010290.015911691-0.650.5178
DASS_ANXIE*cond*time1, control6 month-0.020230.016751691-1.210.2274
DASS_ANXIE*cond*time1, controlBaseline (reference group)0....
DASS_ANXIE*cond*time2, experimental1 month0....
DASS_ANXIE*cond*time2, experimental3 month0....
DASS_ANXIE*cond*time2, experimental6 month0....
DASS_ANXIE*cond*time2, experimentalBaseline (reference group)0....
Type III Tests of Fixed Effects
EffectNum DFDen DFF ValuePr > F
cond16671.570.2105
time3169117.53<.0001
cond*time316912.890.0344
DASS_ANXIETY11691134.49<.0001
DASS_ANXIETY*cond116910.50.4776
DASS_ANXIETY*time316911.730.1581
DASS_ANXIE*cond*time316910.620.6036

Based on my understanding, if the type II tests of fixed effects for mediator*time is significant then mediation is present. The solution vectors are shown in solution for fixed effects, but for the life of me I can not figure out how best to present this finding or figure out a way to find direct/indirect effects.

SteveDenham
Jade | Level 19

The F tests for mediator*time and mediator*condition*time are not significant, but the mediator "main effect" (which is really an intercept measure) is significant.

OK.  I am walking out on a very thin limb here, and my interpretation may not fit your field.  I would say that  I see two populations, defined by the level of dass_anxiety, and the responses over time being essentially identical for those two.  There seems to be an indication that the time course differs somewhat by condition as well.  So, in a guess as to what is going on--direct effects are time and dass_anxiety, and condition an indirect effect on the time course of the response.  Plots over time should make this apparent.

Steve Denham

pronabesh
Fluorite | Level 6

Thanks for the suggestion Steve. I will try to look at the plots for interpretation. I also tried specifying line equations in proc CALIS (code shown below) which gives direct and indirect effects at each time point. The only issue is that I am not sure if I should specify a line equation for baseline as there should be no mediation at baseline in any case. However, that means baseline will be excluded from the error matrix.

ods html;

proc calis cov data=work_wide g4=1000 gconv=1e-10 all technique=levmar;

/*------------------------*/

LINEQS

outcome1_month = b1 cond + c1 mediator1_month + e11,

mediator1_month = a1 cond + e21,

outcome3_month = b2 cond + c2 mediator3_month + e12,

mediator3_month = a2 cond + e22,

outcome6_month = b3 cond + c3 mediator6_month + e13,

mediator6_month = a3 cond + e23

;

STD

cond=vartrt,

e11 = var11,

e21 = var21,

e12 = var12,

e22 = var22,

e13 = var13,

e23 = var23

;

COV

e11 e12 e13= COV1,

e21 e22 e23= COV2

;

run;

SteveDenham
Jade | Level 19

This is a case of statistics as art.  I would fit it both ways, and hopefully find that the estimated values for mediation at baseline are zero.

And if they are NOT zero or nearly so, then I begin to wonder about "pathologies" in the data I am trying to model.

Steve Denham

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 3804 views
  • 0 likes
  • 2 in conversation