Dear Statalist members,

I have the following problem and cant find an answer by myself: I want to run a propensity score weighted regression by using the command teffects psmatch to estimate the propensity scores.

For the default value of nearest neighbor = 1 it is no problem since the help of the guide http://www.ssc.wisc.edu/sscc/pubs/stata_psmatch.htm. But if I want to estimate the propensity scores with nearest neighbor values of 3 or 5 I dont know how to adjust the algorithm:

teffects psmatch (y) (treatment x x x x x x), atet gen(match) nn(3 or 5)

predict ps0 ps1, ps

predict y0 y1, po

*Because observation 1 is in the control group, y0 contains its observed value of y. y1 is the observed value of y for observation X's match, observation XX

predict te

*The treatment effect is simply the difference between y1 and y0. You could calculate the ATE yourself (but emphatically not its standard error) with:

sum te

*and the ATET with:

sum te if treatment==1

*regression preparation

gen ob=_n //store the observation numbers for future use

save fulldata,replace // save the complete data set

keep if treatment // keep just the treated group

keep match1 // keep just the match1 variable (the observation numbers of their matches)

bysort match1: gen weight=_N // count how many times each control observation is a match

by match1: keep if _n==1 // keep just one row per control observation

ren match1 ob //rename for merging purposes

merge 1:m ob using fulldata // merge back into the full data

replace weight=1 if gdum // set weight to 1 for treated observations

regress y treatment x x x xx x x x x z z z [fweight=weight], robust

so how must the middle part be modified so that the weights are adjusted to the nn(3 or 5) option?

Thank you very much!

Cheers,

Kurt

I have the following problem and cant find an answer by myself: I want to run a propensity score weighted regression by using the command teffects psmatch to estimate the propensity scores.

For the default value of nearest neighbor = 1 it is no problem since the help of the guide http://www.ssc.wisc.edu/sscc/pubs/stata_psmatch.htm. But if I want to estimate the propensity scores with nearest neighbor values of 3 or 5 I dont know how to adjust the algorithm:

teffects psmatch (y) (treatment x x x x x x), atet gen(match) nn(3 or 5)

predict ps0 ps1, ps

predict y0 y1, po

*Because observation 1 is in the control group, y0 contains its observed value of y. y1 is the observed value of y for observation X's match, observation XX

predict te

*The treatment effect is simply the difference between y1 and y0. You could calculate the ATE yourself (but emphatically not its standard error) with:

sum te

*and the ATET with:

sum te if treatment==1

*regression preparation

gen ob=_n //store the observation numbers for future use

save fulldata,replace // save the complete data set

keep if treatment // keep just the treated group

keep match1 // keep just the match1 variable (the observation numbers of their matches)

bysort match1: gen weight=_N // count how many times each control observation is a match

by match1: keep if _n==1 // keep just one row per control observation

ren match1 ob //rename for merging purposes

merge 1:m ob using fulldata // merge back into the full data

replace weight=1 if gdum // set weight to 1 for treated observations

regress y treatment x x x xx x x x x z z z [fweight=weight], robust

so how must the middle part be modified so that the weights are adjusted to the nn(3 or 5) option?

Thank you very much!

Cheers,

Kurt

## Comment