Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: graphs linear regressions with dummies


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: graphs linear regressions with dummies
Date   Tue, 9 Nov 2004 15:09:58 -0000

To follow up my previous posting, you 
can do this with less typing (and without changing
your existing variables) 

sysuse auto,clear
reg price mpg fore
predict fit
separate fit, by(foreign) veryshortlabel 
twoway line fit? mpg, clcolor(blue green) 
	ytitle(Predicted Price)

The -veryshortlabel- option is undocumented, 
but helpful here. 

Nick 
[email protected] 

[email protected]

> One way would be to replace dummy values before the fitted 
> values are generated.
> 
> Here is an example of generating fitted values for different 
> values of foreign:
> 
> sysuse auto,clear
> reg price mpg fore
> replace fore = 1 if fore == 0
> predict fit_foreign 
> label var fit_fore "Foreign"
> replace fore = 0 if fore == 1
> predict fit_domestic
> label var fit_dom "Domestic"
> twoway (line fit_foreign mpg, clcolor(blue) clwidth(medium) 
> ytitle(Predicted Price)) ///
> (line fit_domestic mpg, clcolor(green) clwidth(medium))

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