Hello!
I'm having a few problems trying to run and interpret output from the "Predictive margins and average marginal effects" macro on SAS 9.4 using Windows 10: https://support.sas.com/kb/63/038.html
Right now, I'm attempting to run a simplified model using four variables, with the goal of examining margins effects of t7dmar_c on Mar_8 at different levels of t7cgender (i.e., the interactive effect of t7cgender*t7dmar_c):
Mar_8 is the outcome variable and has a negative binomial distribution
Mar_7 is a continuous predictor variable
t7dmar_c is a continuous predictor variable
t7cgender is a dichotomous (0, 1) predictor variable, to be examined as a moderator of the relationship between t7dmar_c and Mar_8
Here is my sas code for the macro:
%Margins(data = marginsdata,
class = t7cgender,
response = MAR_8,
dist = negbin,
model = t7cgender t7dmar_c MAR_7 t7dmar_c*t7cgender,
margins = t7dmar_c,
at = t7cgender)
I've gotten the macro to run in this form; however, I'm having trouble with a couple of things:
1. The output for the regression provides coefficients for t7dmar_c in the order of ~0.4, but the marginal effects provides coefficients ranging from ~40-100. Why would this be? My understanding is that these marginal effects should be using the sample units as in the regression. See attached for an XL file containing the output, as well as data.
2. The macro takes a VERY LONG time to run on my computer (several hours, to overnight, depending on the type of model I'm running). This is especially true when using a continuous variable in the "at = " portion. In some cases I even get "ERROR: The SAS System stopped processing this step because of insufficient memory." I'm guessing this is because it is estimating an enormous number of effects, especially in the case of the interaction between two continuous variables. I don't need marginal effects at every level in the data, and believe reducing the number of levels at which these effects are estimated should solve this problem (e.g., as it has above using a dichotomous moderator). I've read in the notes that I could request specific levels of marginal effects using both the "marginswhere = " and "atwhere = " statements. Yet, I cannot figure out how to get the model to produce marginal effects at only these levels.
For example:
%Margins(data = marginsdata,
class = t7cgender,
response = MAR_8,
dist = negbin,
model = t7cgender t7dmar_c MAR_7 t7dmar_c*t7cgender,
margins = t7dmar_c,
marginswhere = 1,
at = t7cgender)
This will run, but provides no different output than the previous model. I would expect it to provide marginal effects of t7dmar_c only at 1. How can I request specific levels of the marginal effects? Any examples would be appreciated, as none are provided in the "Results" portion of the macro description. Perhaps I'm not understanding how these statements should be used, but I could use some help figuring it out.
Thank you!
... View more