Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Mean with confidence intervals for a collapsed data set


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   stata list <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Mean with confidence intervals for a collapsed data set
Date   Fri, 24 Jul 2009 15:04:51 +0000 (GMT)

> For graphing purposes I want to aggregate a panel data set, from unit
> to group level, to get a mean value for each group, each year. 
> Nonetheless, I would also like to have 95 %-confidence intervals (CI)
> around the calculated mean. What is making things a bit complicated is
> that I need to use (importance) weights when aggregating the data set.
>
> One way of doing this is by using the -statsby- program together with
> the -ci- program, but this does not allows importance weights.

What about this?

*---------- begin example ---------------
sysuse auto, clear
statsby _b _se e(df_r), by(rep78) : ///
    regress mpg [iw = weight]

rename _b_cons mean
rename _se_cons se
rename  _eq2_stat_1 df

gen lb = mean - invttail(df,0.025)*se
gen ub = mean + invttail(df,0.025)*se
*------------- end example --------------

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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