Assignment

Problem 1: money, Growth, and Inflation (30 marks)

  1. Using the four IVs, obtain TSLS estimates of the inflation equation (4 marks), and test the economic theory using the IV estimates.
brumn_dat <- read.dta13('datasets/brumm.dta')
ivmodel <- ivreg(inflat ~ output+money|initial +school+inv+poprate+money, data = brumn_dat)

stargazer(ivmodel, type = 'text')
## 
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                               inflat           
## -----------------------------------------------
## output                       -1.394**          
##                               (0.552)          
##                                                
## money                        1.035***          
##                               (0.010)          
##                                                
## Constant                      -1.094           
##                               (1.858)          
##                                                
## -----------------------------------------------
## Observations                    76             
## R2                             0.995           
## Adjusted R2                    0.995           
## Residual Std. Error       4.344 (df = 73)      
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
summary(ivmodel)
## 
## Call:
## ivreg(formula = inflat ~ output + money | initial + school + 
##     inv + poprate + money, data = brumn_dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -24.633  -1.487   0.204   1.937   9.498 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.093985   1.858208  -0.589   0.5579    
## output      -1.394200   0.551503  -2.528   0.0136 *  
## money        1.035059   0.009773 105.914   <2e-16 ***
## 
## Diagnostic tests:
##                  df1 df2 statistic p-value   
## Weak instruments   4  70     4.642 0.00221 **
## Wu-Hausman         1  72     0.300 0.58551   
## Sargan             3  NA     2.455 0.48344   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.344 on 73 degrees of freedom
## Multiple R-Squared: 0.9947,  Adjusted R-squared: 0.9946 
## Wald test:  6852 on 2 and 73 DF,  p-value: < 2.2e-16

Demand for Democracy

  1. Is the data set a balanced panel? Explain.
income_democracy_dat <- read.dta13('datasets/income_democracy.dta')
income_democracy_dat.p <- pdata.frame(income_democracy_dat, index = c("code","year"))
# 检查面板数据是否平衡
balance_res <- pdim(income_democracy_dat.p)
balance_res
## Unbalanced Panel: n = 195, T = 1-9, N = 1369
  1. The index of political freedom/democracy is labeled dem ind.
# What is the value of dem ind for the United States in 2000? What is the average of dem ind for the United States over all years in the data set? (4 marks) Repeat this exercise for Libya (2 marks).
t.a <- dplyr::filter(income_democracy_dat, country == "United States", year == 2000) $ dem_ind
kable(t.a, caption = "US and year = 2000")
US and year = 2000
x
1
t.a2 <- mean(dplyr::filter(income_democracy_dat, country == "United States") $ dem_ind)
kable(t.a2, caption = "US average of dem_ind")
US average of dem_ind
x
0.9855556
t.libya <- dplyr::filter(income_democracy_dat, country == "Libya", year == 2000) $ dem_ind
kable(t.libya, caption = "Libya and year = 2000")
Libya and year = 2000
x
0
t.libya2 <- mean(dplyr::filter(income_democracy_dat, country == "Libya") $ dem_ind)
kable(t.libya2, caption = "Libya average of dem_ind")
Libya average of dem_ind
x
0.1092593
# List five countries with an average value of dem ind greater than 0.95; less than 0.10; and between 0.3 and 0.7.
income_democracy1 <- income_democracy_dat %>% 
  group_by(code) %>% 
  summarise(
    mean_dem_ind = mean(dem_ind, na.rm = TRUE)
  )
income_democracy2 <- full_join(income_democracy_dat, income_democracy1, by = "code")

income_democracy3 <-  distinct(income_democracy2, code, mean_dem_ind, .keep_all = TRUE) %>% 
  arrange(mean_dem_ind)

list_5.1 <- dplyr::filter(income_democracy3, mean_dem_ind > 0.95) $ country %>% head(n=5)
list_5.2 <- dplyr::filter(income_democracy3, mean_dem_ind < 0.10) $ country %>% head(n=5)
list_5.3 <- dplyr::filter(income_democracy3, mean_dem_ind > 0.3,
              mean_dem_ind < 0.7) $ country %>% head(n=5)

kable(list_5.1, caption = ">0.95 Five countries")
>0.95 Five countries
x
Malta
Luxembourg
Germany, West
Japan
Costa Rica
kable(list_5.2, caption = "<0.10 Five countries")
<0.10 Five countries
x
Eritrea
Turkmenistan
Uzbekistan
Vietnam
Equatorial Guinea
kable(list_5.3, caption = "[0.3,0.7] Five countries")
[0.3,0.7] Five countries
x
Zimbabwe
Jordan
Nigeria
Bulgaria
Bosnia and Herzegovina

3. The logarithm of per capita income is labeled log gdppc

# Regress dem ind on log gdppc using standard errors that are clustered by country

md3 <- lm(dem_ind ~ log_gdppc, data=income_democracy_dat)
md3.reg <- coef_test(md3, vcov='CR2', cluster = income_democracy_dat$country)
# stargazer(md3.reg, type = 'text')
summary(md3)
## 
## Call:
## lm(formula = dem_ind ~ log_gdppc, data = income_democracy_dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.72854 -0.19534  0.02586  0.19123  0.72698 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.354828   0.070919  -19.10   <2e-16 ***
## log_gdppc    0.235673   0.008626   27.32   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2719 on 956 degrees of freedom
##   (411 observations deleted due to missingness)
## Multiple R-squared:  0.4385, Adjusted R-squared:  0.4379 
## F-statistic: 746.5 on 1 and 956 DF,  p-value: < 2.2e-16
# How large is the estimated coefficient on log gdppc? Is the coefficient statistically significant?
md3.reg
##         Coef. Estimate     SE t-stat d.f. p-val (Satt) Sig.
## 1 (Intercept)   -1.355 0.1010  -13.4 70.5       <0.001  ***
## 2   log_gdppc    0.236 0.0119   19.8 69.3       <0.001  ***
# If per capita income in a country increases by 20%, by how much is dem ind predicted to increase? What is a 95% confidence interval for the prediction? Is the predicted increase in dem ind large or small? Explain what you mean by large or small.

# Why is it important to use clustered standard errors for the regression?

# Do the results change if you do not use clustered standard errors?

est <- md3$coefficients[1] + 0.2 * md3$coefficients[2]

kable(est, caption = "dem_ind result")
dem_ind result
x
(Intercept) -1.307693
are <- confint(md3, level = 0.95)[1,] + 0.2 * confint(md3, 'log_gdppc', level=0.95)
kable(are, caption = '95% interval')
95% interval
2.5 % 97.5 %
log_gdppc -1.450253 -1.165133

4.回归分析

固定效应模型(a)
regfeind <- plm(dem_ind ~ log_gdppc, data = income_democracy_dat, effect = "individual")
stargazer(regfeind, type = 'text')
## 
## ========================================
##                  Dependent variable:    
##              ---------------------------
##                        dem_ind          
## ----------------------------------------
## log_gdppc             0.084***          
##                        (0.021)          
##                                         
## ----------------------------------------
## Observations             958            
## R2                      0.020           
## Adjusted R2            -0.163           
## F Statistic    16.202*** (df = 1; 807)  
## ========================================
## Note:        *p<0.1; **p<0.05; ***p<0.01
est4.a <- 0.2 * regfeind$coefficients
kable(est4.a, caption = "dem_ind result in 4(a)")
dem_ind result in 4(a)
x
log_gdppc 0.0167482
are4.a <- 0.2*confint(regfeind, 'log_gdppc', level = 0.95)
kable(are4.a, caption = '95% interval in 4(a)')
95% interval in 4(a)
2.5 % 97.5 %
log_gdppc 0.0085929 0.0249035
固定效应模型(b)
dat <- dplyr::filter(income_democracy_dat, country != "Azerbaijan")
no_a_md <- plm(dem_ind ~ log_gdppc, data = dat, effect = "individual")

stargazer(no_a_md,type = 'text')
## 
## ========================================
##                  Dependent variable:    
##              ---------------------------
##                        dem_ind          
## ----------------------------------------
## log_gdppc             0.084***          
##                        (0.021)          
##                                         
## ----------------------------------------
## Observations             957            
## R2                      0.020           
## Adjusted R2            -0.161           
## F Statistic    16.202*** (df = 1; 807)  
## ========================================
## Note:        *p<0.1; **p<0.05; ***p<0.01
est4.b <- 0.2 * no_a_md$coefficients
kable(est4.b, caption = "dem_ind result in 4(b)")
dem_ind result in 4(b)
x
log_gdppc 0.0167482
are4.b <- 0.2*confint(no_a_md, 'log_gdppc', level = 0.95)
kable(are4.b, caption = '95% interval in 4(b)')
95% interval in 4(b)
2.5 % 97.5 %
log_gdppc 0.0085929 0.0249035
固定效应模型(c)
two_fixed_md <- plm(dem_ind ~ log_gdppc, data = income_democracy_dat, effect = "time")

stargazer(two_fixed_md,type = 'text')
## 
## ========================================
##                  Dependent variable:    
##              ---------------------------
##                        dem_ind          
## ----------------------------------------
## log_gdppc             0.235***          
##                        (0.008)          
##                                         
## ----------------------------------------
## Observations             958            
## R2                      0.449           
## Adjusted R2             0.444           
## F Statistic   772.299*** (df = 1; 948)  
## ========================================
## Note:        *p<0.1; **p<0.05; ***p<0.01
est4.c <- 0.2 * two_fixed_md$coefficients
kable(est4.c, caption = "dem_ind result in 4(c)")
dem_ind result in 4(c)
x
log_gdppc 0.0470213
are4.c <- 0.2*confint(two_fixed_md, 'log_gdppc', level = 0.95)
kable(are4.c, caption = '95% interval in 4(c)')
95% interval in 4(c)
2.5 % 97.5 %
log_gdppc 0.0437051 0.0503376
固定效应模型(d)
two_variable_md <- plm(dem_ind ~ log_gdppc+log_pop, data = income_democracy_dat, effect = "twoway")

stargazer(two_variable_md, type = 'text')
## 
## ========================================
##                  Dependent variable:    
##              ---------------------------
##                        dem_ind          
## ----------------------------------------
## log_gdppc               0.006           
##                        (0.032)          
##                                         
## log_pop                -0.093           
##                        (0.066)          
##                                         
## ----------------------------------------
## Observations             895            
## R2                      0.003           
## Adjusted R2            -0.209           
## F Statistic      1.240 (df = 2; 737)    
## ========================================
## Note:        *p<0.1; **p<0.05; ***p<0.01
est4.d <- 0.2 * two_variable_md$coefficients
kable(est4.d, caption = "dem_ind result in 4(d)")
dem_ind result in 4(d)
x
log_gdppc 0.0012078
log_pop -0.0185721
are4.d <- 0.2*confint(two_variable_md, 'log_gdppc', level = 0.95)
kable(are4.d, caption = '95% interval in 4(d)')
95% interval in 4(d)
2.5 % 97.5 %
log_gdppc -0.0113089 0.0137245
固定效应模型(e)
two_variable_md2 <- plm(dem_ind ~ log_gdppc+educ, data = income_democracy_dat, effect = "twoway")

stargazer(two_variable_md2, type = 'text')
## 
## ========================================
##                  Dependent variable:    
##              ---------------------------
##                        dem_ind          
## ----------------------------------------
## log_gdppc               0.019           
##                        (0.037)          
##                                         
## educ                   -0.007           
##                        (0.017)          
##                                         
## ----------------------------------------
## Observations             688            
## R2                      0.001           
## Adjusted R2            -0.180           
## F Statistic      0.166 (df = 2; 582)    
## ========================================
## Note:        *p<0.1; **p<0.05; ***p<0.01
est4.e <- 0.2 * two_variable_md2$coefficients
kable(est4.e, caption = "dem_ind result in 4(e)")
dem_ind result in 4(e)
x
log_gdppc 0.0037077
educ -0.0014747
are4.e <- 0.2*confint(two_variable_md2, 'log_gdppc', level = 0.95)
kable(are4.e, caption = '95% interval in 4(e)')
95% interval in 4(e)
2.5 % 97.5 %
log_gdppc -0.0107379 0.0181533