******* AULA PRATICA - LATE/VI **** ** BASEADA NO TEXTO /*The Stata Journal (2014) 14, Number 3, pp. 453–480 ivtreatreg: A command for fitting binary treatment models with heterogeneous response to treatment and unobservable selection Author: Giovanni Cerulli */ cd "C:\FEA_OwnCloud\guilherme\FEARP\mestrado\avaliação\late-vi" use "fertil2.dta", clear /*"fertil2.dta is a collection of cross-sectional data on 4,361 women of childbearing age in Botswana. This dataset contains 28 variables on various female and family characteristics. We are particularly interested in evaluating the impact of the variable "educ7" (taking value 1 if a woman has seven years of education or more and 0 otherwise) on the number of family children (children). Several conditioning (or confounding) observable factors are included in the dataset, such as the age of the woman (age), whether or not the family owns a TV (tv), and whether or not the woman lives in a city (urban). To inquire about the relationship between education and fertility, following Wooldridge (2010), we estimate the following specification:*/ *gerando "educ7" gen educ7=0 replace educ7=1 if educ>=7&educ~=. *diferença de média ingenua reg children educ7 estimates store ttest *regressão múltipla reg children educ7 age agesq evermarr urban electric tv estimates store mqo * tem que instalar o comando * ssc install ivtreatreg *rodando o comando para VI /*frsthalf é a variável instrumental que assume valor 1 se a mulher nasceu no primeiro semestre do ano e 0 caso contrário. Essa variável é parcialmente correlacionada com educ7, mas não deveria ter nenhum efeito direto sobre a fertilidade */ reg children educ7 age agesq evermarr urban electric tv estimates store mqo ivtreatreg children educ7 age agesq evermarr urban electric tv, /// iv(frsthalf) model(probit-2sls) graphic estimates store probit_2sls ivtreatreg children educ7 age agesq evermarr urban electric tv, /// iv(frsthalf) model(direct-2sls) graphic estimates store direct_2sls ivtreatreg children educ7 age agesq evermarr urban electric tv, /// iv(frsthalf) model(probit-ols) graphic estimates store probit_ols ivreg 2sls children age agesq evermarr urban electric tv (educ7=frsthalf) estimates store ivregr estimates table mqo probit_ols direct_2sls probit_2sls ivregr,b(%9.2f) keep(educ7 G_fv) star /*G_fv é a probabilidade predita a partir de modelo probit, condicional nas observáveis*/ /*probit-ols 1. Apply a probit of w on x and z, thus getting pw, the predicted probability of w. 2. Run an OLS of y on {1, x, pw, pw(x - µx)}.*/ /*direct_2sls 1. Run an OLS regression of w on x and z, thus getting the predicted values of wi, indicated by wfv,i. 2. Run a second OLS of y on {x, wfv,i, wfv,i(x - µx)}. /*probit-2sls 1. Apply a probit of w on x and z, thus getting pw, the predicted probability of w. 2. Run an OLS of w on (1, x, pw), thus getting the fitted values w2fv,i. 3. Run a second OLS of y on {1, x, w2fv,i, w2fv,i(x - µx)}.*/ /*The coefficient of w2fv,i is a more efficient estimator of ATE compared with direct-2sls. Furthermore, to achieve consistency, this procedure does not require that the process generating w is correctly specified; thus, it is more robust than probit-ols.*/