All entries for February 2013

February 18, 2013

A little note on CIs

Writing about web page

Confidence Intervals are pretty mega, but sometimes it can be difficult to create a graphical representation showing a point estimate (e.g. the mean) and the corresponding confidence interval.

Fortunately, this Scottish Health Survey web page has a nice summary explaining what CIs are, and a further explanation as to how to graph them in Excel.

For CIs in Stata, the following might be useful:

But you may need to prepare the data in Stata before running the syntax.

February 08, 2013

Stata syntax surprise

Here are two bits of syntax that have truly facilitated my life.

When faced with a load of survey variables to clean or recode or regress, the long-winded way is to do them all individually.


regress var1 iv1 iv2 iv3

regress var2 iv1 iv2 iv3

regress var3 iv1 iv2 iv3

Needless to say, it stops being fun after about var5.

So the solution is to set up a little macro. Say there are 7 variables we want to regress using the same regression model.

forval x=1/7 {

regress var`x' iv1 iv2 iv3


It's so beautiful!

But wait! What if your variable doesn't have a number? What if it's vara varb varc vard etc?

There is another beautiful loop.

foreach x of new `c(alpha)'{

dis "x'"

regress var`x' iv1 iv2 iv3


This loop will cycle through the aphabet. If you have variables from a to k, it will stop at k.

And these two little loops have revolutionised my syntax.

They can be used with anything!

My next mission: to find out how they can be combined.


Internet credits for the alpha loop:

Other useful stata sites and things: (love the syntax walkthroughs) (love the annotated outputs)

Publication-ready tables: try tabout outreg/outreg2 and estout

February 2013

Mo Tu We Th Fr Sa Su
Jan |  Today  | Mar
            1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28         

Search this blog


Blog archive

Not signed in
Sign in

Powered by BlogBuilder