Abstract
We analyse specifications of dummy and trend variables to the Wooldridge’s examples 10.4 and 10.8. This is an exercise using a linear multiple regression.This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
License: CC BY-SA 4.0
Sugestão de citação: FIGUEIREDO, Adriano Marcos Rodrigues. Econometria: dummy e tendência: exercício Efeitos da Isenção de Impostos nas Taxas de Fertilidade. Campo Grande-MS,Brasil: RStudio/Rpubs, 2020. Disponível em http://www.rpubs.com/amrofi/ex_wooldridge_10_8_dummy_trend.
Os primeiros passos são criar ou abrir um diretório de trabalho. Se optar por criar um novo projeto, haverá a possibilidade de criar em uma pasta vazia. Os dados básicos estão no pacote wooldridge
, dataset fertil3
.
Example 10.4 Effects of Personal exemption on fertility rates. The general fertility rate (gfr) is the number of children born to every 1,000 women of childbearing age. For the years 1913 through 1984, the equation, \[ gfr_t= \beta _0 + \beta _1 pe_t +\beta _2 ww2_t + \beta _3 pill_t + \mu _t ,\] explains gfr in terms of the average real dollar value of the personal tax exemption (pe) and two binary variables. The variable ww2 takes on the value unity during the years 1941 through 1945, when the United States was involved in World War II. The variable pill is unity from 1963 onward, when the birth control pill was made available for contraception. Using the data in FERTIL3, which were taken from the article by Whittington, Alm, and Peters (1990).
Enunciado do exemplo 10.4 da edição brasileira. Fonte: Wooldridge (2006, p.321)
data(fertil3, package='wooldridge')
# exemplo 10.8 do livro do Wooldridge, Introdução a Econometria
# dados basicos de:
# Wooldridge Source: L.A. Whittington, J. Alm, and H.E. Peters (1990),
# “Fertility and the Personal Exemption: Implicit Pronatalist Policy in
# the United States,” American Economic Review 80, 545-556.
# data.frame with 72 observations on 24 variables:
# gfr: births per 1000 women 15-44
# [tgf = taxa geral de fertilidade]
# pe: real value pers. exemption, $
# [ip = valor real da taxa de isenção de impostos]
# year: 1913 to 1984 [ano]
# t: time trend, t=1,...,72 [tendencia]
# tsq: t^2 [tendencia ao quadrado]
# pill: =1 if year >= 1963
# [pilula anticoncepcional]
# ww2: =1, 1941 to 1945 [world war dummy]
# tcu: t^3 [tendencia cubica]
# cgfr: change in gfr: gfr - gfr_1
# [mudanca na tx de fertilidade]
library(dynlm);library(stargazer)
data(fertil3, package='wooldridge') # chamo os dados de dentro do pacote "wooldridge"
# exemplo 10.8 do livro do Wooldridge, Introdução a Econometria
# dados basicos de:
# Wooldridge Source: L.A. Whittington, J. Alm, and H.E. Peters (1990),
# “Fertility and the Personal Exemption: Implicit Pronatalist Policy in
# the United States,” American Economic Review 80, 545-556.
# data.frame with 72 observations on 24 variables:
# gfr: births per 1000 women 15-44 [tgf]
# pe: real value pers. exemption, $ [ip]
# year: 1913 to 1984 [ano]
# t: time trend, t=1,...,72 [tendencia]
# tsq: t^2 [tendencia ao quadrado]
# pill: =1 if year >= 1963 [pilula anticoncepcional]
# ww2: =1, 1941 to 1945 [world war dummy]
# tcu: t^3 [tendencia cubica]
# cgfr: change in gfr: gfr - gfr_1 [mudanca na tx de fertilidade]
#View(fertil3)
#library(esquisse)
#esquisser(fertil3)
library(ggplot2)
ggplot(fertil3) +
aes(x = pe, y = gfr, colour = pill) +
geom_point(size = 3L) +
scale_color_distiller(palette = "RdBu") +
ggthemes::theme_foundation()
ggplot(fertil3) +
aes(x = pe, y = gfr, colour = ww2) +
geom_point(size = 3L) +
scale_color_distiller(palette = "RdBu") +
ggthemes::theme_foundation()
attach(fertil3)
O gráfico da variável dependente gfr (tgr - taxa geral de fertilidade) é:
require(fpp2)
autoplot(as.ts(gfr))
Vamos estimar o modelo linear múltipla fazendo a regressão inicial conforme o exemplo 10.4.
# Regressao Linear :
reg1.lm <- lm(gfr ~ pe + ww2 + pill, data = fertil3)
reg1.lm$AIC <- AIC(reg1.lm) # Akaike
reg1.lm$BIC <- BIC(reg1.lm) # Schwarz
stargazer::stargazer(reg1.lm, title = "Título: Resultado da Regressão OLS", type = "text",
style = "all", align = TRUE, keep.stat = c("AIC", "BIC", "rsq", "adj.rsq", "n"))
Título: Resultado da Regressão OLS
===============================================
Dependent variable:
---------------------------
gfr
-----------------------------------------------
pe 0.083***
(0.030)
t = 2.784
p = 0.007
ww2 -24.238***
(7.458)
t = -3.250
p = 0.002
pill -31.594***
(4.081)
t = -7.742
p = 0.000
Constant 98.682***
(3.208)
t = 30.760
p = 0.000
-----------------------------------------------
Observations 72
R2 0.473
Adjusted R2 0.450
Akaike Inf. Crit. 597.115
Bayesian Inf. Crit. 608.499
===============================================
Note: *p<0.1; **p<0.05; ***p<0.01
library(equatiomatic)
equatiomatic::extract_eq(reg1.lm, use_coefs = TRUE, ital_vars = T, coef_digits = 3)
$$
gfr = 98.682 + 0.083(pe) - 24.238(ww2) - 31.594(pill) + \epsilon
$$
# $$ \operatorname{gfr} = 98.682 + 0.083(\operatorname{pe}) -
# 24.238(\operatorname{ww2}) - 31.594(\operatorname{pill}) + \epsilon $$
Portanto a equação estimada é
\[ gfr = 98.682 + 0.083(pe) - 24.238(ww2) - 31.594(pill) + \epsilon \]
Interpretação do exemplo 10.4 da edição brasileira. Fonte: Wooldridge (2006, p.321)
Ou seja, para um aumento de 12 dólares em ip, o aumento em tgf será \(12*0.083 \approx +1\), ou 1 para cada 1000 mulheres em idade fértil.
Podemos colocar as equações assim:
sem guerra: \(ww2=0\)
antes da pílula: \(pill = 0\): \[ \begin{array}{l} gfr = 98.682 + 0.083(pe) - 24.238{\rm{ x 0}} - 31.594{\rm{ x 0}}\\ gfr = 98.682 + 0.083(pe) \end{array} \] depois da pílula: \(pill = 1\): \[ \begin{array}{l} gfr = 98.682 + 0.083(pe) - 24.238{\rm{ x 0}} - 31.594{\rm{ x 1}}\\ gfr = \left( {98.682 - 31.594} \right) + 0.083(pe)\\ gfr = \left( {67.088} \right) + 0.083(pe) \end{array} \]
com guerra: \(ww2=1\)
antes da pílula: \(pill = 0\): \[ \begin{array}{l} gfr = 98.682 + 0.083(pe) - 24.238{\rm{ x 1}} - 31.594{\rm{ x 0}}\\ gfr = \left( {98.682 - 24.238} \right) + 0.083(pe)\\ gfr = \left( {74.444 } \right) + 0.083(pe) \end{array} \] depois da pílula: \(pill = 1\): \[ \begin{array}{l} gfr = 98.682 + 0.083(pe) - 24.238{\rm{ x 1}} - 31.594{\rm{ x 1}}\\ gfr = \left( {98.682 -24.238 - 31.594} \right) + 0.083(pe)\\ gfr = \left( {42.850} \right) + 0.083(pe) \end{array} \]
São realizados dois procedimentos, um com a variável \(year\) e outro com a variável \(t\) construída previamente, de modo que o leitor verá que ambos resultam no mesmo resultado, com exceção da constante que terá nível diferente para a equação com \(year\) por estar em anos (1913, 1914, …) invés de t=(1,2,…).
# Regressao exemplo 10.8 - incluindo tendencia
reg2 <- lm(gfr ~ pe + ww2 + pill + year, data = fertil3)
reg2.a <- lm(gfr ~ pe + ww2 + pill + t, data = fertil3)
reg2$AIC <- AIC(reg2) # com tendencia
reg2$BIC <- BIC(reg2) # com tendencia
reg2.a$AIC <- AIC(reg2.a) # com tendencia
reg2.a$BIC <- BIC(reg2.a) # com tendencia
stargazer(reg2, reg2.a, title = "Título: Resultados das Regressões OLS
com tendência",
align = TRUE, type = "text", style = "all", keep.stat = c("AIC", "BIC", "rsq",
"adj.rsq", "n"))
Título: Resultados das Regressões OL
================================================
Dependent variable:
----------------------------
gfr
(1) (2)
------------------------------------------------
pe 0.279*** 0.279***
(0.040) (0.040)
t = 6.968 t = 6.968
p = 0.000 p = 0.000
ww2 -35.592*** -35.592***
(6.297) (6.297)
t = -5.652 t = -5.652
p = 0.00000 p = 0.00000
pill 0.997 0.997
(6.262) (6.262)
t = 0.159 t = 0.159
p = 0.874 p = 0.874
year -1.150***
(0.188)
t = -6.119
p = 0.00000
t -1.150***
(0.188)
t = -6.119
p = 0.00000
Constant 2,310.325*** 111.769***
(361.420) (3.358)
t = 6.392 t = 33.287
p = 0.00000 p = 0.000
------------------------------------------------
Observations 72 72
R2 0.662 0.662
Adjusted R2 0.642 0.642
Akaike Inf. Crit. 567.148 567.148
Bayesian Inf. Crit. 580.808 580.808
================================================
Note: *p<0.1; **p<0.05; ***p<0.01
reg3 <- lm(gfr ~ pe + ww2 + pill + t + tsq, data = fertil3)
reg3$AIC <- AIC(reg3) # com tendencia quadratica
reg3$BIC <- BIC(reg3) # com tendencia quadratica
reg4 <- lm(gfr ~ pe + ww2 + pill + t + tsq + tcu, data = fertil3)
reg4$AIC <- AIC(reg4) # com tendencia cubica
reg4$BIC <- BIC(reg4) # com tendencia cubica
Para a tabela, a função com tendência será a número (1 - reg2.a), a quadrática a (2 - reg3) e a cúbica a (3 - reg4).
# library(stargazer)
star.1 <- stargazer(reg2.a, reg3, reg4, title = "Título: Resultados das Regressões",
align = TRUE, type = "text", column.labels = c("linear", "quadrática", "cúbica"),
keep.stat = c("aic", "bic", "rsq", "adj.rsq", "n"))
Título: Resultados das Regressões
====================================================
Dependent variable:
--------------------------------
gfr
linear quadrática cúbica
(1) (2) (3)
----------------------------------------------------
pe 0.279*** 0.348*** 0.162***
(0.040) (0.040) (0.041)
ww2 -35.592*** -35.880*** -19.047***
(6.297) (5.708) (5.042)
pill 0.997 -10.120 -25.010***
(6.262) (6.336) (5.346)
t -1.150*** -2.531*** -5.612***
(0.188) (0.389) (0.543)
tsq 0.020*** 0.155***
(0.005) (0.020)
tcu -0.001***
(0.0002)
Constant 111.769*** 124.092*** 142.795***
(3.358) (4.361) (4.338)
----------------------------------------------------
Observations 72 72 72
R2 0.662 0.727 0.840
Adjusted R2 0.642 0.706 0.826
Akaike Inf. Crit. 567.148 553.901 517.138
Bayesian Inf. Crit. 580.808 569.838 535.351
====================================================
Note: *p<0.1; **p<0.05; ***p<0.01
É possível observar que a expressão cúbica, (3), foi a de maiores valores de \(R^2\), \(R^2\) ajustado, e menores valores de Akaike (AIC) e Schwarz (Bayesian - BIC). Desta forma, a princípio, esta é a melhor expressão.
HEISS, Florian. Using R for Introductory Econometrics. 2.ed. Florian Heiss, 2020. Recurso online. Disponível em: http://www.urfie.net/.
WOOLDRIDGE, J.M. Introdução à Econometria: uma abordagem moderna. São Paulo: Pioneira Thomson Learning, 2006.(tradução da segunda edição americana).