| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Creating loops to drop observations each time regression is run
From |
Samia Tavares <[email protected]> |
To |
[email protected] |
Subject |
Re: st: RE: Creating loops to drop observations each time regression is run |
Date |
Sun, 2 Apr 2006 10:45:11 -0400 |
That worked. Thanks a lot!!
Samia
On Apr 1, 2006, at 7:52 PM, Neil Shephard wrote:
On 4/2/06, Thuy Le <[email protected]> wrote:
You can use the 'foreach'. See help on 'foreach' for details.
Although in this example forval may be more appropriate...
use dataset.dta, clear
drop if code=="country1"
regress y x
use dataset.dta, clear
drop if code=="country2"
regress y x
Assuming that code is always countryN then you could...
forval x = 1/N{
use dataset, clear
drop if(code == "country`x'")
regress y x
}
You would substitute N in the above for the maximum country number.
If however you actually have named countries such as "Australia",
"United States", "Germany", "Nepal", "United Kingdom", "France" etc.
then you would have to use foreach....
foreach x in Australia "United States" France Germany "United
Kingdom" Nepal{
use dataset, clear
drop if(code == "`x'")
regress y x
}
Note that countries where there are two parts to the name need to be
encapsulated in double quotes.
Nick Cox has written a "Speaking Stata" article on this very topic...
Cox, NJ (2002) Speaking Stata: How to face lists with fortitude. Stata
Journal 2:202-222
http://ideas.repec.org/a/tsj/stataj/v2y2002i2p202-222.html
Alternatively you may be interested in Roger Newson's -parmby- command
(part of the parmest package). See -ssc desc parmest- for more
information and -ssc install parmest- to install.
Neil
--
"The best safety device in climbing is always situated between your
ears" - Ross Weiter, Perth Rock Climbing Guide (2002)
Email - [email protected] / [email protected]
Website - http://slack.ser.man.ac.uk/
Blog - http://slack---line.blogspot.com/
Flickr - http://www.flickr.com/photos/slackline/
*
* 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/
*
* 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/