BookmarkSubscribeRSS Feed
Therese2
Calcite | Level 5

Hi community

 

I'm currently working on research in self-harming behaviour. I have a large longitudinal dataset, and I am investigating the effect of hyperactivity difficulties in the early childhood on the risk of developing self-harming behavior as adolescent. I now want to investigate which possible mediating effects there might be between the two. So I have the following model:

Y = selfharm (binary) 

treatment=hyperactivity in early childhood (scale on 0-20) 
covariates: female (binary), divorced(binary), smoking(binary), peer_dif (scale on 0-10) and mater_menta (continous)
I then have several mediators such as psychiatric disorders, SDQ measures, addiction etc. which I want to test at the same time. 
But 'proc causalmed' can only handle one mediator. I then looked at 'Example 2' in this link: https://support.sas.com/kb/59/081.html
but as far as I can see, this example is without covariates.
So my question is, if there is a way I can do a mediation analysis with multiple mediators and covariates?
I'm using SAS Studio.. 
I have thought of first running a logistic regression, controlling self-harm for the covariates, but not hyperactivity, and then save the residual and use the residuals as my Y. But I'm not sure if that would make any sense.  
 
Thank you for your time,
7 REPLIES 7
SteveDenham
Jade | Level 19

Did you look at Example 2 in the Usage Note https://support.sas.com/kb/59/081.html  ?  That looks like a method is provided for both continuous and categorical effects (whether direct or mediators).  Unfortunately (at least for me), all of the code is done using proc logistic - proc means - proc reg.  To address your research question, you may need even more blocks of these procs to get something that then has to be combined in a DATA step to calculate all needed entities.  

 

Perhaps the References and Resources links at the bottom would provide more illumination than what I came up with.

 

SteveDenham

Therese2
Calcite | Level 5

Hi @SteveDenham

 

Thank you for your reply.

Yes, I've tried the example from the link. Unfortunately, the example does not use covariates, and I can't seem to figure out how or where to fit them into the datasteps in the code provided. I have considered to first run a Proc Logistic with only the covariates and then use the residuals as the outcome variable in the mediation analysis. Do you think that might be the way to do it?

Will take a closer look at the references...

SteveDenham
Jade | Level 19

HI @Therese2 ,

 

I probably don't know the vocabulary of your field well enough.  When you say "covariate" do you mean a categorical variable of some sort? The reason I ask is that Example 2 has SES as a continuous predictor in PROC LOGISTIC.  If you had a categorical variable, you could enter it in the MODEL statement and in a CLASS statement. The only drawback I see right off the top is that when a continuous mediator is modeled, the example uses PROC REG, which unfortunately does not support the CLASS statement.  You would probably have to substitute PROC GLM to include the categorical covariate.  This presents some issues regarding standardized coefficients and non-full rank parameterization, but the standardized coefficients issue is probably the harder to solve.  You may have to use GLMMOD to get the design matrix to feed into PROC REG.  That should solve both problems, I think.

 

SteveDenham

Therese2
Calcite | Level 5

@SteveDenham sorry, covariates as in control variables.. 

SteveDenham
Jade | Level 19

Control variable = constant during the period of observation (at least that's how I think of it).  But that could be either categorical (biological sex) or continuous (weight at study enrollment).  Consequently, they could be either, which is the source of your original question I think. An overnight think on this leads me to believe the multi-step calculation presented in Example 2, using PROG LOGISTIC, PROC REG and a DATA step could be implemented.  The example uses a binary categorical mediator.  I assume the problem is that you have categorical variables with more than two levels. While adding a CLASS statement to PROC LOGISTIC seems the most straight forward to me, you could augment the data set with indicator (0/1) variables that define the levels of the categorical variables.  For a categorical variable with N levels, there would be N-1 indicator variables.  You would then include all of these indicator variables in the MODEL statement. Then you get the variance of the logits and go from there.  I think using the CLASS statement would be easier.  The key is going to be what the X*beta dataset looks like.  I assume that there will be one logit for each record, and there won't be any complications.

 

SteveDenham

SAS_Rob
SAS Employee

Proc CAUSALMED will allow you to add multiple variables to the COVAR statement and thus you can have multiple covariates.  But it will only allow a single mediator (i.e. one MEDIATOR statement) with a single predictor.

 

The Process Macro might be an option for you as it allows multiple mediators.  It can be downloaded with documentation here:

http://processmacro.org/download.html

SteveDenham
Jade | Level 19

@SAS_Rob : I went to the PROCESS.ORG website, and, at least according to the FAQ, It should be able to address the @Therese2 's issues. There is one huge drawback - the documentation for the program is not online, and is only available in the author's hardcopy book.  I suppose that if the issue is important enough, then spending 46USD shouldn't be a show-stopper.

The fact that PROCESS,ORG uses PROC IML may be something that @Therese2 would have to address with the site administrator where they are located.

 

SteveDenham

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 2781 views
  • 1 like
  • 3 in conversation