BookmarkSubscribeRSS Feed
polarjud
Calcite | Level 5

I think I found two undesirable features in LSMEANS.

 

First, it is calculating the means of the covariates on the set of cases where the outcome is not missing. For predictive margins, we really want the means on the set of cases where none of the covariates are missing.  As it is, LSMEANS is projecting to an uninteresting population.

 

Second, LSMEANS is rounding the population-wide averages of the covariates before taking their inner product with the beta coefficients.  (Or it is rounding the beta coefficients.  Maybe both?)  This can cause the LSMEAN for the reference group to be different than the empirical mean for the reference group.  This makes for awkward presentations.

5 REPLIES 5
ballardw
Super User

@polarjud wrote:

I think I found two undesirable features in LSMEANS.

 

First, it is calculating the means of the covariates on the set of cases where the outcome is not missing. For predictive margins, we really want the means on the set of cases where none of the covariates are missing.  As it is, LSMEANS is projecting to an uninteresting population.

 

Second, LSMEANS is rounding the population-wide averages of the covariates before taking their inner product with the beta coefficients.  (Or it is rounding the beta coefficients.  Maybe both?)  This can cause the LSMEAN for the reference group to be different than the empirical mean for the reference group.  This makes for awkward presentations.


Since LSMEANS is not unique to a single procedure you should provide some more details. Specifically example code that you are running.

 

First, it is calculating the means of the covariates on the set of cases where the outcome is not missing.

It is pretty well documented that the models are build this way. To predict results for the records with the model dependent missing varies a bit by procedure and option used.

 

You should provide some example data code to address why you think the second issue 1) exists and 2) why it makes for awkward presentations. It may be that some of the explanation would be available with additional options or perhaps just changes in display formats. Without a concrete example, preferably using one of the SAS supplied training sets found in the SASHELP library, code and interpretation it is awkward to address a likely mobile target in verbiage only.

 

 

polarjud
Calcite | Level 5

I found the first problem in both GLM and MIXED.  The second one may only impact MIXED.  Not sure.

 

It is extremely easy to reproduce.  

 

Let Y be some outcome variable with some missing data.

Let D1 and D2 be binary indicators for population domains of interest (no missing data).

Let X be a binary or continuous covariate (no missing data).

Let Z be a categorical variable labeling clusters (no missing data).

 

Proc Mixed data=;

  Class D1 D2 Z;

  Model Y = D1 D2 D1*D2 X/solution;

  Random intercept/subject=Z;

  LSMEANS D1 D2 D1*D2/E;

run;

 

proc means data= means;

  var X;

run;

 

You will immediately see that the means used by LMEANS to estimate predictive margins are different from those produced by proc means.  

 

 

 

 

Reeza
Super User
Check your PROC MIXED results, the first sets of tables will include one that shows the number of observations used. That will not match the PROC MEANS. If they N matches they would match and none of this seems unexpected to me.

I wouldn't want the LSMEANS to calculate the means using data it did not use to fit the model in the first place.
polarjud
Calcite | Level 5

Even with no missing data, they do not match because of rounding.  MIXED rounds more than MEANS.

 

But as for the desired behavior in the case of missing outcome data, I think you are missing the point of predictive margins.  They are supposed to present estimates on a well defined population.

PaigeMiller
Diamond | Level 26

@polarjud wrote:

But as for the desired behavior in the case of missing outcome data, I think you are missing the point of predictive margins.  They are supposed to present estimates on a well defined population.


LSMEANS can only work on the data you give it, and if the data has missings, that data can't be used.

 

Even with no missing data, they do not match because of rounding.  MIXED rounds more than MEANS.

 

Even if you had the same rounding, LSMEANS would not match MEANS.

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 1292 views
  • 0 likes
  • 4 in conversation