Newsgroups: bit.listserv.sas-l
Date:         Wed, 8 Apr 1992 17:47:36 EDT
Reply-To:     Tim Dorcey <TCD@CORNELLC.BITNET>
From:         Tim Dorcey <TCD@CORNELLC.BITNET>
Subject:      Re: ANCOVA and LSMEANS

On Wed, 8 Apr 1992 12:01:57 CDT Dick Campbell 312/413-3759 FAX 312/996-5104 said
>If one has a standard one way ANCOVA the SAS LSMEANS statement produces
>classic adjusted means.  However, suppose the design is a two way factorial.
>If the design is orthogonal, LSMEANS still produces standard results. How-
>ever, if the design is non-orthogonal, it is my understanding that the
>adjusted means that one gets are estimated as though the design were
>orthogonal. This makes sense when departures from othogonality are "nuisance"
>effects due to trivial amounts of missing data. Its doesn't make sense if the
>data come from a survey. Example:
>PROC GLM; CLASS RACE SEX;
>  MODEL y = RACE SEX EDUC;    (assume no sig. two way interaction)
>  LSMEANS RACE SEX;
>
>In this case, unequal N's in the cells of the two by two reflect RACE and
>SEX differences in mortality. You would not want adjusted means to assume
>such effects away.
>
>I am concerned about this because a loose reading of the SAS manual would
>lead on to think that LSMEANS is just an easy way to get classical adjusted
>means in ANCOVA. It is for simple designs. For more complex designs it
>appears to do more than that.

This is an important point to be aware of when using LSMEANS.  However, you
should be able to get whatever you want by using an appropriate ESTIMATE
statement.  I like to conceptualize this in terms of trying to predict the
response variable based on varying amounts of information.  Using the
example above, we have estimated the parameters of a linear model for the
expected value of Y given values of Race (R), Sex (S), and Education (E):

E{Y|R=i,S=j,E=e} = m + r[i] + s[j] + b*e

So, if I drew a random individual from the population and was told
that their Race was i, there Sex was j, and their Education was e, I would
use the above formula to calculate a least squares estimate of their value
for Y.  Now, what would I do if I was only told what their Race was?  In order
to get a least squares mean for Race=1, I would need to make some assumptions
about the distribution of the characteristics in the sample.  The value
that PROC GLM will compute for a least squares mean can be obtained by
making the following assumptions about the population distribution of the
various predictors in the model:
1)  All predictors are independent of one another
2)  All CLASS variables are uniformly distributed across their levels
3)  The distribution of non-CLASS variables is represented by their observed
    distribution in the sample.

Taken together, these assumptions imply that:

E{Y|R = 1} = m + r[1] + .5*s[1] + .5*s[2] + b*ebar

where ebar is the mean of E in the sample and assuming that Sex takes on
2 different values.  I.e., since we don't know what S or E are, we assume
that each value of S is equally likely and that the likelihood of a particular
value for E is proportional to its frequency in the sample.
     If the assumptions which lead to this estimate are not reasonable for
the population of interest, then one can use the ESTIMATE statement.  For
example, suppose that the joint distribution of Race x Sex in the population
that we are interested in is:
        Race=1   Race=2   Race=3
Sex=1    .3        .2       .1
Sex=2    .1        .1       .2
but that we continue to assume that Education is independent of either of
these factors.  Note that this assumption about Education may seem
implausible for most currently existing population, but we still might like
to guess what we would expect to see in a population where there were no
education differences among the groups.  Then, to get our least squares mean
for Race = 1, we first note that the conditional distribution of Sex given
Race = 1 is:  Pr{S=1|R=1} = .75 and Pr{S=2|R=1} = .25.  Thus:

E{Y|R=1} = m + r[1] + .75*s[1] + .25*s[2] + b*ebar
or, in PROC GLM, terminology:
ESTIMATE 'R=1' INTERCEPT 1 RACE 1 0 0 SEX .75 .25 EDUC 10.243;
(assuming the mean of EDUC is 10.243).

Similarly, we could construct, e.g.,

E{Y|S=2} = m + .25*r[1] + .25*r[2] + .5*r[3] + s[2] + b*ebar

or,

E{Y|E=11.5) = m + .4*r[1] + .3*r[2] + .3*r[3] + .6*s[1] + .4*s[2] + b*11.5

Now let's drop the assumption that Education is independent of Race and Sex
and suppose that the expected value of Education for each of the groups is:
         Race=1   Race=2   Race=3
Sex=1     10        9        8
Sex=2     12       20       11

Then we have:

E{Y|R=1} = m + r[1] + .75*s[1] + .25*s[2] +  b*(.75*10 + .25*12)

Note that we can make up whatever particular joint distribution for S,R,E
that we like, and obtain least squares means for that hypothetical
population (as long as we believe our original linear model is valid in
the population we are thinking of).  Also, we can test whether two
least squares means are different from one another by creating the
appropriate estimates as above, and then create a new estimate whose
coefficients are the difference between corresponding coefficients of
the 2 estimates.  E.g., we could ask questions like "if we had a
population where the average education in each group was 13.2, would we
expect a difference in Y between Race 1 and Race 2?" (use a CONTRAST
statement to compare more than 2 estimates).
     If we were to adopt the most general assumptions that were
considered above, and then suppose that the sample from which we
estimated the model parameters is representative of the population that
we are actually interested in, then we could estimate the joint
distribution of Race and Sex and Education from that same data (i.e., we
could fill in the two 2 x 3 tables above with sample proportions and
sample means).  In that case, however, there would be little point in
fitting the linear model in the first place, because all of our least
squares means would end up being the same as the simple arithmetic
means, e.g.,
E{Y|R=1} = average of all observations with R=1
     Some time ago I posted a similar discussion of this way of looking
at LSMEANS and ESTIMATE, and would be happy to forward a copy to anyone
who found this posting useful (hey, you made it this far....)

Tim Dorcey                        BITNET:   TCD@CORNELLC
Statistical Software Consultant   Internet: TCD@CORNELLC.CIT.CORNELL.EDU
Cornell Information Technologies  Phone:    (607) 255-5715
Cornell University
Ithaca, NY  14853