BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Alice86
Calcite | Level 5
Dear all,
I need to calculate the average marginal effects for some logistic regression models im running. I use proc surveylogistic because my data must be bootstrapped and I was able to run marginal effects for some models. In other models where I have to impute data, I use proc surveylogistic followed by proc analyze.. I'm at a lost as to how I can calculate the marginal effects of the final estimates.

If anyone has any ideas please let me know. Thanks in advance!
1 ACCEPTED SOLUTION

Accepted Solutions
SAS_Rob
SAS Employee

In order to use Proc MIANALYZE to combine the estimates, you would also need to have a standard error of the marginal effect (or some measure of variation).  I suppose this could be done using the Delta Method, but I do not know of any published examples where someone has done this.

View solution in original post

2 REPLIES 2
SAS_Rob
SAS Employee

In order to use Proc MIANALYZE to combine the estimates, you would also need to have a standard error of the marginal effect (or some measure of variation).  I suppose this could be done using the Delta Method, but I do not know of any published examples where someone has done this.

Alice86
Calcite | Level 5

Thanks a lot for your response Rob!

I essentially followed this step from SAS support (http://support.sas.com/kb/22/604.html😞

 

Marginal effects using results from PROC LOGISTIC

To compute the marginal effects using results from a model fit with PROC LOGISTIC (or other modeling procedure), include an ODS OUTPUT statement to write the ParameterEstimates table to a data set. Also specify the OUTPUT statement to save the predicted probabilities for a logistic model (use the P= option), or the x'b values for a probit model (use the XBETA= option) to a data set.

      proc logistic data=remiss;
        model remiss(event="1")=blast smear;
        ods output parameterestimates=logparms;
        output out=outlog p=p;
        run;

Use PROC TRANSPOSE to arrange the parameter estimates as a row and rename them so as not to conflict with the original variable names.

      proc transpose data=logparms out=tlog (rename=(blast=tblast smear=tsmear));
        var estimate;
        id variable;
        run;

Then use a DATA step to combine the parameter estimates and OUT= data sets and compute the marginal effects for each observation in the original data. Only the marginal effects for the response level representing the event of interest (REMISS=1) are computed below. The marginal effect for REMISS=0 could be similarly computed.

      data outlog;
        if _n_=1 then set tlog;
        set outlog;
        MEffBlast = p*(1-p)*tblast;
        MEffSmear = p*(1-p)*tsmear;
        run;
      proc print noobs;
        var smear blast MEff:;
        run;

 

I used mianalyze to get the appropriate standard errors but used the imputed runs to calculate the average marginal effects 🙂

 

Thanks again!

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!

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
  • 2 replies
  • 2117 views
  • 0 likes
  • 2 in conversation