############################################################################## # # PROJECT: ERC ANALYSIS # AUTHOR: NICOLA FOSTER # LAST UPDATED: 31 JANUARY 2021 # # FIGURE-CONCENTRATION INDEX # ############################################################################## # finding the right colours library(colortools) # using the weighted concentration index estimated using the conindex command in stata # converts the "robust standard errors" into standard deviations, where sd is estimated from # the standard error of a mean by multiplying square root of sample size # sets initial parameters n_ci1 <- 90975 sd_ci1 <- 0.03518817 ind_ci1 <- (-0.1036192) set.seed(ind_ci1) ci1 <- rnorm(n=n_ci1, mean=ind_ci1, sd=sd_ci1) # checks whether the summary simulates the original findings round(c(n=length(ci1), mean=mean(ci1), sd=sd(ci1)), 2) # sets initial parameters n_ci2 <- 56260 sd_ci2 <- 0.04633685 # sd_ci2 <- (0.04633685 * sqrt(n_ci2))/2 ind_ci2 <- 0.06548882 set.seed(ind_ci2) ci2 <- rnorm(n=n_ci2, mean=ind_ci2, sd=sd_ci2) # checks whether the summary simulates the original findings round(c(n=length(ci2), mean=mean(ci2), sd=sd(ci2)), 2) boxplot(ci1, ci2, names = c("2007", "2017"), ylab = "Concentration index (Standard Error)", col = c("#4169E1", "#E1B941"), border = c("royalblue4", "goldenrod4"), notch = TRUE) text(x=1, y=0.15, labels="n = 90 975 \n ConcentrationIndex = -0.104 \n p-Value = 0.003") text(x=2, y=0.15, labels="n = 56 260 \n ConcentrationIndex = 0.066 \n p-Value = 0.158") abline(h=0.0, col="Black", lty=2)