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]

From |
"Garth Rauscher" <garthr@uic.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: psmatch2-identifying matched pairs |

Date |
Fri, 2 Apr 2010 13:57:53 -0500 |

I managed to figure out how to identify and subset my data to include only the matched pairs created by psmatch2. What was (and still is) confusing me was that if I included the ate option, some of the matched pairs were "broken" and a member of the pair was no longer identified as such. I don't understand why this happened, but, nonetheless for my purposes, leaving off the ate option allowed the following code to work: --------------------------------------------------------------------- psmatch2 path2, pscore(p_prodterms) outcome(binarystage) caliper(.001) noreplace neighbor(1) gen pair = _id if _treated==0 replace pair = _n1 if _treated==1 bysort pair: egen paircount = count(pair) drop if paircount !=2 --------------------------------------------------------------------- This code creates the variable pair that identifies the matched pairs. I forgot to mention- Hat tip to the authors of psmatch2 for providing this partial solution... ------------------------------------------------------------------------ The following code: gen pair = _id if _treated==0 replace pair = _n1 if _treated==1 creates a variable that identifies the matched pairs but also includes those within the region of support who are not included in a matched pair. I cannot figure out how to drop those observations that are not part of a matched pair. Any help would be appreciated. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Wednesday, March 31, 2010 8:13 AM To: statalist@hsphsun2.harvard.edu Subject: st: RE: psmatch2-identifying matched pairs I don't know anything about -psmatch2- (which is a user-written program from SSC, as should be explained). But the problem may be soluble by -egen, group()-. A more general discussion is given by SJ-7-4 dm0034 . . . Stata tip 52: Generating composite categorical variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/07 SJ 7(4):582--583 (no commands) tip on how to generate categorical variables using tostring and egen, group() Nick n.j.cox@durham.ac.uk Garth Rauscher I apologize if this has been answered before but I could not find the solution in the archives. When I perform 1-1 matching using psmatch2, several new variables are added to my dataset. Among these are _id, which is a unique identifier for each observation, and _n1, which identifies the _id for the observation in the matched pair. I'd like to be able to define a new variable that uniquely identifies each matched pair. In other words if there are 100 observations making 50 matched pairs, there are 100 unique values of _id and 100 unique values of _n1. I'd like a variable with 50 unique values, one for each matched pair. Stata doesn't appear to create this variable. Having this variable would enable me to conduct stratified analyses (stratifying on matched pairs) outside of what is provided by psmatch2. Given _id and _n1 there is probably a way to do this but it is beyond my skill set. I'd appreciate if there are any ideas out there as to how to go about defining this variable. * * 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/ * * 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/ * * 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/ * * 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/

- Prev by Date:
**Re: st: issue in data analysis** - Next by Date:
**Re: st: issue in data analysis** - Previous by thread:
**st: RE: RE: psmatch2-identifying matched pairs** - Next by thread:
**st: documentation Stata tips : any wrong with counting on googling?** - Index(es):