[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Rachele Capocchi <rachele.capocchi@arsanita.toscana.it> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: CI for adjusted mean |

Date |
Mon, 29 Oct 2007 12:13:51 +0100 |

Thanks for the exhaustive answer.

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:

And Maarten Buis <maartenbuis@yahoo.co.uk> answered with"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.

sysuse auto, clearJust to add extra light to what is happening

recode rep78 1/2 = 3

xi: reg mpg i.rep78 wei

adjust wei, se ci

adjust wei, se ci by(rep78)

<cut>

. adjust wei

which produces 21.2899 as the estimate, is the same as

. adjust wei _Irep78_4 _Irep78_5

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

one cell). -adjust- is asking -predict- to give the prediction

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

. adjust wei, by(rep)

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

http://www.stata.com/support/faqs/stat/adjust.html

which is related to this discussion.

Here are some additional comments concerning leaving variables

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

Maarten already knows all about this -- he wrote a recent Stata

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

. adjust, pr by(ht)

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/

**References**:**Re: Re: st: CI for adjusted mean***From:*khigbee@stata.com

- Prev by Date:
**st: artifacts after merge** - Next by Date:
**st: help to create a constant price variable (UK firm data)** - Previous by thread:
**Re: Re: st: CI for adjusted mean** - Next by thread:
**st: Reconciling xtabond2 and DPD98** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |