Bookmark and Share

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]

Re: st: -foreach- loop to fit regression at each level of a variable


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: -foreach- loop to fit regression at each level of a variable
Date   Tue, 19 Nov 2013 13:55:01 +0000

imply or infer that I am suggesting that anyone reads _all_ the
documentation. You had a question about -foreach- (etc.) and the help
for -foreach- explained your problem. -search foreach- pointed to
resources directly relevant to your question.

Moving forward, you have a new question, which is in essence that you
don't get any estimates.

As it stands, that question is not answerable. Please show us the
relevant syntax and tell us more about your data. Ideally, illustrate
your problem with data we can all access.

Nick
[email protected]


On 19 November 2013 13:38, Milena Przheska
<[email protected]> wrote:
> With all due respect, I doubt that everyone that posts a question has
> read all 11000 pages of documentation.
>
> I felt overwhelmed, so I asked for help.
>
> And by the way, even with all the syntax correct, I don't get any
> estimates, which was the essence of my question.
>
>
>
> On Tue, Nov 19, 2013 at 2:27 PM, Nick Cox <[email protected]> wrote:
>> My point was that I had already explained why -foreach- with -of- did
>> not work without a key word indicating list type. Also, the specific
>> FAQ referred to does explain at length how to approach exactly your
>> problem.
>>
>> The Statalist FAQ does underline an expectation that people do try to
>> read the documentation.
>>
>> Nick
>> [email protected]
>>
>>
>> On 19 November 2013 13:10, Milena Przheska
>> <[email protected]> wrote:
>>> Nick,
>>>
>>> Judging by your tone I realize I have wasted your patience, but my
>>> question was whether it is even possible to do what I wanted, because
>>> I just wanted to know whether I am on the right path, or trying
>>> something that Stata cannot accept.
>>>
>>> In any case, thank you for your reply.
>>>
>>> On Tue, Nov 19, 2013 at 1:57 PM, Nick Cox <[email protected]> wrote:
>>>> Please read the whole of my reply and the FAQ referred to.
>>>>
>>>> Nick
>>>> [email protected]
>>>>
>>>>
>>>> On 19 November 2013 12:47, Milena Przheska
>>>> <[email protected]> wrote:
>>>>> Yes, I fixed that with the following:
>>>>>
>>>>>
>>>>> levelsof sample, local(sample_levels)
>>>>>
>>>>> but the -foreach- still does not work
>>>>>
>>>>>
>>>>> On Tue, Nov 19, 2013 at 1:43 PM, Nick Cox <[email protected]> wrote:
>>>>>> Also, there is no legal syntax
>>>>>>
>>>>>> -egen local-
>>>>>> Nick
>>>>>> [email protected]
>>>>>>
>>>>>>
>>>>>> On 19 November 2013 12:42, Nick Cox <[email protected]> wrote:
>>>>>>> Just looking at the help for a few seconds establishes that
>>>>>>>
>>>>>>> 1. There is no -levelsof()- function for -egen-.
>>>>>>>
>>>>>>> 2. -foreach ... of- requires a key word specifying a list type to follow.
>>>>>>>
>>>>>>> Also you should learn in type in Stata
>>>>>>>
>>>>>>> . search foreach
>>>>>>>
>>>>>>> to find resources. In this case,
>>>>>>>
>>>>>>> http://www.stata.com/support/faqs/data-management/try-all-values-with-foreach/
>>>>>>>
>>>>>>> is most focused on your problem.
>>>>>>>
>>>>>>> Nick
>>>>>>> [email protected]
>>>>>>>
>>>>>>>
>>>>>>> On 19 November 2013 12:34, Milena Przheska
>>>>>>> <[email protected]> wrote:
>>>>>>>
>>>>>>>> I am trying to fit the same logistic regression model using different
>>>>>>>> samples from a data set and I am wondering if it is even possible to
>>>>>>>> use a -foreach- loop to estimate regression models for each sample
>>>>>>>> (indicated by a variable).
>>>>>>>>
>>>>>>>> I use the variable 'sample' to indicate the sample, but instead of
>>>>>>>> writing the command over and over for each sample, I tried to do this
>>>>>>>> with a -foreach- loop, something  like this:
>>>>>>>>
>>>>>>>> egen local sample_level = levelsof(sample)
>>>>>>>>
>>>>>>>> foreach n of sample_level {
>>>>>>>> logistic outcome var1 var2 var3 if sample_level==`n', vce(cluster id)
>>>>>>>> }
>>>>>>>>
>>>>>>>> As always, I would appreciate your help.
>>>> *
>>>> *   For searches and help try:
>>>> *   http://www.stata.com/help.cgi?search
>>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index