Statalist


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

Re: st: error bars


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: error bars
Date   Mon, 16 Jun 2008 13:05:25 +0100 (BST)

--- moleps islon <[email protected]> wrote:
> I need to make a an error-bar graph categorised by year. I've tried
> using serrbar mean(x) etc, but I cant find a command for the standard
> error. Do I need to run a CI, generate a new variable from the ci
> result and feed that into serrbar?

There are many ways of doing this. For instance you can use methods
discussed in (Buis 2007) (a convenient estimatation command would in
this case be -mean-), or you can remember that the standard error of
the mean is the standard deviation divided by the square root of the
number of observations, like in the example below: 

*-------------- begin example -----------------------
sysuse nlsw88, clear
gen mis = missing(wage, age)
bys age: egen mwage = mean(wage)
bys age: egen sdwage = sd(wage)
bys age mis: gen se = sdwage/sqrt(_N) if mis == 0
serrbar mwage se age, scale(1.96)
*-------------- end example -------------------------

Notice that a fixed scale is slightly problematic here as idealy this
scale should depend on the number of observations (a t-test), but 1.96
should work fine in large samples. For a more flexible approach, where
you can take all this into account see: (Newson 2003)

-- maarten

M.L. Buis (2007), "Stata tip 54: Where did my p-values go?", The Stata
Journal, 7(4), pp.584--586. 
http://home.fsw.vu.nl/m.buis/wp/pvalue.html 

R. Newson (2003), "Confidence intervals and p�values for delivery to
the end user", The Stata Journal, 3(3), pp. 245--269.
http://www.stata-journal.com/article.html?article=st0043

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

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


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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/



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