Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Bugs in LSMEANS

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 04-24-2018 02:44 PM
(1408 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@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

Paige Miller

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

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.