Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: st: 1:1 match and identifying result


From   Peter Hofmann <peter.uniseminar@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: Re: st: 1:1 match and identifying result
Date   Fri, 27 Apr 2012 19:13:58 +0200

Dear Stas
Thank you for the hints. Results look better now.
But I have one problem now using your command:
bysort same_years (price ) : gen byte match_prev = reldif( price,
price[_n-1] ) < 0.25 & (treated + treated[_n-1] == 1)
It is possible that I sort three (and more) treated following each
other line by line, then the middle one(s) of the observations would
not find a match because the line above and beneath include a treated
obs. (the same for matched obs)

But it is possible that two lines above or beneath there is a fine
match on price for this treated, but I only check the first line above
and beneath, right??
It would look like this:
matched1 price1
treated1   price1
treated2   price1
treated3   price1
matched2 price1
matched3 price1
matched4 price1
matched5 price2
.....

Thank you for clarifying this :)
Regards
Peter Hofmann

@Steve: thanks, I checked on cem already, did not work for me.


On Thu, Apr 26, 2012 at 4:17 PM, uniseminar uniseminar
<peter.uniseminar@gmail.com> wrote:
> Hi all,
>
> My - beginners - problem concerns the 1:1 matching of a treated group
> of companies to an untreated by three variables. Two of the
> variables need to be exact matches and one should be in a range of 25%
> difference. All numeric: founding year, target year, sales.
> my data looks similar to this:
> Company1 target-year1 sales1 founding-year ID1 ...
> Company1 target-year2 sales2 founding-year ID2 ...
> ...
> Company2 target-year1 sales1 founding-year IDx+3...
> Company2 target-year2 sales2 founding-year IDx+4...
> ....
>
> I tried to work on several matching procedures with merge, vmatch,
> psmatch2 nnmatch etc. Neither was suitable for me...
> vmatch was matching the three variables, but does not give me the
> unique identifier of the matched company next to the treated company.
> Further question: If I would receive the ID of the matched comp in the
> line of the treated comp(thats the goal), how can I make sure to
> compare these two? Something like: if ID of matched is found under
> another variable in another line of treated comps then subtract sales
> treated from sales matched...
>
> Hopefully this is understandable...!?

Brute force solution that employs the exact equality:

sysuse auto
ren foreign treated
ren mpg year1
ren head year2
replace year2 = 10+2*year2
replace year1 = floor(year1/2)
egen same_years = group( year1 year2 )
bysort same_years (price ) : gen byte match_prev = reldif( price,
price[_n-1] ) < 0.25 & (treated + treated[_n-1] == 1)
bysort same_years (price ) : gen byte match_next = reldif( price,
price[_n+1] ) < 0.25 & (treated + treated[_n+1] == 1)
list if match_prev == 1 | match_next == 1 , sepby(same)

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index