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.
@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.
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.
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.
@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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.