Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Re: Tactical looping


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: RE: Re: Tactical looping
Date   Mon, 26 Jan 2004 19:21:23 -0500

This probably should have gone off list at this point..

The command :
assert _merge==3

was merely included to be sure that every election has results in the top3
(or top4) file -- it was thrown in out of habit for when I expect a
perfectly matching merge.  The value 3 indicates that a merge matched in
both files (see help merge), it has nothing to do with whether you are
looking for the top 3 or top 4.

Why did this happen?  Well, now that we included dropping observations with
missing values, we could end up with some elections having no votes.
Apparently this was true for one election --that's why assert said "1
contradiction", 1 election did not have any observations left when missing
data were dropped.

You should drop the assert line (it is no longer needed if you accept that
some elections have no votes) and then check the results for the one
election with no top3 or top4 results if you want to see if there's a data
error.

Michael Blasnik
[email protected]

----- Original Message ----- 
From: "Clive Nicholas" <[email protected]>

> Michael Blasnik wrote:
>
> > I think you could just insert :
> >
> > drop if pc==.
> >
> > right after the 1st reshape command, that way missing vote percents
won't
> > count as the highest.  Another approach would be to insert
> >
> > replace pc=0 if pc==.
> >
> > in the same spot, although this could conceivably declare a party in the
> > top
> > 3 if 0% is in the top 3 in any election.  Also, I just realized that the
> > approach I showed will split ties randomly so if you have any ties, you
> > may
> > need to decide what to do about them.
>
> It almost worked. When I dropped this into the code, thus:
>
> reshape long @lag, i(id) j(party) string
> drop if lag==.
> bysort id (lag): gen byte rank=_N-_n+1
> keep if rank<5
> keep id party rank
> reshape wide  party, i(id) j(rank)
> sort id
> save top4
> use "C:\DATA\pool7901.dta"
> sort id
> merge id using top4
> assert _merge==3
>
> I got an error after the final command
>
> . assert _merge==3
> 1 contradiction in 3457 observations
> assertion is false
> r(9);
>
> Thinking this might be because I'm specifying 4 parties and not 3, I
> changed this to -assert _merge==4-. But this produced:
>
> . assert _merge==4
> 3457 contradiction in 3457 observations
> assertion is false
> r(9);
>
> However, quickly sampling the orderings showed them to be correct (but I
> can't be sure that all of them are). Thus, is this error message worth
> worrying about?
>
> CLIVE NICHOLAS        |t: 0(44)191 222 5969


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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index