Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: plotting a regression function with time-dummies indicating structural breaks

 From Maarten buis To "statalist@hsphsun2.harvard.edu" Subject Re: st: plotting a regression function with time-dummies indicating structural breaks Date Tue, 3 May 2011 11:16:50 +0100 (BST)

```--- Oliver Jones <ojones@wiwi.uni-bielefeld.de>
> here is some example I just made up, that shows what I mean by "range
> problem"

Notice that, as Nick already told you, -twoway function- cannot include
variables in the way you use it in your example. You must "create" your
dummies on the fly within your -twoway function- specification. So in
the example below I changed -d1- with -(x>1995)- and -d2- with
-(x>2005)-. For more on this trick see:
<http://www.stata.com/support/faqs/data/trueorfalse.html>

*--------------------------- begin example ---------------------
clear
set obs 20

gen int TIME = _n + 1990

* create dummies
gen byte d1 = 0
replace d1 = 1 if TIME > 1995
gen byte d2 = 0
replace d2 = 1 if TIME > 2005

tsset TIME

* set coefficients
scalar b_0 = 100
scalar b_1 = 2
scalar b_2 = 10000
scalar b_3 = -5
scalar b_4 = 20

* generate the time series
set seed 1
gen u = rnormal(0,2)
gen y = b_0 + b_1*TIME + b_2*d1 + b_3*d1*TIME + b_4*d2 + u

tw ///
(tsline y) ///
(function y = b_0 + b_1*x + b_2*(x>1995) + b_3*(x>1995)*x + b_4*(x>2005), ///
range(1991 2010)), ///
legend(order(1 "tsline" 2 "function"))
*-------------------------------- end example ----------------------------------

Hope this helps,
Maarten

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

http://www.maartenbuis.nl
--------------------------

*
*   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/
```