Practical question regarding the Propensity Score Matching macro (probably an easy question).

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Practical question regarding the Propensity Score Matching macro (probably an easy question).

Joel A.Peterson
Hi all,
I’ve been reading a lot about the ‘Painter-macro propensity score matching procedure’ discussions on here (without necessarily understanding all of statistically and mathematically discussions: I’m an undergrad), and decided to give it a go. I used the SPPSpropensityMatch_example syntax:

/* Core code written by Raynald Levesque */
/* Adapted for use with propensity matching by John Painter Feb 2004*/
/* Program developed and tested with SPSS 11.5 */
/* Procedure will find best match for each treatment case from the control cases, */
/* control case is then removed and not reconsidered for subsequent matches */
/* Order of cases is randomized */

/* Requirement: The number of Treatment cases must be known */

/* Change file path here only  */

DEFINE !pathd() 'c:\temp\' !ENDDEFINE.

* This arrangement gives a good set of data .
* Generate sample data for illustration purposes.
SET SEED=01251701.
NEW FILE.
INPUT PROGRAM.
LOOP id=1 TO 3000.                                              /* generates 300 records */
+ COMPUTE sex=1 + (UNIFORM(1)>.5).                 /* generates 27 treatment cases */
+ COMPUTE age=TRUNC(50+UNIFORM(10)).
+ COMPUTE treatm=UNIFORM(1)>.90.                  /* 1=treatment, 0=potential control */
+ COMPUTE abc=UNIFORM(1)>.5.
+ COMPUTE def=UNIFORM(1)>.4.
+ COMPUTE hij=UNIFORM(1)>.3.
+ END CASE.
END LOOP.
END FILE.

END INPUT PROGRAM.
******************** .
* Perform logistical regression to compute propensity score .
******************* .

LOGISTIC REGRESSION VAR=treatm
  /METHOD=ENTER sex age abc def hij
  /CONTRAST (sex)=Indicator
  /SAVE PRED
  /CRITERIA PIN(.05) POUT(.10) ITERATE(20) CUT(.5) .
RENAME VARIABLES (PRE_1=propen) .


*********************.
* Note number of Treatment cases and place number after MACRO CALL near end ofthis program .
********************* .
FREQUENCIES
  VARIABLES=treatm
  /ORDER=  ANALYSIS .


SAVE OUTFILE=!pathd + "population.sav" .


********************* .
** End Preparation .
********************* .
GET FILE= !pathd + "population.sav".
COMPUTE x = RV.UNIFORM(1,1000000) .
SORT CASES BY treatm(D) propen x.
COMPUTE idx=$CASENUM.
SAVE OUTFILE=!pathd + "mydata.sav".

* Erase the previous temporary result file, if any.
ERASE FILE=!pathd + "results.sav".
COMPUTE key=1.
SELECT IF (1=0).
* Create an empty data file to receive results.
SAVE OUTFILE=!pathd + "results.sav".
exec.

********************************************.
* Define a macro which will do the job.
********************************************.

SET MPRINT=no.
*////////////////////////////////.
DEFINE !match (nbtreat=!TOKENS(1))
!DO !cnt=1 !TO !nbtreat

GET FILE=!pathd + "mydata.sav".
SELECT IF idx=!cnt OR treatm=0.
* Select one treatment case and all control .
DO IF $CASENUM=1.
COMPUTE #target=propen.
ELSE.
COMPUTE delta=propen-#target.
END IF.
EXECUTE.
SELECT IF ~MISSING(delta).
IF (delta<0) delta=-delta.

SORT CASES BY delta.
SELECT IF $CASENUM=1.
COMPUTE key=!cnt .
SAVE OUTFILE=!pathd + "used.sav".
ADD FILES FILE=*
        /FILE=!pathd + "results.sav".
SAVE OUTFILE=!pathd + "results.sav".

************************************************ Match back to original and drop case  from original .
GET FILE= !pathd + "mydata.sav".
SORT CASES BY idx .
MATCH FILES
 /FILE=*
 /IN=mydata
 /FILE=!pathd + "used.sav"
 /IN=used
 /BY idx .
SELECT IF (used = 0).
SAVE OUTFILE=!pathd + "mydata.sav"
 / DROP = used mydata key delta.
EXECUTE.
!DOEND
!ENDDEFINE.
*////////////////////////////////.

SET MPRINT=yes.

**************************.
* MACRO CALL (first insert the number of cases after nbtreat below) .
**************************.
!match nbtreat=27.

* Sort results file to allow matching.

GET FILE=!pathd + "results.sav".
SORT CASES BY key.
SAVE OUTFILE=!pathd + "results.sav".

******************.
* Match each treatment cases with the most similar non treatment case.
* To include additional variables from original file list them on the RENAME subcommand below .
******************.

GET FILE=!pathd + "mydata.sav".
MATCH FILES
 /FILE=*
 /FILE=!pathd + "results.sav"
 /RENAME (idx = d0) (id=id2) (propen=propen2)  (treatm=treatm2) (key=idx)
 /BY idx
 /DROP= d0 x.
FORMATS delta propen propen2 (F10.8).
SAVE OUTFILE=!pathd + "mydata and results.sav".
EXECUTE .
* That's it!.*

So, my probably moronic question is this: How do I use these results to do further analysis? The file ‘mydata and results.sav’ has 27 treatment cases that are matched; but the data doesn’t seem to be matched on the propensity scores as the gender distribution on the ‘treatm’ variable is exactly the same as in the ‘population.sav’ file which hasn’t been matched. So, what do I do next to get the data actually matched on the propensity scores?  

This is an easy question compared to what is normally posted in this forum, but I really would appreciate any answer!

Thanks,
Jane