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: Different results with the same code
From
Estrella Gomez <[email protected]>
To
[email protected]
Subject
Re: st: Different results with the same code
Date
Mon, 10 Feb 2014 11:41:52 +0100
Sorry, I've realized that you were right: some variables in (firstnm)
vary also by country and orig
Thank you very much!
Estrella
2014-02-10 11:24 GMT+01:00 Estrella Gomez <[email protected]>:
> Hi, Nick
>
> I do the collapse by country and orig; and the variables I include in
> (firstnm) do not vary by country and orig, that's why I thougth that
> picking the first value in each case would be enough; because it
> should be equal to the rest of cases in that pair. Is not like that?
>
> Thanks,
> Estrella
>
>
> 2014-02-10 11:08 GMT+01:00 Nick Cox <[email protected]>:
>> Wrong way round: -collapse- reports (firstnm) as it finds them; it's
>> the sorting that includes some arbitrariness.
>>
>> But evidently you have different values on variables for which you
>> select (firstnm), so why do you want to pick the first non-missing and
>> what sort order do you want?
>>
>> Nick
>> [email protected]
>>
>>
>> On 10 February 2014 09:59, Estrella Gomez <[email protected]> wrote:
>>> Hi, Nick
>>>
>>> I have tried sorting just before the collapse and it happens the same
>>> thing. Does (firstnm) use random values each time then?
>>>
>>> Thank you,
>>> Estrella
>>>
>>> 2014-02-10 10:41 GMT+01:00 Nick Cox <[email protected]>:
>>>> Contrary to your claim, I would point at this:
>>>>
>>>> Which values are (firstnm) is likely to depend on the exact sort order
>>>> of your data and you are sorting before you -collapse-.
>>>>
>>>> As Phil Schumm often explains, you could get consistent results by
>>>> insisting on stable sorting, but that would be hiding a bug. There's
>>>> evidently some arbitrariness that is better fixed directly.
>>>> Nick
>>>> [email protected]
>>>>
>>>>
>>>> On 10 February 2014 09:07, Estrella Gomez <[email protected]> wrote:
>>>>> Dear Statalisters
>>>>>
>>>>> I am running a code and I have realized that every time I run it the
>>>>> results (the coefficients and the standard errors) are different. This
>>>>> is the code:
>>>>>
>>>>> clear all
>>>>> use "itunes_grav_song", clear
>>>>> sort id country orig
>>>>>
>>>>> egen nb_id=tag(id)
>>>>> bysort orig: egen nr_orig=sum(nb_id)
>>>>> bysort orig country: egen nr_dest=sum(available)
>>>>> gen avail_share=(nr_dest/nr_orig)
>>>>> collapse (count) nr_songs=id (firstnm) contig comlang ldist
>>>>> avail_share, by(country orig)
>>>>> encode country, gen(d_id)
>>>>> encode orig, gen(o_id)
>>>>> gen home=country==orig
>>>>>
>>>>> reg avail_share ldist comlang home i.d_id i.o_id
>>>>>
>>>>>
>>>>> I have checked and after the collapse I obtain every time the same
>>>>> dataset, so I don't know what can be the reason
>>>>>
>>>>> Thanks for any help!
>>>>> Estrella
>>>>> *
>>>>> * 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/