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

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Overlaying several regression lines from level-2 units in a single graph |

Date |
Tue, 22 May 2012 12:29:43 +0100 |

I'd get Stata to do the fitting outside -graph-. For example, webuse grunfeld, clear gen ln_invest = ln(invest) gen predict = . qui forval i = 1/10 { regress ln_invest year if company == `i' predict work replace predict = work if company == `i' drop work } xtline predict, overlay Nick On Tue, May 22, 2012 at 12:06 PM, Love Hansson <love.hansson@gmail.com> wrote: > I am currently working with a 2-level dataset containing level-1 > dependent and independent variables and level-2 independent variables, > connected with a level-2 group variable. I have found that one way of > visualizing the difference between level-2 units is to plot a > regression line for the level-1 independent and dependent variables in > the following fashion (similar to a Trellis plot): > > graph twoway (lfit depvar indepvar), by(grpvar) > > Obviously, this results in a number of graphs being plotted next to > each other. However, I would prefer it if *all* of the regression > lines could be plotted in an overlaying fashion into the same graph. > Is there any convenient way of doing this? One way of solving the > problem might be to do a "graph twoway" and then add as many "lfit" > parts as there are level-2 units, but since there are fairly many > level-2 units in my dataset I would prefer it if I could find a more > convenient solution. * * 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: Overlaying several regression lines from level-2 units in a single graph***From:*Love Hansson <love.hansson@gmail.com>

- Prev by Date:
**Re: st: Interpretation of Interaction terms in log-lin** - Next by Date:
**Re: st: Interpretation of Interaction terms in log-lin** - Previous by thread:
**st: Overlaying several regression lines from level-2 units in a single graph** - Next by thread:
**st: Execute shell command asynchronously?** - Index(es):