BookmarkSubscribeRSS Feed
Novice_user
Calcite | Level 5

Hello all, I need some help with marginal effects in proc mixed. I am comparing two treatments from a clinical trial. I have tried the following code:

PROC MIXED DATA=Data METHOD=ml;

CLASS trt_group patient_id;

MODEL y=visit_yrs|trt_group/solution residual;

Random int visit_yrs/subject=patient_id;

FORMAT trt_group trt_group.;

RUN;

What I'd like to do is get the marginal effects for the treatment group (ie mean of all readings for all participants across the study). I believe lsmeans only allows categorical variables. I did try putting visit_wks as a class variable to accommodate the lsmeans statement, however that seems to change all the parameters for the model. I hope I've got the terminology correct.  Any help would be greatly appreciated! 

2 REPLIES 2
sbxkoenk
SAS Super FREQ

Hello,

 

A nice blog about the terminology :
Marginalia: A guide to figuring out what the heck marginal effects, marginal slopes, average marginal effects, marginal effects at the mean, and all these other marginal things are
by Andrew Heiss
https://www.andrewheiss.com/blog/2022/05/20/marginalia/

 

For an answer, see here :
Usage Note 30333: FASTats: Frequently Asked-For Statistics
https://support.sas.com/kb/30/333.html

Search for "marginal effects".

 

Margins, predictive and marginal effects
The MARGINS statement can estimate and test predictive margins and marginal effects for CLASS (categorical) predictors and is available beginning in these releases in these SAS Viya procedures: GLIMMIX (2021.1.3), LOGISTIC, SURVEYLOGISTIC, SURVEYPHREG, SURVEYREG, LMIXED (2022.12). For both categorical and continuous predictors, the Margins macro (SAS Note 63038) is available in SAS/STAT beginning in SAS 9.4M8 or can be downloaded. The Margins macro can estimate and test predictive margins and average marginal effects in generalized linear and GEE models fit using SAS/STAT PROC GENMOD. Predictive margins and average marginal effects can be estimated by the macro at specified values of other model variables or at computed values such as means or medians. For binary or ordinal logit or probit models, point estimates of marginal effects for predictors not involved in interactions can be obtained from the MARGINAL option in the OUTPUT statement of SAS/ETS PROC QLIM. SAS Note 22604 discusses and illustrates the estimation of marginal effects in logit and probit models.


Usage Note 22604: Marginal effect estimation for predictors in logistic and probit models
https://support.sas.com/kb/22/604.html

 

Koen

Novice_user
Calcite | Level 5

Many thanks Koen, that information was interesting.  Unfortunately, I still couldn't figure out a way to calculate the mean across the whole study.  Is the only way to calculate the lsmeans at specific time points, save to an output, and take a mean of those means?  Or is there a simpler way?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 986 views
  • 0 likes
  • 2 in conversation