tsline with confidence intervals - Using margins

In this post, I will show you how to add confidence intervals to a tsline plot in Stata. Below is a worked example:

Please note, you will need to install parmest and tsmktim for this purpose. To download the programs type the following on the Stata command pane: ssc install parmest ssc install tsmktim


After installing the programs, please copy and paste the commands below in your do-file:

webuse grunfeld, clear
qui reg invest i.year i.company
margins i.year, post
// Roger Newson's parmest from SSC
parmest, saving(yeareff, replace)
use yeareff, clear
// Kit Baum's tsmktim from SSC
tsmktim year, start(1935)
tsline estimate || tsrline min95 max95, legend(col(1)) scheme(s2mono)

For more useful tips in Stata graphs, please have a look at the book Speaking Stata Graphics

42 views

© 2020 by Survey Design and Analysis Services. 

  • LinkedIn
  • Facebook
  • Twitter
  • YouTube