[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Austin Nichols <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: graphing results |

Date |
Wed, 9 Sep 2009 08:00:19 -0400 |

Matthijs --- The line that ends _b[x1*x2]*x1*x2_bar should probably end _b[x1x2]*x*x2_bar and note legal variable names should be used inside brackets... but probably the model should be y=a.x1+b.x1^2+c.x2+d.x1*x2+e.x1^2*x2+r i.e. it's a bit odd for x2 to be interacted with only one of the x1 terms, though it may or may not make a big difference for predictions... clear all sysuse nlsw88 ren wage y ren tenure x1 ren grade x2 g x1x2=x1*x2 g x1s=x1^2 g x1sx2=x1s*x2 reg y x1 x2 x1x2 x1s su x2 if e(sample), meanonly loc m=r(mean) loc f "_b[_cons]+_b[x1]*x+_b[x1s]*x^2+" loc f "`f'_b[x2]*`m'+_b[x1x2]*x*`m'" su x1 if e(sample), meanonly loc r2=r(max) loc r1=r(min) sc y x1,mc(gs12)||function `f', ra(`r1' `r2') clp(l) name(a) reg y x1 x2 x1x2 x1s x1sx2 su x2 if e(sample), meanonly loc f "_b[_cons]+_b[x1]*x+_b[x1s]*x^2+" loc f "`f'_b[x2]*`m'+_b[x1x2]*x*`m'+_b[x1sx2]*x^2*`m'" su x1 if e(sample), meanonly loc r2=r(max) loc r1=r(min) sc y x1,mc(gs12)||function `f', ra(`r1' `r2') clp(l) name(b) It's easier to -preserve-, -replace- x2 with its mean, and -predict- and -graph- btw. On Wed, Sep 9, 2009 at 7:15 AM, Isabelle Deltour<deltour@cancer.dk> wrote: > Hi Matthijs: > > Have you tried > graph export name_of_your_graph.wmf > and then copy and paste into a word document? > > Isabelle > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Matthijs De > Zwaan > Sent: Wednesday, September 09, 2009 12:34 PM > To: statalist@hsphsun2.harvard.edu > Subject: st: graphing results > > Dear Stata-listers, > I am trying to graph the results of my regression. I have estimated a > model with quadratic terms and an interaction, as in y=x1 + x1^2 + x2 > + x1*x2. I am trying to plot my results in a graph of y versus x1. > Using -adjust- to keep covariates doesn't do what I need, since it > also sets x1*x2 to the mean of the interaction, rather than x1*(mean > x2). > > I can get what I want by plotting it using the -graph twoway function- > command. My current code looks like: > graph twoway scatter y x1 /// > || function y = _b[_cons] + _b[x1]*x = _b[x1^2]*x^2 + _b[x2]*x2_bar + > _b[x1*x2]*x1*x2_bar , > > where x2_bar is the mean of x2 (in the estimation sample). > > However, when imported in a document, the final graph looks coarse: > more like a like a step-function than a smooth line, even when using > 2500 points to graph the function instead of the default 300. Is there > a way to get a graph that produces the effect of x1 on y controlling > for covariates, but that looks better than what I have now? > > Thanks for helping! > Matthijs * * 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/

**References**:**st: graphing results***From:*Matthijs De Zwaan <m.dezwaan@gmail.com>

**st: RE: graphing results***From:*"Isabelle Deltour" <deltour@cancer.dk>

- Prev by Date:
**st: transformations for highly skewed dependent variable** - Next by Date:
**RE: st: RE: RE: RE: RE: distribution curve with svy** - Previous by thread:
**st: RE: graphing results** - Next by thread:
**st: Cluster and xtabond2** - Index(es):

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