The PSMATCH Procedure

Example 95.4 Greedy Nearest Neighbor Matching

(View the complete code for this example.)

This example performs greedy matching in a propensity score analysis.

At the completion of a school year, a school administrator asks whether taking a music class causes an improvement in the grade point averages (GPAs) of students. The reasoning behind this question is that learning to read and perform music might improve general reading ability, concentration, and memory.

The data set School contains information about students that is available at the end of the school year. StudentID is the student identification number, Music indicates whether the student took a music class, Gender provides the gender of the student, and Absence is the percentage of absences. For simplicity, this example uses only three covariates (Music, Gender, and Absence), but in practice a propensity score analysis often involves many more covariates.

Output 95.4.1 lists the first 10 observations.

Output 95.4.1: Input School Data Set

First 10 Observations of the Input Music Data Set

ObsStudentIDMusicGenderAbsence
118NoFemale3.71200
261NoMale2.07552
395NoFemale2.53865
441NoMale3.00637
519YesFemale0.08081
651NoFemale1.20229
7110NoMale2.20710
887NoFemale2.30150
9103NoFemale3.08102
10175NoFemale1.12169


In this example, the outcome data (GPAs) for the students happen to be available at the time of the propensity score analysis, but the recommended practice is not to use the outcome values in the propensity score analysis (Stuart 2010, p. 2). Instead, the response variable is added to the output data set created by the PSMATCH procedure; that output data set consists of matched observations that are subsequently used in an outcome analysis.

The following statements invoke the PSMATCH procedure and request greedy nearest neighbor matching to sequentially match each observation for students in the treatment group (those who took music) with one observation for students in the control group (those who did not take music):

ods graphics on;
proc psmatch data=School region=treated;
   class Music Gender;
   psmodel Music(Treated='Yes')= Gender Absence;
   match method=greedy(k=1) exact=Gender caliper=0.5;
   assess lps var=(Gender Absence) / plots=all weight=none;
   output out(obs=match)=OutEx4 matchid=_MatchID;
run;

The CLASS statement specifies the classification variables. The PSMODEL statement specifies the logistic regression model that creates the propensity score for each student, which is the probability that the student enrolled in the music class. The Music variable is the binary treatment indicator variable and TREATED='Yes' identifies Yes as the treated group. The Gender and Absence variables are included in the model because they are believed to be related to enrolling in the music class.

The REGION= option specifies an interval region of propensity scores such that only observations that have propensity scores in the region are used in stratification and matching. Because the MATCH statement is also specified, the REGION=TREATED option requests that only observations whose propensity scores lie in the range that corresponds to observations in the treated group be used for matching. By default, the region is extended by 0.25 times the pooled estimate of the common standard deviation of the logit of the propensity score statistic.

The MATCH statement requests matching and specifies the criteria for matching. The STAT=LPS option (which is the default) requests that the logit of the propensity score be used in computing differences between pairs of observations. The METHOD=GREEDY(K=1) option requests greedy nearest neighbor matching in which one control unit is matched with each unit in the treated group such that the matching produces the smallest within-pair difference among all available pairs with this treated unit. The EXACT=GENDER option forces the treated unit and its matched control unit to have the same value of the Gender variable. The CALIPER=0.5 option specifies the caliper requirement for matching: units are matched only if the difference in the logits of the propensity score for pairs of units from the two groups is less than or equal to 0.5 times the pooled estimate of the common standard deviation of the logits of the propensity scores.

The "Data Information" table, which is produced by the PSMATCH procedure and shown in Output 95.4.2, displays information about the input and output data sets, the numbers of observations in the treated and control groups, the lower and upper limits for the propensity score support region, and the numbers of observations in the treated and control groups that fall within the support region. Of the 140 observations in the control group, 132 fall within the support region.

Output 95.4.2: Data Information

The PSMATCH Procedure

Data Information
Data SetWORK.SCHOOL
Output Data SetWORK.OUTEX4
Treatment VariableMusic
Treatment GroupYes
All Obs (Treatment)60
All Obs (Control)140
Support RegionExtended Treatment Group
Lower PS Support0.079975
Upper PS Support0.530932
Support Region Obs (Treatment)60
Support Region Obs (Control)132


The "Propensity Score Information" table in Output 95.4.3 displays summary statistics for the treatment and control groups, which are computed for all observations, support region observations, and matched observations.

Output 95.4.3: Propensity Score Information

Propensity Score Information
ObservationsTreated (Music = Yes)Control (Music = No)
NMeanStd DevMinimumMaximumNMeanStd DevMinimumMaximum
All600.3471430.0961840.0928310.4901911400.2797960.1249970.0264650.488875
Region600.3471430.0961840.0928310.4901911320.2940240.1139970.0833460.488875
Matched600.3471430.0961840.0928310.490191600.3401880.0984820.0929630.488875


The "Matching Information" table in Output 95.4.4 displays the matching criteria, the number of matched sets, the numbers of matched observations in the treated and control groups, and the total absolute difference in the logit of the propensity score for all matches.

Output 95.4.4: Matching Information

Matching Information
Difference StatisticLogit of Propensity Score
MethodGreedy Matching
Control/Treated Ratio1
OrderDescending
Caliper (Logit PS)0.326257
Matched Sets60
Matched Obs (Treated)60
Matched Obs (Control)60
Total Absolute Difference2.943871


The ASSESS statement produces tables and plots that summarize differences in the specified variables between treated and control groups for all observations, for the support region observations, and for the matched observations. You can use these results to assess how well matching achieves a balance in the distributions of these variables. As requested by the LPS and VAR= options, the variables are the logit of propensity score and the covariates Gender and Absence. The WEIGHT=NONE option suppresses the display of differences for weighted matched observations. For a matching of one control unit to each treated unit, the weights are all 1 for matched treated and control units, and the results are identical for the weighted matched observations and the matched observations.

The "Standardized Variable Differences" table in Output 95.4.5 displays standardized differences between the treated and control groups, which are computed for all observations, support region observations, and matched observations. For the binary classification variable (Gender), the computed difference is in the proportion of the first ordered level (Female).

Output 95.4.5: Standardized Differences

The PSMATCH Procedure

Standardized Variable Differences (Treated - Control)
Variable Standardized Mean Difference 
Mean DifferenceDivisorMean DifferencePercent ReductionVariance Ratio
All ObsRegion ObsMatched ObsAll ObsRegion ObsMatched ObsRegion ObsMatched ObsAll ObsRegion ObsMatched Obs
LPS0.4068090.2841630.0326790.6525140.6234490.4354890.05008130.1591.970.38100.61350.9696
Absence-0.697568-0.485721-0.0577591.136945-0.613546-0.427216-0.05080230.3791.720.35500.55600.9375
Gender-0.045238-0.03484800.496344-0.091143-0.070210022.97100.001.02081.01441.0000


The standardized mean differences are significantly reduced in the matched observations, and the largest of these differences is 0.0508 in absolute value, which is less than the recommended upper limit of 0.25 (Rubin 2001, p. 174; Stuart 2010, p. 11). The variance ratios between the two groups are between 0.9375 1 and 1 for all variables in the matched observations, which is within the recommended range of 0.5 to 2. Because both EXACT=GENDER and METHOD=GREEDY are specified in the MATCH statement, the standardized difference for Gender is 0 in the matched observations.

When ODS Graphics is enabled and you specify PLOTS=ALL, the PSMATCH procedure uses ODS Graphics to create all applicable plots. Output 95.4.6 displays a plot of the standardized differences in Gender, Absence, and the logit propensity score for all observations, observations in the support region, and matched observations.

Output 95.4.6: Standardized Differences Plot

Standardized Differences Plot


Output 95.4.7 displays box plots that compare the distributions of the logit propensity score for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Note that the two distributions are well-balanced for matched observations.

Output 95.4.7: LPS Box Plot

LPS Box Plot


Output 95.4.8 displays box plots that compare the distributions of Absence for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Again, note that the two distributions are well-balanced for matched observations.

Output 95.4.8: Absence Box Plot

Absence Box Plot


Output 95.4.9 displays bar charts that compare the distributions of Gender for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Again, note that the two distributions are well-balanced for matched observations.

Output 95.4.9: Gender Bar Chart

Gender Bar Chart


Output 95.4.10 displays a cloud plot that compares the values of the logit propensity score LPS for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations. The points are jittered in the vertical direction to avoid overlap.

Output 95.4.10: LPS Cloud Plot

LPS Cloud Plot


Output 95.4.11 displays a cloud plot that compares the values of Absence for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations.

Output 95.4.11: Absence Cloud Plot

Absence Cloud Plot


Output 95.4.12 displays a cloud plot that compares the values of Gender for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations.

Output 95.4.12: Gender Cloud Plot

Gender Cloud Plot


If you are not satisfied with the variable balance, you can do one or more of the following until you are satisfied: you can select another set of variables to fit the propensity score model, you can modify the matching criteria, or you can choose another matching method.

The OUT(OBS=MATCH)=OutEx4 option in the OUTPUT statement creates an output data set, OutEx4, that contains the matched observations. The following statements list the 10 observations in OutEx4 that have lowest propensity scores, as shown in Output 95.4.13:

proc sort data=OutEx4 out=OutEx4a;
   by _PS_;
run;

proc print data=OutEx4a(obs=10);
   var StudentID Music Gender Absence _PS_ _MATCHWGT_ _MatchID;
run;

Output 95.4.13: Output Data Set with Multiple Matches

ObsStudentIDMusicGenderAbsence_PS__MATCHWGT__MatchID
133YesFemale3.503130.09283160
282NoFemale3.500360.09296160
367YesFemale2.713520.13790159
495NoFemale2.538650.15009159
547NoFemale2.498660.15300158
64YesFemale2.494250.15333158
737NoMale2.939550.15549157
8152YesMale2.881020.15988157
920YesFemale2.127510.18224156
10121NoFemale2.122390.18267156


By default, the output data set includes the variable _PS_ (which provides the propensity score) and the variable _MATCHWGT_ (which provides matched observation weights). The MATCHID=_MatchID option creates a variable named _MatchID that identifies the matched sets of observations.

If you assume that no other confounding variables are associated with both the GPA and the music class indicator Music, you can add the GPAs for the students to the data set OutEx4 and perform an outcome analysis of GPA on this data set to estimate the music class effect.