stata怎么看变量类型(stata怎么看数据类型)
处理效应模型
一.处理效应模型命令简介
原始命令为:**treatreg has been renamed to etregress.
现在更新为:etregress
etregress语法格式为:
Basic syntax *基础格式
etregress depvar [indepvars], treat(depvar_t = indepvars_t) [twostep|cfunction]
Full syntax for maximum likelihood estimates only ML估计格式
etregress depvar [indepvars] [ if] [ in] [weight], treat(depvar_t = indepvars_t [, noconstant]) [etregress_ml_options]
Full syntax for two-step consistent estimates only\2阶段一致估计\
etregress depvar [indepvars] [ if] [ in], treat(depvar_t = indepvars_t [, noconstant]) twostep [etregress_ts_options]
Full syntax for control-function estimates only控制函数估计格式
etregress depvar [indepvars] [ if] [ in], treat(depvar_t = indepvars_t [, noconstant]) cfunction [etregress_cf_options]
展开全文
选项介绍:
depvar :结果变量。
indepvars :直接影响结果变量depvar的自变量。
treat(depvar_t = indepvars_t [, noconstant]) 处理方程
noconstant :不包含截距项。
constraints(constraints) :应用线性约束
twostep表示使用两步法,默认MLE
first表示汇报第一阶段的Probit回归结果
depvar :结果变量。
indepvars :直接影响结果变量depvar的自变量。
treat(depvar_t = indepvars_t [, noconstant]) 处理方程
noconstant :不包含截距项。
constraints(constraints) :应用线性约束
twostep表示使用两步法,默认MLE
first表示汇报第一阶段的Probit回归结果
首先调用数据* union3,*
use union3
数据结构如下:
desc
结果为:
webuse union3
(National Longitudinal Survey. Young Women 14-26 years of age in1968)
. desc
Contains data from http://www.stata-press.com/data/r14/union3.dta
obs: 1,693 National Longitudinal Survey. Young
Women 14-26 years of age in1968
vars: 24 11 Mar 2014 09:47
size: 77,878
--------------------------------------------------------------------------------------
storage display value
variable name typeformat label variable label
--------------------------------------------------------------------------------------
idcode int %8.0g NLS ID
year byte %8.0g interview year
birth_yr byte %8.0g birth year
age byte %8.0g age incurrent year
race byte %8.0g racelbl race
msp byte %8.0g 1 ifmarried, spouse present
nev_mar byte %8.0g 1 ifnever married
grade byte %8.0g current grade completed
collgrad byte %8.0g 1 ifcollege graduate
not_smsa byte %8.0g 1 ifnot SMSA
c_city byte %8.0g 1 ifcentral city
south byte %8.0g 1 ifsouth
ind_code byte %8.0g industry of employment
occ_code byte %8.0g occupation
union byte %8.0g 1 ifunion
wks_ue byte %8.0g weeks unemployed last year
ttl_exp float%9.0g total work experience
tenure float%9.0g job tenure, inyears
hours int %8.0g usual hours worked
wks_work int %8.0g weeks worked last year
ln_wage float%9.0g ln(wage/GNP deflator)
wage double %10.0g real wage
black float%9.0g race black
smsa byte %8.0g 1 ifSMSA
--------------------------------------------------------------------------------------
Sorted by: idcode year
下面使用Obtain full ML estimates****ML估计格式****
其中wage为工资,age grade smsa black tenure这些分别为自变量,而south black tenure为影响union的变量,union为处理变量
. etregress wage age grade smsa black tenure, treat(union = south black tenure)
Iteration 0: loglikelihood = -3140.811
Iteration 1: loglikelihood = -3053.6629
Iteration 2: loglikelihood = -3051.5847
Iteration 3: loglikelihood = -3051.575
Iteration 4: loglikelihood = -3051.575
Linear regression with endogenous treatment Number of obs = 1,210
Estimator: maximum likelihood Wald chi2(6) = 681.89
Log likelihood = -3051.575 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
wage |
age | .1487409 .0193291 7.70 0.000 .1108566 .1866252
grade | .4205658 .0293577 14.33 0.000 .3630258 .4781058
smsa | .9117044 .1249041 7.30 0.000 .6668969 1.156512
black | -.7882471 .1367078 -5.77 0.000 -1.05619 -.5203048
tenure | .1524015 .0369596 4.12 0.000 .0799621 .2248409
1.union | 2.945815 .2749621 10.71 0.000 2.4069 3.484731
_cons | -4.351572 .5283952 -8.24 0.000 -5.387208 -3.315936
-------------+----------------------------------------------------------------
union |
south | -.5807419 .0851111 -6.82 0.000 -.7475566 -.4139271
black | .4557499 .0958042 4.76 0.000 .2679771 .6435226
tenure | .0871536 .0232483 3.75 0.000 .0415878 .1327195
_cons | -.8855758 .0724506 -12.22 0.000 -1.027576 -.7435753
-------------+----------------------------------------------------------------
/athrho | -.6544347 .0910314 -7.19 0.000 -.832853 -.4760164
/lnsigma | .7026769 .0293372 23.95 0.000 .645177 .7601767
-------------+----------------------------------------------------------------
rho | -.5746478 .060971 -.682005 -.4430476
sigma | 2.019151 .0592362 1.906325 2.138654
lambda | -1.1603 .1495097 -1.453334 -.8672668
------------------------------------------------------------------------------
LR testof indep. eqns. (rho = 0): chi2(1) = 19.84 Prob > chi2 = 0.0000
.
Obtain two-step consistent estimates 2阶段一致估计
etregress wage age grade smsa black tenure, treat(union = south black tenure) twostep
. etregress wage age grade smsa black tenure, treat(union = south black tenure) twoste
> p
Linear regression with endogenous treatment Number of obs = 1210
Estimator: two-step Wald chi2(8) = 566.56
Prob > chi2 = 0.0000
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
wage |
age | .1543231 .0194903 7.92 0.000 .1161227 .1925234
grade | .4225025 .029014 14.56 0.000 .3656362 .4793689
smsa | .8628628 .1285907 6.71 0.000 .6108297 1.114896
black | -.9206944 .1774617 -5.19 0.000 -1.268513 -.572876
tenure | .1003226 .051879 1.93 0.053 -.0013584 .2020037
union | 4.563859 1.006459 4.53 0.000 2.591236 6.536483
_cons | -4.670352 .5401517 -8.65 0.000 -5.72903 -3.611674
-------------+----------------------------------------------------------------
union |
south | -.4895032 .0933276 -5.24 0.000 -.6724221 -.3065844
black | .4397974 .0972261 4.52 0.000 .2492377 .6303572
tenure | .0997638 .0236575 4.22 0.000 .053396 .1461317
_cons | -.9679795 .0746464 -12.97 0.000 -1.114284 -.8216753
-------------+----------------------------------------------------------------
hazard |
lambda | -2.093313 .5801968 -3.61 0.000 -3.230478 -.9561486
-------------+----------------------------------------------------------------
rho | -0.89172
sigma | 2.3475104
------------------------------------------------------------------------------
调用数据drugexp use drugexp
Obtain control-function estimates forpotential-outcome model**控制函数估计格式**
etregress lndrug chron age lninc, treat(ins=age married lninc work) poutcomes cfunction
. webuse drugexp
(Presciption drug expenditures)
. etregress lndrug chron age lninc, treat(ins=age married lninc work) poutcomes cfunct
> ion
Iteration 0: GMM criterion Q(b) = 2.279e-15
Iteration 1: GMM criterion Q(b) = 4.501e-30
Linear regression with endogenous treatment Number of obs = 6,000
Estimator: control-function
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
lndrug |
chron | .4671725 .0319731 14.61 0.000 .4045064 .5298387
age | .1021359 .00292 34.98 0.000 .0964128 .1078589
lninc | .0550672 .0225036 2.45 0.014 .0109609 .0991735
1.ins | -.8598836 .3483648 -2.47 0.014 -1.542666 -.1771011
_cons | 1.665539 .2527527 6.59 0.000 1.170153 2.160925
-------------+----------------------------------------------------------------
ins |
age | .021142 .0022961 9.21 0.000 .0166416 .0256424
married | .084631 .0359713 2.35 0.019 .0141286 .1551334
lninc | .1023032 .0225009 4.55 0.000 .0582022 .1464041
work | .288418 .0372281 7.75 0.000 .2154522 .3613837
_cons | -.622993 .108795 -5.73 0.000 -.8362273 -.4097587
-------------+----------------------------------------------------------------
/athrho0 | .4035094 .1724539 2.34 0.019 .0655059 .7415129
/lnsigma0 | .3159269 .0500476 6.31 0.000 .2178353 .4140184
/athrho1 | .7929459 .2986601 2.66 0.008 .2075829 1.378309
/lnsigma1 | .1865347 .0613124 3.04 0.002 .0663646 .3067048
-------------+----------------------------------------------------------------
rho0 | .3829477 .1471637 .0654124 .6300583
sigma0 | 1.37153 .0686418 1.243382 1.512885
lambda0 | .5252243 .226367 .0815532 .9688954
rho1 | .6600746 .1685343 .2046518 .880572
sigma1 | 1.205066 .0738855 1.068616 1.35894
lambda1 | .7954338 .2513036 .3028878 1.28798
------------------------------------------------------------------------------
Wald testof indep. (rho0 = rho1 = 0): chi2(2) = 8.88 Prob > chi2 = 0.0118