Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Maria Ana Vitorino <vitorino@wharton.upenn.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: using a loop to run multiple regression models |

Date |
Sat, 5 Nov 2011 16:53:51 -0400 |

Thanks!! Ana On Nov 5, 2011, at 4:47 PM, Tirthankar Chakravarty wrote:

Something like this: ********************************************** clear* set obs 1000 g y = rnormal() drawnorm a b c d e f local rhssets ""a b" "c d" "e f"" local counter = 1 foreach x of local rhssets { reg y `x' predict yhat`counter' local counter = `counter' +1 } ********************************************** T On Sat, Nov 5, 2011 at 10:47 AM, Maria Ana Vitorino <vitorino@wharton.upenn.edu> wrote:Dear statalist users,Can something similar to this be done in stata? The code I'mproviding is*clearly incorrect* but I think it gives the idea of what I'mlooking for.I'm basically trying to create sets of right-hand sets variablesthat canbe used to generate several model specifications.And can I also include a counter in the loop that keeps track ofhow manydifferent model specifications were estimated so that I cangenerate fittedvalues using the counter value as an index? counter=1 local rhssets ` "x1 x2" "x2 x3 "' foreach rhs of loc rhssets{ corr `rhs' reg Y `rhs' counter=counter+1 predict yhat`counter' } Any help is appreciated. Thanks! Ana * * 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/-- Tirthankar Chakravarty tchakravarty@ucsd.edu tirthankar.chakravarty@gmail.com * * 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/

* * 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: using a loop to run multiple regression models***From:*Maria Ana Vitorino <vitorino@wharton.upenn.edu>

**Re: st: using a loop to run multiple regression models***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: using a loop to run multiple regression models** - Next by Date:
**SV: st: problems with nlsur aids** - Previous by thread:
**Re: st: using a loop to run multiple regression models** - Next by thread:
**st: spatial weight matrix in stata** - Index(es):