首先,通过
des
命令了解一下数据基本情况。由下文可以看出,该数据共有 3100 个观测值,并且在本文中,我们将
first
作为处理变量,将
ppvt
作为结果变量。
. use nlsy.dta, clear
. des
Contains data from nlsy.dta obs: 3,100 vars: 29 20 Oct 2004 15:03 ------------------------------------------------------------ value variable label variable label ------------------------------------------------------------ row_names hispanic hispanic hispanic black black black white white white momrace momrace mother's race female female female b_marr b_marr mom married at birth? pr0 pr0 was household in poverty the year before child was born? lths mom's ed is less than high school hs mom is hs grad ltcoll mom attended some college college mom finished college momed momed mom's education level when she gave birth lnfinc_a0 logged family income in the year before the child was born age child's age (in months) on 1/1/90 momage afqt mom's score on the armed forces qualifying test brthwt birthweight of child (oz) brorddum brordum first born? preterm weeks preterm rmomwk rmomwk did respondent's momther work while she was in high school? work treat did mom work in the first 3 years? ppvt peabody picture vocab test score at 36 months piatm56 score on the piat math component at age 5 or 6 piatm78 score on the piat mathcomponent at age 7 or 8 piatr56 score on the piat reading component at age 5 or 6 piatr78 score on the piat reading component at age 7 or 8 notfirst first ------------------------------------------------------------ Sorted by:
然后,将变量
ppvt
对全局暂元
x
进行 Logit 回归,并计算 pscore 值。
global x lths hs ltcoll college lnfinc_a0 age momage afqt brthwt preterm //设定全局变量 logit ppvt $x //进行 logit 回归 predict pscore, p //计算 pscore 值
最后,使用
iematch
命令完成匹配。值得注意的是,为了保证结果的可重新,我们需要设定
set seed 12345
,以及使用
iematch
的
seedok
选项。同时,在
iematch
命令语句中,
grpdummy(first) matchvar(pscore)
表示根据
pscore
值,为
first
等于 1 的组中观测值匹配
first
等于 0 的组中观测值。
maxmatch(3)
表示目标观测值允许匹配的最大观测值数为 3。
Observations are excluded from the matching for the following reasons: 285 observation(s) were excluded due to missing value in matchvar(pscore). max count
Observations are excluded from the matching for the following reasons: 1498 observation(s) were excluded in if/in: (if white == 1). 203 observation(s) were excluded due to missing value in matchvar(pscore). max count