eBayesian Growth Rates

Chart from Doudchenko and Imbens (2017). It shows the large dip in per-capita GDP growth after reunification in 1990. It also shows that a large variety of method pretty much capture the effect (except difference in difference).

Consider that we are interested in estimating the impact of German reunification on the growth rate of GDP per capita. Say we have annual per-capital GDP for West-Germany and an assortment of other countries.

ASSUMPTION: Each country i has an average growth rate that is identical through the period. EXCEPT WEST GERMANY. West Germany has one an average growth rate before 1990 and a different one afterwards.

y_it = exp{alpha_i t}

log(y_it) = alpha_i t

log(y_i(t+1)) - log(y_it) = alpha_i

Distribution of the analog estimates of the average annual growth rates for each country.

Code is below.



eBayesian posterior distributions of growth rate before and after reunification.

Before: 1960 to 1989

After: 1990 to 2018

Code is below. Note that it uses eBayes.R

# growth_rates.R

# uses eBayes.R

x <- read.csv("gdp.csv", as.is = TRUE)


countries <- sort(unique(x$Country.Name))

countries <- countries[2:length(countries)]

years <- c(1960:2019)


Y <- matrix(NA,length(countries),length(years))

for (i in 1:length(countries)) {

country <- countries[i]

pop <- as.numeric(x[x$Series.Name=="Population, total" & x$Country.Name==country,5:dim(x)[2]])

gdp <- as.numeric(x[x$Series.Name=="GDP (current US$)" & x$Country.Name==country,5:dim(x)[2]])

Y[i,] <- gdp/pop

print(i)

}

colnames(Y) <- years

row.names(Y) <- countries


y <- log(Y[,2:dim(Y)[2]]) - log(Y[,1:(dim(Y)[2]-1)])

colnames(y) <- years[1:(length(years)-1)]

row.names(y) <- countries

y1 <- y[-which(row.names(y)=="Germany"),]

pre <- y[which(row.names(y)=="Germany"),1:30]

pre <- c(pre,rep(NA,59-length(pre)))

post <- y[which(row.names(y)=="Germany"),31:59]

post <- c(rep(NA,59-length(post)),post)

y1 <- rbind(y1,pre,post)

y1 <- y1[rowSums(is.na(y1))<59,]


alpha_hat <- rowMeans(y1, na.rm = TRUE)

hist(alpha_hat)

sd_y1 <- sd(y1, na.rm = TRUE)


b <- data.fun(t(y1),K=20)

a <- mixmod.fun(b$p_hat,b$N_hat,R=20000,eps=1e-10,maxiter=1000000,

noise=0.5*sd_y1,verb = TRUE)


means <- t(b$y_hat)%*%a$mu

mu <- a$posteriors%*%t(means)


J <- 10000

pre_dist <- post_dist <- NULL

for (i in 1:length(means)) {

pre_dist <- c(pre_dist, rep(means[i],round(J*a$posteriors[212,i])))

post_dist <- c(post_dist, rep(means[i],round(J*a$posteriors[213,i])))

print(i)

}


plot(density(pre_dist,bw=0.005),lwd=3,lty=2,main="",xlab="alpha")

lines(density(post_dist,bw=0.005),lwd=3)

legend("topright",c("before","after"),lwd=3,lty=2:1)