BookmarkSubscribeRSS Feed
tymon
Calcite | Level 5

I am having an issue with using the Margins Macro to estimate predictive margins for my class variables. The same result is produced across all variables in the model, as well as all levels of individual variables, regardless of the variable I am attempting to analyse. The same problem is occurring for all continuous variables (with a different set of uniform results). Code and two examples of results below.

 

Grateful for any assistance on what I am doing wrong here!

 

%Margins(data     = current.final, 
         class    = ATSI Gender NDIS LSIR sec SD PD CD PSD,
         response = sentences_2015_2019_all,
         dist     = poisson,
         model    = ATSI NDIS Gender PD CD PSD SD sentences_pre2019_all LSIR sec age ndis*lsir,
         margins  = lsir,
         alpha    = 0.1,
         options  = atmeans diff cl nomodel)

Results:

 

Screen Shot 2021-07-13 at 7.00.11 pm.pngScreen Shot 2021-07-13 at 7.01.18 pm.png

 

 

1 REPLY 1
StatDave
SAS Super FREQ

Nothing looks wrong about the macro call. It is not clear why all margins are identical. I suggest you examine the fitted model. However, since all of the predictors are fixed due to the atmeans option, you should be able to just fit the model in PROC GENMOD and use the LSMEANS statement with the ILINK option to estimate the mean count at each level of LSIR. If you need to estimate and test the difference in means, you can then use the NLMeans macro. For example, using Example 3 in the Margins macro documentation, the following give essentially the same results:

%Margins(data     = long97data,
         class    = Fem Mar,
         response = Art,
         model    = Fem|Mar Ment, 
         dist     = poisson,
         margins  = Fem, 
         balanced=mar, mean=ment,
         options  = diff cl )
proc genmod data=long97data; 
  class fem mar; 
  model art=fem|mar ment / dist=poisson;
  lsmeans fem / ilink cl diff e;
  store pmod;
  ods output coef=coeffs;
  run;
%NLMeans(instore=pmod, coef=coeffs, link=log)

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 452 views
  • 1 like
  • 2 in conversation