Sie sind auf Seite 1von 2

Stata Code for Propensity Score Analysis (Using user-written commands and commands from Stata 13)

Calculate propensity score


and perform initial balance
assessment
Try a different specification of
the propensity score
Match or weight sample by
propensity score

Melissa Garrido, PhD

pscore treatment covariate1 covariate2 covariate#, pscore(pc_pscore) blockid(pc_block) detail


psgraph, treated(treatment)pscore(pc_pscore)
drop pc_pscore pc_block
pscore treatment covariate1 covariate2 covariate#, pscore(pc_pscore) blockid(pc_block) detail

Nearest neighbor or caliper match


qui psmatch2 treatment, outcome(outcomevar) pscore(pc_pscore) caliper(.013828) neighbor(1)

Kernel weight
qui psmatch2 treatment, kernel outcome(outcomevar) pscore(pc_pscore)

Inverse Probability of Treatment Weight


qui dr outcomevar treatment covariate 1 covariate #, genvars
egen sumofweights = total(iptwt)
gen norm_weights = iptwt/sumofweights

Balance tests in matched or


weighted sample

Matched or kernel weighted


pstest covariate1..covariate#, treated(treatment) both

IPTW
pbalchk treatment covariate1 covariate#, wt(norm_weights)

Graphs
qqplot covariate_treated covariate_comparison if _weight==1
twoway kdensity covariate if treatment [aweight= norm_weights] || kdensity covariate if
!treatment [aweight= norm_weights]

Calculate treatment effects


with appropriate standard
errors

Matched sample
teffects psmatch(outcome) (treatment covariate1 covariate#), atet nneighbor(#) caliper(#)

IPTW sample
teffects ipw (outcome)(treatment covariate1 covariate#)

Kernel weighted sample


IPTW doubly robust
estimation
Multi-valued categorical
treatment
Generalized propensity score
for continuous treatment

After running pscore, get treatment effects from psmatch2- and standard errors with:
bs "psmatch2 treatment, kernel outcome(outcomevar) pscore(pc_pscore)" "r(att)", reps(#) dots
teffects ipwra (outcome covariate1 covariate#)(treatment covariate1 covariate#)
teffects ipwra (outcome covariate1 covariate#)(treatment covariate1 covariate#),
atet control(treatmentlevel0) tlevel (treatmentlevelB)
doseresponse covariate1 covariate#, outcome(outcomevar) t(treatmentvar) gpscore(newpscorevar)
predict(hat_treat) sigma(hat_sd) cutpoints(cut) index(mean) nq_gps(#)
dose_response(newdoseresponsevar) test(Bayes_factor) detail

Becker, S., and A. Ichino. 2002. Estimation of Average Treatment Effects Based on Propensity
Scores. The Stata Journal 2(4): 358-377.
Leuven, E., and B. Sianesi. 2003. PSMATCH2: Stata Module to Perform Full Mahalanobis and
Propensity Score Matching, Common Support Graphing, and Covariate Imbalance Testing, version 4.0.6. Available at:
http://ideas.repec.org/c/boc/bocode/s432001.html.
Lunt, M. PBALCHK: Checking Covariate Balance. Available at:
http://personalpages.manchester.ac.uk/staff/mark.lunt/propensity.html.
StataCorp. 2013. Stata 13 Base Reference Manual. College Station, TX: Stata Press.
StataCorp. 2013. Stata Statistical Software: Release 13. College Station, TX: StataCorp LP.

Das könnte Ihnen auch gefallen