# Re: st: CI for adjusted mean

 From Rachele Capocchi To statalist@hsphsun2.harvard.edu Subject Re: st: CI for adjusted mean Date Mon, 29 Oct 2007 12:13:51 +0100

I have read the material and now I have undestood the difference between the two commands.

Kind Regards,
Rachele

khigbee@stata.com ha scritto:

Rachele Capocchi <rachele.capocchi@arsanita.toscana.it> said:

I tried:

. adjust wei, by(rep) se ci

and I obtained the adjusted means of the groups, but I don't know how
I can obtain the overall mean.
And Maarten Buis <maartenbuis@yahoo.co.uk> answered with"

sysuse auto, clear
recode rep78 1/2 = 3
xi: reg mpg i.rep78 wei

<cut>
Just to add extra light to what is happening

which produces 21.2899 as the estimate, is the same as

because -by()- was not specified so there is only one cell in the
output table and the variables that were left "as is" in the
first call were set to their mean within that cell (there is only
when weight is 3032.029, _Irep78_4 is .26086957, and _Irep78_5 is
.15942029. The estimation sample has 26% with rep78 at level 4,
16% at level 5, and the remaining 58% at level 3 (with level 3
omitted from the regression estimation).

You may be wondering what it means to ask for a prediction where
an indicator variable is set to .26 or .16 instead of something
like 0 or 1.

-regress- knows nothing about categorical variables. As far as
it knows all variables are continuous. So -predict- after
-regress- has no problem producing predictions for values of
_Irep78_4 such as .26.

With our -regress- example, you get the same answer produced by
the -adjust- commands above by taking an appropriately weighted
linear combination of the predictions found in

which gives values of

----------------------
Repair |
Record |
1978 | xb
----------+-----------
3 | 20.9262
4 | 20.7741
5 | 23.4563
----------------------

When you multiply the estimates for each level of rep78 by the
proportion of that level found in the data

20.9262*.57971014 + 20.7741*.26086957 + 23.4563*.15942029

it equals our overall estimate

21.2899

obtained earlier.

You might want to see the following FAQ

which is related to this discussion.

"asis" in -adjust-. With -regress-, what I am about to point out
does not matter (because the mean of a linear combination is the
linear combination of the means), but with other estimators such
as -logit- it does matter. So, since Rachele is using -anova-
and -regress- she may not care about what I am about to point
out, but those using other models should be aware of the issue.

Journal article

Buis, M. L. 2007. predict and adjust with logistic
regression. Stata Journal 7, Number 2, pages 221-226.

where he presents

. webuse lbw
. gen black = race==2
. gen other = race==3
. logit low age lwt black other smoke

and compares

. predict p
. tabstat p, statistics(mean) by(ht)
to

Maarten concludes the Stata Journal article saying:

"... predict will give us the average predicted probability for
someone with hypertension, whereas adjust will give us the
predicted probability for someone with average values on age,
lwt, black, other, and smoke for someone with hypertension. It
is the difference between a typical predicted probability for
someone within a group and the predicted probability for
someone with typical values on the explanatory variables for
someone within that group."

The Stata Journal article explains why this is true and presents
two pictures illustrating the point. See
http://www.stata-journal.com/abstracts/st0127.pdf
for the abstract of this Stata Journal article and
http://www.stata.com/bookstore/sjj.html?issue=sjj7-2
to order it if you do not have a copy available to you.

Ken Higbee khigbee@stata.com
StataCorp 1-800-STATAPC

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
```*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```