class: center, middle, inverse, title-slide .title[ # Econometria III ] .subtitle[ ## Variáveis Instrumentais - Aplicações ] .author[ ### Rafael Bressan ] .date[ ### Esag 2023-04-07 ] --- layout: true <div class="my-footer"><img src="../../img/logo/UdescEsag.jpeg" style="height: 60px;"/></div> --- # Status .pull-left[ ## O que fizemos na semana passada? * Aprendemos sobre o grande experimento de John Snow em Londres em 1850. * Usamos sua história para motivar o estimador IV. * Você fez um quiz sobre alguns aspectos do IV. ] -- .pull-right[ ## Hoje * Veremos outras aplicações IV. * Introduzimos uma extensão chamada *Two Stage Least Squares*. * Usaremos `R` para calcular as estimativas. * Finalmente falaremos sobre instrumentos *fracos*. ] --- # Retornos da Escolaridade .pull-left[ * Qual é o impacto causal da escolaridade sobre os rendimentos? * [Jacob Mincer](https://en.wikipedia.org/wiki/Jacob_Mincer) estava interessado nesta importante questão. * Aqui está o modelo dele: $$ \log Y_i = \alpha + \rho S_i + \beta_1 X_i + \beta_2 X_i^2 + e_i $$ ] .pull-right[ ```r knitr::include_graphics("../../img/schooling-dag.png") ``` <img src="../../img/schooling-dag.png" style="display: block; margin: auto;" /> ] --- # Retornos da Escolaridade .pull-left[ $$ \log Y_i = \alpha + \rho S_i + \beta_1 X_i + \beta_2 X_i^2 + e_i $$ * Ele encontrou uma estimativa para `\(\rho\)` de cerca de 0,11, * 11% de vantagem nos ganhos para cada ano adicional de educação * Veja o DAG. Esse é um bom modelo? Bem, por que não seria? ] .pull-right[ <img src="../../img/schooling-dag.png" style="display: block; margin: auto;" /> ] --- # Viés de Habilidade .pull-left[ * Comparamos os ganhos de homens com certa escolaridade e experiência de trabalho * Tudo o mais é igual, depois de controlar isso? * Dado `\(X\)`, * Podemos encontrar trabalhadores mais ou menos diligentes por aí? * Podemos encontrar trabalhadores com capacidades diferentes? * As conexões familiares dos trabalhadores variam? ] -- .pull-right[ * Sim claro. Então, *todo o resto* não é igual. * Isso é um problema, porque para consistência dos MQO exigimos a suposição de ortogonalidade `$$E[e_i | S_i, X_i] = 0$$` * Vamos introduzir a **habilidade** `\(A_i\)` explicitamente. ] --- # Mincer com Habilidade não Observada .pull-left[ * Na verdade temos *dois* fatores não-observáveis: `\(e\)` e `\(A\)`. * Claro que não podemos distingui-los. * Então definimos um novo fator não observável `$$u_i = e_i + A_i$$` ] -- .pull-right[ <img src="../../img/schooling-dag2.png" style="display: block; margin: auto;" /> ] --- # Mincer com Habilidade não Observada .pull-left[ * Em termos de uma equação: `$$\log Y_i = \alpha + \rho S_i + \beta_1 X_i + \beta_2 X_i^2 + \underbrace{u_i}_{A_i + e_i}$$` * Às vezes, isso não importa e o viés dos MQO é pequeno. * Às vezes importa, e a estimação é totalmente errada! ] .pull-right[ <img src="../../img/schooling-dag2.png" style="display: block; margin: auto;" /> ] --- layout: false class: separator, middle # Mecânica das Variáveis Instrumentais ## Identificação e Inferência --- layout: true <div class="my-footer"><img src="../../img/logo/UdescEsag.jpeg" style="height: 60px;"/></div> --- # Identificação Vamos voltar ao nosso modelo linear simples: $$ y = \beta_0 + \beta_1 x + u $$ onde tememos que `\(Cov(x,u) \neq 0\)`, `\(x\)` seja *endógeno*. ## Condições para VI 1. **Relevância do Instrumento**: `\(Cov(z,x) \neq 0\)` 1. **Exogenidade do VI** (restrição de exclusão): `\(Cov(z,u) = 0\)`, a VI é exógena na equação do resultado. --- # Identificação ## Modelo Válido (A) vs Model Inválido (B) para VI `z` <img src="04-IV2_pt_files/figure-html/IV-dag2-1.svg" style="display: block; margin: auto;" /> --- # Identificação .pull-left[ ## Condições para VI 1. **Relevância**: `\(Cov(z,x) \neq 0\)` 2. **Exogeneidade**: `\(Cov(z,u) = 0\)` ] -- .pull-right[ <br> * Como isto ***identifica*** `\(\beta_1\)`? * Como podemos expressar `\(\beta_1\)` em termos de momentos populacionais de forma única? ] --- # Identificação `\begin{align} Cov(z,y) &= Cov(z, \beta_0 + \beta_1 x + u) \\ &= \beta_1 Cov(z,x) + Cov(z,u) \end{align}` .pull-left[ Sob a condição 2. acima (**restrição de exclusão**), temos que `\(Cov(z,u)=0\)`, então: $$ Cov(z,y) = \beta_1 Cov(z,x) $$ ] -- .pull-right[ e sob a condição 1. (**relevância**), temos `\(Cov(z,x)\neq 0\)`, portanto: $$ \beta_1 = \frac{Cov(z,y)}{Cov(z,x)}. $$ ] -- * `\(\beta_1\)` é ***identificado*** via os momentos populacionais `\(Cov(z,y)\)` e `\(Cov(z,x)\)` * Podemos ***estimar*** estes momentos através dos ***análogos amostrais*** (_sample plugin estimator_) --- # Estimador de Variáveis Instrumentais Basta "plugar" os momentos **amostrais**: `$$\hat{\beta}_1 = \frac{\sum_{i=1}^n (z_i - \bar{z})(y_i - \bar{y})}{\sum_{i=1}^n (z_i - \bar{z})(x_i - \bar{x})}$$` * A estimativa do intercepto é `\(\hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x}\)` -- * Dado que ambas as hipóteses 1. e 2. são satisfeitas, dizemos que ***o estimador de VI é consistente para `\(\beta_1\)`*** e escrevemos: $$ \text{plim}(\hat{\beta}_1) = \beta_1 $$ em palavras: o *limite em probabilidade* de `\(\hat{\beta}_1\)` é o verdadeiro `\(\beta_1\)`. O estimador `\(\hat{\beta}_1\)` converge em probabilidade para o parâmetro populacional * Se isso for verdade, dizemos que este estimador é **consistente**. --- # Inferência com Variáveis Instrumentais Assumindo `\(E(u^2|z) = \sigma^2\)` a variância do estimador de VI é: `$$Var(\hat{\beta}_{1,IV}) = \frac{\sigma^2}{n \sigma_x^2 \rho_{x,z}^2}$$` * `\(\sigma_x^2\)` é a variância populacional de `\(x\)`, * `\(\sigma^2\)` é a variância de `\(u\)`, e * `\(\rho_{x,z}\)` é a correlação populacional entre `\(x\)` e `\(z\)`. -- Você pode ver 2 coisas importantes aqui: 1. Sem o termo `\(\rho_{x,z}^2\)`, isso é **a variância do MQO**. 2. A medida que o tamanho da amostra `\(n\)` aumenta, a **variância diminui** (assim como no MQO). --- # Inferência com Variáveis Instrumentais ## Variância de VI é sempre maior que MQO * Compare os estimadores de variância de MQO e VI: .pull-left[ `$$Var(\hat{\beta}_{1}) = \frac{\sigma^2}{n \sigma_x^2}$$` ] .pull-right[ `$$Var(\hat{\beta}_{1,IV}) = \frac{\sigma^2}{n \sigma_x^2 \rho_{x,z}^2}$$` ] 1. Dado `\(\rho_{x,z}^2 < 1\)` na maioria das situações da vida real, temos que `\(Var(\hat{\beta}_{1,IV}) > Var(\hat{\beta}_ {1})\)` quase certamente. -- 1. Quanto maior a correlação entre `\(z\)` e `\(x\)`, mais próximo o `\(\rho_{x,z}^2\)` está de 1 e voltamos a variância do MQO. --- # Inferência com Variáveis Instrumentais ## Variância de VI é sempre maior que MQO <img align="middle" src="https://media.giphy.com/media/Xg4Lc2tzOXXdNCU4Qc/giphy.gif" width="100"> Se tiverermos um regressor exógeno válido `\(x\)`, **não** devemos usar VI `\(z\)` para obter `\(\hat{\beta}\)`, pois sua variância será desnecessariamente grande. --- # Inferência com Variáveis Instrumentais ## Estimador de variância com VI Novamente utilizamos os análogos amostrais * `\(n\sigma_x^2\)` é a `\(SQT_x\)` * `\(\rho_{x,z}^2\)` é estimado via `\(R_{x,z}^2\)`. R2 de uma regressão simples de `\(x\)` em `\(z\)` * a variância de `\(u\)` é obtida através do estimador: `$$\hat{\sigma}^2=\frac{1}{n-2}\sum_{i=1}^{n}\hat{u}_i^2$$` onde `\(\hat{u}_i=y_i-\hat\beta_0-\hat\beta_{1, IV} x_i\)` --- # Como Saber se a VI é Válida? ## Condições para VI 1. **Relevância**: `\(Cov(z,x) \neq 0\)` 2. **Exclusão**: `\(Cov(z,u) = 0\)` -- * Somente a condição **1.** pode ser testada empiricamente! * ⚠️ Restrição de exclusão é hipótese não testável + Pesquisador deve se valer de teoria econômica e arguição lógica --- # Mínimos Quadrados Ordinários em 2 Estágios: MQ2E **Equação estrutural**: `\(y_i=\beta_0+\beta_1 s_i + \beta_2 x_i + u_i\)` -- 1. Estimamos um **modelo de primeiro estágio** que usa apenas variáveis exógenas (como `\(z\)`) para explicar nosso regressor endógeno `\(s\)`. 2. Em seguida, usamos a **previsão** do 1º estágio, `\(\hat{s}\)`, no que é chamado de modelo de **segundo estágio**. Esse procedimento deve eliminar qualquer endogeneidade entre `\(\hat{s}\)` e `\(y\)`. `\begin{align} \text{1. Estágio: }s_i &= \alpha_0 + \alpha_1 z_i + \alpha_2 x_i + \eta_i \\ \text{2. Estágio: }y_i &= \beta_0 + \beta_1 \hat{s}_i + \beta_2 x_i + \varepsilon_i \end{align}` -- **Condições:** 1. Relevância do IV: `\(\alpha_1 \neq 0\)` 1. Exogeneidade (restrição de exclusão): `\(E[u | z] = 0\)` --- # Mínimos Quadrados Ordinários em 2 Estágios: MQ2E O primeiro estágio isola a endogeneidade no termo de erro `\(\eta_i\)` `$$s_i=\underbrace{\alpha_0 + \alpha_1 z_i + \alpha_2 x_i}_{\hat{s}_i\text{: parte exógena}} + \eta_i$$` -- E utiliza somente a parte exógena no segundo estágio! `$$y_i = \beta_0 + \beta_1 \hat{s}_i + \beta_2 x_i + \varepsilon_i$$` Assim o segundo estágio faz uso somente de ***variações exógenas*** de `\(s_i\)` e, portanto, `\(\hat{\beta}_1\)` será não viesado. -- * ⚠️ o primeiro estágio **DEVE** ser linear. Caso contrário, regressão proibida de Hausman! (MHE ch. 4, p. 142) * Não realizamos manualmente porque os erros padrão no 2º estágio estarão errados -- .large.center[Vejamos em um exemplo] --- layout: false class: separator, middle # Vamos implementar Angrist e Krueger (1991)! --- layout: true <div class="my-footer"><img src="../../img/logo/UdescEsag.jpeg" style="height: 60px;"/></div> --- # Angrist e Krueger (1991) ## Data de nascimento é tão boa quanto aleatória .pull-left[ * Angrist e Krueger (AK91) é um estudo influente que aborda o viés de habilidade 1. construir uma VI que codifique a *data de nascimento do aluno* 1. A criança nascida logo após a data limite começará a escola mais tarde! * Crianças que completam 6 anos até 31 de dezembro devem se matricular na 1ª série em setembro do mesmo ano ] -- .pull-right[ * Nascidos em dezembro de 2016, estarão com 5a9m quando começarem a escola * Nascidos em 1º de janeiro de 2017 estarão com 6a9m quando *estes* entrarem na escola em setembro de 2023 * Podem legalmente abandonar a escola quando fazem 16 anos! Alguns terão mais escolaridade que outros * VI Dummy para *trimestre de nascimento*: afeta a escolaridade, mas não está relacionado a `\(A\)`! ] --- # Angrist e Krueger (1991) ## Setup com Variável Instrumental .pull-left[ * *trimestre de nascimento* dummy `\(z\)`: afeta a escolaridade, mas não está relacionada a `\(A\)`! * Em particular: se nasceu no 4º trimestre ou não. ] .pull-right[ <img src="../../img/schooling-dag3.png" style="display: block; margin: auto;" /> ] --- # Dados sobre aniversário e salários Vamos carregar os dados e olhar seu sumário ```r # remotes::install_github("jrnold/masteringmetrics", subdir = "masteringmetrics") data("ak91", package = "masteringmetrics") # from the modelsummary package datasummary_skim(data.frame(ak91), histogram = TRUE) ``` <table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> Unique (#) </th> <th style="text-align:right;"> Missing (%) </th> <th style="text-align:right;"> Mean </th> <th style="text-align:right;"> SD </th> <th style="text-align:right;"> Min </th> <th style="text-align:right;"> Median </th> <th style="text-align:right;"> Max </th> <th style="text-align:right;"> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> lnw </td> <td style="text-align:right;"> 26732 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 5.9 </td> <td style="text-align:right;"> 0.7 </td> <td style="text-align:right;"> −2.3 </td> <td style="text-align:right;"> 6.0 </td> <td style="text-align:right;"> 10.5 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="1.23" y="11.66" width="1.73" height="0.0024" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="2.96" y="11.66" width="1.73" height="0.00014" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="4.68" y="11.66" width="1.73" height="0.0038" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="6.41" y="11.66" width="1.73" height="0.0045" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="8.14" y="11.66" width="1.73" height="0.0035" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="9.86" y="11.66" width="1.73" height="0.0035" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="11.59" y="11.66" width="1.73" height="0.0072" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="13.31" y="11.65" width="1.73" height="0.014" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="15.04" y="11.64" width="1.73" height="0.019" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="16.77" y="11.64" width="1.73" height="0.023" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="18.49" y="11.63" width="1.73" height="0.037" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="20.22" y="11.52" width="1.73" height="0.14" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="21.95" y="11.46" width="1.73" height="0.20" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="23.67" y="11.42" width="1.73" height="0.25" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="25.40" y="10.87" width="1.73" height="0.79" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="27.12" y="8.64" width="1.73" height="3.02" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="28.85" y="3.69" width="1.73" height="7.97" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="30.58" y="3.22" width="1.73" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="32.30" y="9.41" width="1.73" height="2.25" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="34.03" y="11.02" width="1.73" height="0.64" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="35.75" y="11.64" width="1.73" height="0.025" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="37.48" y="11.65" width="1.73" height="0.010" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="39.21" y="11.66" width="1.73" height="0.0063" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="40.93" y="11.66" width="1.73" height="0.0043" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="42.66" y="11.66" width="1.73" height="0.0013" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="44.39" y="11.66" width="1.73" height="0.00043" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="46.11" y="11.66" width="1.73" height="0.00022" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> <tr> <td style="text-align:left;"> s </td> <td style="text-align:right;"> 21 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 12.8 </td> <td style="text-align:right;"> 3.3 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 12.0 </td> <td style="text-align:right;"> 20.0 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="1.78" y="11.61" width="2.22" height="0.056" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="4.00" y="11.62" width="2.22" height="0.042" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="6.22" y="11.59" width="2.22" height="0.075" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="8.44" y="11.57" width="2.22" height="0.092" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="10.67" y="11.52" width="2.22" height="0.14" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="12.89" y="11.40" width="2.22" height="0.27" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="15.11" y="11.24" width="2.22" height="0.42" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="17.33" y="10.56" width="2.22" height="1.11" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="19.56" y="10.76" width="2.22" height="0.91" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="21.78" y="10.53" width="2.22" height="1.14" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="24.00" y="10.72" width="2.22" height="0.94" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="26.22" y="3.22" width="2.22" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="28.44" y="10.41" width="2.22" height="1.25" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="30.67" y="9.90" width="2.22" height="1.76" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="32.89" y="10.98" width="2.22" height="0.69" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="35.11" y="9.21" width="2.22" height="2.46" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="37.33" y="10.83" width="2.22" height="0.83" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="39.56" y="10.86" width="2.22" height="0.80" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="41.78" y="11.23" width="2.22" height="0.43" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="44.00" y="10.87" width="2.22" height="0.79" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> <tr> <td style="text-align:left;"> yob </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1934.6 </td> <td style="text-align:right;"> 2.9 </td> <td style="text-align:right;"> 1930.0 </td> <td style="text-align:right;"> 1935.0 </td> <td style="text-align:right;"> 1939.0 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="1.78" y="3.74" width="2.47" height="7.92" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="4.25" y="4.45" width="2.47" height="7.21" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="6.72" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="9.19" y="4.07" width="2.47" height="7.60" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="11.65" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="14.12" y="4.41" width="2.47" height="7.25" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="16.59" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="19.06" y="4.13" width="2.47" height="7.53" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="21.53" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="24.00" y="3.93" width="2.47" height="7.73" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="26.47" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="28.94" y="3.96" width="2.47" height="7.71" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="31.41" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="33.88" y="3.65" width="2.47" height="8.01" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="36.35" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="38.81" y="3.36" width="2.47" height="8.31" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="41.28" y="11.66" width="2.47" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="43.75" y="3.22" width="2.47" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> <tr> <td style="text-align:left;"> qob </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 2.5 </td> <td style="text-align:right;"> 1.1 </td> <td style="text-align:right;"> 1.0 </td> <td style="text-align:right;"> 3.0 </td> <td style="text-align:right;"> 4.0 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="1.78" y="3.72" width="2.96" height="7.94" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="4.74" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="7.70" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="10.67" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="13.63" y="3.87" width="2.96" height="7.79" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="16.59" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="19.56" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="22.52" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="25.48" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="28.44" y="3.22" width="2.96" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="31.41" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="34.37" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="37.33" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="40.30" y="11.66" width="2.96" height="0.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="43.26" y="3.80" width="2.96" height="7.86" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> <tr> <td style="text-align:left;"> sob </td> <td style="text-align:right;"> 51 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 30.7 </td> <td style="text-align:right;"> 14.2 </td> <td style="text-align:right;"> 1.0 </td> <td style="text-align:right;"> 34.0 </td> <td style="text-align:right;"> 56.0 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="0.97" y="9.26" width="1.62" height="2.40" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="2.59" y="11.37" width="1.62" height="0.30" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="4.20" y="6.97" width="1.62" height="4.70" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="5.82" y="10.88" width="1.62" height="0.78" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="7.43" y="10.43" width="1.62" height="1.24" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="9.05" y="10.23" width="1.62" height="1.43" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="10.67" y="9.32" width="1.62" height="2.34" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="12.28" y="11.15" width="1.62" height="0.51" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="13.90" y="4.07" width="1.62" height="7.60" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="15.52" y="8.46" width="1.62" height="3.20" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="17.13" y="7.51" width="1.62" height="4.15" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="18.75" y="9.84" width="1.62" height="1.83" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="20.36" y="4.97" width="1.62" height="6.69" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="21.98" y="8.03" width="1.62" height="3.63" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="23.60" y="8.69" width="1.62" height="2.97" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="25.21" y="10.61" width="1.62" height="1.06" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="26.83" y="8.83" width="1.62" height="2.83" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="28.44" y="3.22" width="1.62" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="30.06" y="8.09" width="1.62" height="3.57" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="31.68" y="4.98" width="1.62" height="6.69" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="33.29" y="3.73" width="1.62" height="7.94" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="34.91" y="11.19" width="1.62" height="0.47" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="36.53" y="9.71" width="1.62" height="1.95" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="38.14" y="4.91" width="1.62" height="6.75" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="39.76" y="10.83" width="1.62" height="0.83" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="41.37" y="9.63" width="1.62" height="2.04" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="42.99" y="8.87" width="1.62" height="2.79" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="44.61" y="9.07" width="1.62" height="2.59" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> <tr> <td style="text-align:left;"> age </td> <td style="text-align:right;"> 40 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 45.0 </td> <td style="text-align:right;"> 2.9 </td> <td style="text-align:right;"> 40.2 </td> <td style="text-align:right;"> 45.0 </td> <td style="text-align:right;"> 50.0 </td> <td style="text-align:right;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="svglite" width="48.00pt" height="12.00pt" viewBox="0 0 48.00 12.00"><defs><style type="text/css"> .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10.00; } .svglite text { white-space: pre; } </style></defs><rect width="100%" height="100%" style="stroke: none; fill: none;"></rect><defs><clipPath id="cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw"><rect x="0.00" y="0.00" width="48.00" height="12.00"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwwLjAwfDEyLjAw)"> </g><defs><clipPath id="cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw"><rect x="0.00" y="2.88" width="48.00" height="9.12"></rect></clipPath></defs><g clip-path="url(#cpMC4wMHw0OC4wMHwyLjg4fDEyLjAw)"><rect x="0.64" y="3.22" width="2.28" height="8.44" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="2.92" y="3.78" width="2.28" height="7.88" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="5.20" y="3.44" width="2.28" height="8.22" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="7.48" y="3.83" width="2.28" height="7.84" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="9.75" y="3.64" width="2.28" height="8.02" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="12.03" y="4.20" width="2.28" height="7.46" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="14.31" y="4.12" width="2.28" height="7.54" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="16.59" y="4.31" width="2.28" height="7.36" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="18.87" y="4.01" width="2.28" height="7.65" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="21.15" y="4.37" width="2.28" height="7.29" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="23.43" y="4.12" width="2.28" height="7.54" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="25.71" y="4.65" width="2.28" height="7.01" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="27.99" y="4.66" width="2.28" height="7.00" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="30.27" y="4.65" width="2.28" height="7.02" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="32.55" y="4.27" width="2.28" height="7.39" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="34.83" y="4.37" width="2.28" height="7.30" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="37.11" y="4.68" width="2.28" height="6.98" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="39.38" y="4.70" width="2.28" height="6.96" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="41.66" y="4.00" width="2.28" height="7.66" style="stroke-width: 0.38; fill: #000000;"></rect><rect x="43.94" y="4.01" width="2.28" height="7.66" style="stroke-width: 0.38; fill: #000000;"></rect></g></svg> </td> </tr> </tbody> </table> --- # Transformações dos Dados * Queremos criar uma _dummy_ `q4` que é `TRUE` se você nasceu no 4º trimestre. * criar versões `factor` de trimestre e ano de nascimento. ```r ak91 <- mutate(ak91, qob_fct = factor(qob), q4 = as.integer(qob == "4"), yob_fct = factor(yob)) # get mean wage by year/quarter ak91_age <- ak91 %>% group_by(qob, yob) %>% summarise(lnw = mean(lnw), s = mean(s)) %>% mutate(q4 = (qob == 4)) ``` --- # Primeiro Estágio! Vamos reproduzir agora a primeira figura de AK91 sobre educação em função do trimestre de nascimento! ```r ggplot(ak91_age, aes(x = yob + (qob - 1) / 4, y = s )) + geom_line() + geom_label(mapping = aes(label = qob, color = q4)) + guides(label = FALSE, color = FALSE) + scale_x_continuous("Year of birth", breaks = 1930:1940) + scale_y_continuous("Years of Education", breaks = seq(12.2, 13.2, by = 0.2), limits = c(12.2, 13.2)) + theme_bw() ``` --- # Primeiro Estágio! .left-thin[ <br> 1. Os números rotulados significam trimestre de nascimento. 1. Nascidos no 4º trimestre **obtiveram** mais educação na maioria dos anos! 1. **Relevância da VI**. ] .right-wide[ <img src="04-IV2_pt_files/figure-html/ak91-dummy-1.svg" style="display: block; margin: auto;" /> ] --- # Impacto da VI no resultado E quanto aos ganhos para esses grupos? ```r ggplot(ak91_age, aes(x = yob + (qob - 1) / 4, y = lnw)) + geom_line() + geom_label(mapping = aes(label = qob, color = q4)) + scale_x_continuous("Year of birth", breaks = 1930:1940) + scale_y_continuous("Log weekly wages") + guides(label = FALSE, color = FALSE) + theme_bw() ``` --- # Impacto da VI no resultado .left-thin[ <br> <br> <br> 1. Nascidos no 4º trimestre estão entre os mais bem pagos por ano de nascimento. 1. Em geral, os salários semanais parecem diminuir um pouco ao longo do tempo. ] .right-wide[ <img src="04-IV2_pt_files/figure-html/ak91-wage-1.svg" style="display: block; margin: auto;" /> ] --- # Executando estimativa VI no `R` <br> <br> .pull-left[ * Várias opções (como sempre com `R`! 😉) * Usaremos a função [`iv_robust`](https://declaredesign.org/r/estimatr/reference/iv_robust.html) do pacote `estimatr`. * *Robusto*? Calcula erros padrão que estão corrigindo a heterocedasticidade. [Detalhes aqui.](https://declaredesign.org/r/estimatr/articles/mathematical-notes.html) ] .pull-right[ ```r library(estimatr) # create a list of models mod <- list() # standard (biased!) OLS mod$ols <- lm(lnw ~ s, data = ak91) # IV: born in q4 is TRUE? # doing IV manually in 2 stages. mod$stage_1 <- lm(s ~ q4, data = ak91) ak91$shat <- predict(mod$stage_1) mod$stage_2 <- lm(lnw ~ shat, data = ak91) # run 2SLS # doing IV all in one go # notice the formula! # formula = y ~ x | z mod$MQ2E <- iv_robust(lnw ~ s | q4, data = ak91, diagnostics = TRUE) ``` ] --- count: false # Executando estimativa VI no `R` <br> <br> .pull-left[ * Várias opções (como sempre com `R`! 😉) * Usará a função [`iv_robust`](https://declaredesign.org/r/estimatr/reference/iv_robust.html) do pacote `estimatr`. * *Robusto*? Calcula erros padrão que estão corrigindo a heterocedasticidade. [Detalhes aqui.](https://declaredesign.org/r/estimatr/articles/mathematical-notes.html) * Observe o `predict` para obter `\(\hat{s}\)`. ] .pull-right[ ```r library(estimatr) # create a list of models mod <- list() # standard (biased!) OLS mod$ols <- lm(lnw ~ s, data = ak91) # IV: born in q4 is TRUE? # doing IV manually in 2 stages. mod$stage_1 <- lm(s ~ q4, data = ak91) *ak91$shat <- predict(mod$stage_1) modmod$stage_2 <- lm(lnw ~ shat, data = ak91) # run 2SLS # doing IV all in one go # notice the formula! # formula = y ~ x | z mod$MQ2E <- iv_robust(lnw ~ s | q4, data = ak91, diagnostics = TRUE) ``` ] --- layout: false # Resultados .left-wide[
ols
stage_1
stage_2
MQ2E
(Intercept)
4.995***
12.747***
4.955***
4.955***
(0.004)
(0.007)
(0.381)
(0.358)
s
0.071***
0.074**
(0.000)
(0.028)
q4
0.092***
(0.013)
shat
0.074*
(0.030)
R2
0.117
0.000
0.000
0.117
RMSE
0.64
3.28
0.68
0.64
1. Stage F:
48.990
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
] .right-thin[ 1. MQO viesado para baixo (erro de medição) 1. Primeira Fase: VI `q4` é estatisticamente significativo 1. O segundo estágio tem a mesma estimativa pontual que `MQ2E`, mas um erro padrão diferente (segundo estágio um está errado) ] --- layout: true <div class="my-footer"><img src="../../img/logo/UdescEsag.jpeg" style="height: 60px;"/></div> --- # Lembra da estatística F? * Encontramos isso antes: é útil testar modelos restritos versus irrestritos entre si. -- * Aqui, estamos interessados em saber se nossos instrumentos são *conjuntamente* significativos. Claro, com apenas uma VI, isso não é mais informativo do que o t-stat dessa VI. -- * Este F-Stat compara o poder preditivo do primeiro estágio com e sem as VIs. Se eles tiverem poder preditivo muito semelhante, o F-stat será baixo e não poderemos rejeitar H0 de que nossas VIs são **conjuntamente insignificantes** no modelo do primeiro estágio. 😞 --- # VI com um instrumento fraco * VI é consistente sob determinadas premissas. * No entanto, *mesmo* que tenhamos apenas `\(Cor(z,u)\)` muito pequenos, podemos errar * Pequena correlação entre `\(x\)` e `\(z\)` pode produzir estimativas **inconsistentes**. $$ \text{plim}(\hat{\beta}_{1,IV}) = \beta_1 + \frac{Cor(z,u)}{Cor(z,x)} \cdot \frac{\sigma_u}{\sigma_x} $$ -- * Mesmo que `\(Cor(z,u)\)` seja muito pequena * Um **instrumento fraco** é aquele com pequeno valor absoluto para `\(Cor(z,x)\)` * Mesmo com um tamanho de amostra grande, nosso estimador *não* convergirá para o verdadeiro parâmetro populacional `\(\beta_1\)`. --- # VI com um instrumento fraco Para ilustrar esse ponto, vamos supor que queremos analisar o impacto do número de maços de cigarros fumados por dia por mulheres grávidas (*packs*) no peso ao nascer de seus filhos (*bwght*): $$ \log(bwght) = \beta_0 + \beta_1 packs + u $$ Estamos preocupados que o comportamento de fumar esteja correlacionado com uma série de outras variáveis relacionadas à saúde que estão em `\(u\)` e que podem afetar o peso ao nascer da criança. Então, procuramos um IV. Suponha que usemos o preço dos cigarros (*cigprice*), supondo que o preço dos cigarros não esteja correlacionado com fatores em `\(u\)`. Vamos executar o primeiro estágio de *cigprice* em *packs* e então vamos mostrar as estimativas de MQ2E: --- # VI com um instrumento fraco ```r data(bwght, package = "wooldridge") mods <- list() mods$Estagio_1 <- lm(packs ~ cigprice, data = bwght) mods$VI <- estimatr::iv_robust(log(bwght) ~ packs | cigprice, data = bwght, diagnostics = TRUE) ```
Estagio_1
VI
(Intercept)
0.067
4.448
(0.103)
(0.940)
cigprice
0.000
(0.001)
packs
2.989
(8.996)
R2
0.000
-23.230
RMSE
0.30
115.77
1. Stage F:
0.121
--- # VI com um instrumento fraco .pull-left[ * As primeiras colunas mostram: primeiro estágio muito fraco. *cigprice* parece ter zero impacto nos maços! * `\(R^2\)` é zero. * O que é que usamos nesta VI, no entanto? ] -- .pull-right[ * na segunda coluna: impacto muito grande e positivo(!) dos maços fumados no peso ao nascer. 🤔 * Enorme erro padrão. * Um `\(R^2\)` de -23?! * F-stat do primeiro estágio: 0,121. Corresponde a um valor p de 0.728 : nós **não podemos** rejeitar a H0 de um primeiro estágio insignificante. * Então: abordagem **inválida**. ❌ ] --- # Variáveis de Controle Adicionais * Vimos uma tendência de tempo clara na educação mais cedo. * Há também flutuações do ciclo de negócios nos ganhos * Devemos de alguma forma controlar por diferentes períodos de tempo. * Além disso, podemos usar mais de uma VI! Aqui está como: --- # Variáveis de Controle Adicionais ```r # we keep adding to our `mod` list: mod$ols_yr <- update(mod$ols, . ~ . + yob_fct) # previous OLS model # add exogenous vars on both sides of the `|` ! mod$MQ2E_yr <- iv_robust(lnw ~ s + yob_fct | q4 + yob_fct, data = ak91, diagnostics = TRUE ) # use all quarters as IVs mod$MQ2E_all <- iv_robust(lnw ~ s + yob_fct | qob_fct + yob_fct, data = ak91, diagnostics = TRUE ) ``` --- # Variáveis de Controle Adicionais
ols
MQ2E
ols_yr
MQ2E_yr
MQ2E_all
(Intercept)
4.995
4.955
5.017
4.966
4.592
(0.004)
(0.358)
(0.005)
(0.354)
(0.251)
s
0.071
0.074
0.071
0.075
0.105
(0.000)
(0.028)
(0.000)
(0.028)
(0.020)
Num.Obs.
329509
329509
329509
329509
329509
R2 Adj.
0.117
0.117
0.118
0.117
0.091
Instruments
none
Q4
none
Q4
All Quarters
Year of birth
no
no
yes
yes
yes
--- # Variáveis de Controle Adicionais .left-wide[
ols
MQ2E
ols_yr
MQ2E_yr
MQ2E_all
(Intercept)
4.995
4.955
5.017
4.966
4.592
(0.004)
(0.358)
(0.005)
(0.354)
(0.251)
s
0.071
0.074
0.071
0.075
0.105
(0.000)
(0.028)
(0.000)
(0.028)
(0.020)
Num.Obs.
329509
329509
329509
329509
329509
R2 Adj.
0.117
0.117
0.118
0.117
0.091
Instruments
none
Q4
none
Q4
All Quarters
Year of birth
no
no
yes
yes
yes
] .right-thin[ **Adicionando controle de ano**... * deixa o MQO praticamente inalterado * ligeiro aumento na estimativa de MQ2E **Usando todos os trimestres como VI**... * Aumenta muito a precisão da estimativa MQ2E! * A estimativa pontual é de 10,5% agora! ] --- # Fazendo um balanço - O Trimestre de Nascimento (QOB) .pull-left[ * Isso produzirá estimativas consistentes se 1. A VI prediz bem o regressor endógeno. 2. A VI é tão boa quanto aleatória/independente das VOs. 3. Só pode impactar o resultado através da escolaridade. * Como o QOB se comporta com relação a estes itens? ] -- .pull-right[ 1. O gráfico do 1º estágio e o F-stat alto oferecem evidências de **relevância**. ✅ 2. O QOB é **independente** de, digamos, *características maternas*? Aniversários não são realmente aleatórios - há épocas de nascimento para certas origens socioeconômicas. maior escolaridade materna dão à luz no segundo trimestre. (não no 4º! ✅) 3. Exclusão: E se as crianças mais novas (nascidas no 4º tri!) forem desfavorecidas desde o início, que tem impactos negativos a longo prazo? Então `\(E[u|z] \neq 0\)`! Bem, os mais novos se saem melhor (mais escolaridade e salário mais alto)! ✅ ] --- # Tópicos Especiais VI ## Experimentos Aleatorizados * Experimento aleatorizado (RCT ou A/B testing) -- * Atribui indíviduos para grupos Controle ou Tratado, mas não obriga -- * Existe _noncompliance_. Tratamento efetivo `\(T_i \neq Z_i\)` designação -- * **Atribuição ao tratamento** `\(Z_i\)` serve como **instrumento** para o efetivo status `\(T_i\)` --- # Tópicos Especiais VI ## Experimentos Aleatorizados * Duas medidas de tratamento + Intention-to-treat (**ITT**): forma reduzida `\(Y_i=\pi Z_i+v_i\)` + Local Average Treatment Effect (**LATE**): variável instrumental (MQ2E) -- * Para validade do experimento, checa-se o balanço de covariadas entre grupo controle e tratamento * Bom balanço `\(\implies\)` aleatorização bem feita. (Imbens e Rubin, 2015) --- # Tópicos Especiais VI ## Instrumentos de Bartik > A ideia por trás de um instrumento de Bartik é medir variações locais a partir de um choque nacional (regional) -- * Também conhecidos como ***Shift-Share design*** -- * Comuns na literatura de comércio internacional (Autor, Dorn, e Hanson, 2013), imigração (Card, 2009) e trabalho (Bound e Holzer, 2000) -- * ***Bartik Instruments: What, When, Why, and How***. Goldsmith-Pinkham, et al. (2020) --- # Tópicos Especiais VI ## Instrumentos de Bartik * Um choque nacional (_**shifter**_), em diferentes indústrias, é "espalhado" localmente de forma diferente entre as localidades através de uma matriz de exposições (_**shares**_) -- * Crescimento do salário em razão do crescimento no emprego, em uma localidade `\(l\)` `$$y_l=\rho+\beta_1x_l+\epsilon_l$$` -- * Crescimento do emprego é *produto interno* da fração de cada indústria `\(k\)` no emprego com o crescimento desta indústria. `\(x_l=\sum_kz_{lk}g_{lk}\)` -- * Crescimento da indústria local é decomposto: `\(g_{lk}=g_k+\tilde{g}_{lk}\)` -- * O ***Instrumento de Bartik*** é: `$$Z_l=\sum_k z_{lk}g_k$$` --- # Leitura Recomendada * WOOLDRIDGE, Jeffrey M. Introdução à econometria: uma abordagem moderna. São Paulo: Cengage Learning, 2016. Tradução da 4ª edição norte-americana por José Antonio Ferreira. Capítulo 15 Estimação de Variáveis Instrumentais e Mínimos Quadrados em dois Estágios. * GUJARATI, Damodar N.; PORTER, Dawn C. Econometria básica. Porto Alegre: Amgh Editora, 2011. - 5. ed. * ANGRIST, Joshua D.; PISCHKE, Jörn-Steffen. Mostly harmless econometrics: An empiricist's companion. Princeton university press, 2009. Chapter 4 Instrumental Variables in Action. * IMBENS, Guido W.; RUBIN, Donald B. Causal inference in statistics, social, and biomedical sciences. Cambridge University Press, 2015. * GOLDSMITH-PINKHAM, Paul; SORKIN, Isaac; SWIFT, Henry. Bartik instruments: What, when, why, and how. American Economic Review, v. 110, n. 8, p. 2586-2624, 2020. --- layout: false class: title-slide-final, middle background-image: url(../../img/logo/UdescEsag.jpeg) background-size: 350px background-position: 9% 19% # ATÉ A PRÓXIMA AULA! Com a Lista 2 feita! ✅ .footnote[ [1]: Este slides foram baseados nas aulas de econometria da [SciencesPo Department of Economics](https://github.com/ScPoEcon/ScPoEconometrics-Slides) ] | | | | :--------------------------------------------------------------------------------------------------------- | :-------------------------------- | | <a href="https://github.com/rfbressan/econometria3_slides">.ScPored[<i class="fa fa-link fa-fw"></i>] | Slides | | <a href="http://github.com/rfbressan">.ScPored[<i class="fa fa-github fa-fw"></i>] | @rfbressan | | <a href="https://raw.githack.com/rfbressan/econometria3_slides/master/lectures/04-IV2/lista_II_pt.html">.ScPored[<i class="fa fa-list fa-fw"></i>] | Lista de Exercícios II |