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

RE: st: error bars

From   "Nick Cox" <>
To   <>
Subject   RE: st: error bars
Date   Mon, 16 Jun 2008 13:23:57 +0100

Standard errors can come from lots of places, including the -ci-

Moleps seems to be implying that -ci- does the right calculation for his
or her purposes. 

(I note that Moleps has yearly results, but -ci- for separate years does
nothing about any time series structure in the data, for example about
taking serial correlation into account.) 

-ciplot- and -stripplot- from SSC both do -ci-type calculations and
graphing in one. 


Maarten buis

--- moleps islon <> 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. 

R. Newson (2003), "Confidence intervals and p-values for delivery to
the end user", The Stata Journal, 3(3), pp. 245--269.

*   For searches and help try:

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