Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Austin Nichols <austinnichols@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: psmatch2 with the if condition |
Date | Mon, 22 Mar 2010 12:02:34 -0400 |
Nick-- I think the poster is confusing _n1 and _id, which are defined clearly in the help file for -psmatch2-, and simple summary stats would disabuse him of his notion that _id is capturing matches. use http://pped.org/lalonde, clear psmatch2 t age educ if black==1, out(re78) su _* if black==0 su _* if black==1 reg re78 t [aw=_w] On Mon, Mar 22, 2010 at 9:40 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > In effect you raise two new points: > > 1. Whether -psmatch2- promises, implicitly or explicitly, to match > companies [in your case] in a specified subset only with others in the > same subset. > > 2. How to achieve that if that is what you wish. > > On 1, the best answers will come from the program authors, who may or > may not be currently members of this list. > > A solution 2 that is possible: You could temporarily -drop- observations > that you don't want to be included from the dataset. That way, > -psmatch2- will not see any others. > However, I wouldn't implementing that until you have a good answer on 1. > > > I haven't read the -psmatch2- help. But the looping you quote looks > sound, and yours is buggy, so I recommend that you base your code more > closely on that example. > > Nick > n.j.cox@durham.ac.uk > > Roberto Mura > > Nick, > Thank you for your kind reply. The loop is not the main issue. Even > if I do not specify any loop but simply code: > use "C:\AAA.dta", clear > catenate condition1 = country sic2 > gen quotedcondition1=1 if quotedcompany==1 > replace quotedcondition1=0 if quotedcompany==0 & diversification_orig==1 > gen quotednumerator=. > gen quoteddenomenator=. > gen privatenumerator=. > gen privatedenominator=. > egen g=group(condition1) > bysort condition1: gen Ncondition1=_N > > psmatch2 quotedcondition1 if g==1, pscore(size) noreplacement > > I still find that psmatch2 uses companies which do not belong to > group 1 to look for matches. As a matter of fact, it is assigning _id > values outside the range of group 1 (there are just 15 firms in it > but psmatch2 reports values like 877). Also, I am not blaming > psmatch2 for anything and I never said I discovered a bug. I am just > trying to understand what I am doing wrong. Also, please note that my > code is very similar to the one reported in the help of psmatch2 > which I report below for simplicity: > Matching within strata > The following code illustrates how to match within exact cells > and then calculate the average effect for the whole population. > > g att = . > egen g = group(groupvars) > levels g, local(gr) > qui foreach j of local gr { > psmatch2 treatvar varlist if g==`j', out(outvar) > replace att = r(att) if g==`j' > } > sum att > <snip> * * 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/