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: Re: Analyzing time series data on prices by districts & markets


From   Chris Parker <[email protected]>
To   [email protected]
Subject   Re: st: Re: Analyzing time series data on prices by districts & markets
Date   Tue, 14 Jun 2011 09:20:40 +0100

Hi Partho,

Yes - the second and third parts are both calculated incorrectly. The
issue is that -egen, tag- only tags one instance of a district. On a
given date the "tagged" observation may or may not be considered. This
should give you the correct results.

egen districttag = tag(district)
bysort state: egen numdistricts = total(districttag)
egen districtdatetag = tag(district date)
bysort state date: egen districtswithprices = total(districtdatetag)
gen percentdistrictswithprices = districtswithprices/numdistricts

egen statetag = tag(state)
egen numstates = total(statetag)
egen statedatetag = tag(state date)
bysort date: egen stateswithprices = total(statedatetag)
gen percentstateswithprices = stateswithprices/numstates

Sorry for sending you down the wrong path before!

Chris

Chris Parker

________________________________

PhD Candidate | Management Science & Operations
London Business School | Regent's Park | London NW1 4SA | United Kingdom
Direct line +44 (0)20 7000 8816 | Email [email protected]

On Tue, Jun 14, 2011 at 7:54 AM, Partho Sarkar <[email protected]> wrote:
>
> Hello Chris,
>
> The code worked fine, except for this section:
>
> The number of districts in each state for which prices are
> reported, versus the total no. of districts in that state
>
> egen districttag = tag(district)
> bysort state: egen numdistricts = total(districttag)
> bysort state date: egen districtswithprices = total(districttag)
> gen percentdistrictswithprices = districtswithprices/numdistricts
>
>  I am getting many false zero values for districtswithprices, as seen
> in this extract from the output:
>
> The headers for the 7 columns: reportdate       state mandi
> district        mandisopen      numdistricts    districtswithprices
>
> 06/01/09        Andhra  Addank  Prakas  3       8       6
> 06/01/09        Andhra  Bhimav  West G  2       8       6
> 06/01/09        Andhra  Kothav  Vizian  2       8       6
> 06/02/09        Andhra  Atmaku  Kurnoo  1       8       0
> 06/02/09        Andhra  Kondap  Prakas  2       8       0
> 06/02/09        Andhra  Satten  Guntur  1       8       0
>
>
> Clearly, if mandisopen>0, districtswithprices =0 can't be right.
> Wonder if you can spot the problem with the code without too much more
> trouble.
>
> And thank you, Dr. Cox- I had a glance at the article, and will go
> through it carefully- it looks quite insightful.
>
> Regards,
>
> Partho
>
> Partha S. Sarkar
> *
> *   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/
>
> ______________________________________________________________________
>
> This email has been scanned by the MessageLabs Email Security System
> on behalf of the London Business School community.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________

*
*   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/


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