| |
| require(lfe) |
| |
|
|
| num_ests <- 1*2 |
| estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests), |
| y_var = rep(0,num_ests), |
| label = rep(0, num_ests)) |
|
|
| lm.beta.ses2 <- function (MOD, dta,y="ln_agprod") |
| { |
| b <- MOD$se[2] |
| sx <- sd(dta[,c("non_comp")],na.rm=TRUE) |
| |
| sy <- sd((dta[,c(y)]),na.rm=TRUE) |
| beta <- b * sx/sy |
| return(beta) |
| } |
|
|
| lm.beta2 <- function (MOD, dta,y="ln_agprod") |
| { |
| b <- MOD$coef[2] |
| sx <- sd(dta[,c("non_comp")],na.rm=TRUE) |
| |
| sy <- sd((dta[,c(y)]),na.rm=TRUE) |
| print(sx) |
| beta <- b * sx/sy |
| return(beta) |
| } |
|
|
| censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta") |
| censo_ag_wreform_tev <- censo_ag_wreform %>% |
| mutate(non_comp = ifelse(reform == 0 & Above500==1,1,0)) %>% |
| filter(reform!=1) |
|
|
| controls <- 1 |
| count<-1 |
| for (i in controls) { |
| print(i) |
| |
| |
| |
| rdests <- felm(CashCrop_Share ~ |
| non_comp |
| | 0 | 0 | Expropretario_ISTA, |
| data = censo_ag_wreform_tev, |
| subset = (reform==0 & AREA_HECTAREA > 350)) |
| |
| estimates[count,c("estimates")] <-lm.beta2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share") |
| estimates[count,c("ses")] <- lm.beta.ses2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share") |
| estimates[count,c("y_var")] <- "Cash Crop Share" |
| |
| count<-count+1 |
| |
| |
| |
| rdests <- felm(StapleCrop_Share ~ |
| non_comp |
| | 0 | 0 | Expropretario_ISTA, |
| data = censo_ag_wreform_tev, |
| subset = (reform==0 & AREA_HECTAREA > 350)) |
| |
| estimates[count,c("estimates")] <-lm.beta2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share") |
| estimates[count,c("ses")] <- lm.beta.ses2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share") |
| estimates[count,c("y_var")] <- "Staple Crop Share" |
| |
| |
| |
| |
| count<-count+1 |
| label.count<-label.count+1 |
| } |
|
|
|
|
| estimates |
|
|
| |
|
|
| |
| alpha<- 0.05 |
| Multiplier <- qnorm(1 - alpha / 2) |
|
|
| |
| data <-estimates |
|
|
| |
|
|
| |
| betas <- data |
| dim(betas) |
| betas<- betas[seq(dim(betas)[1],1),] |
|
|
| |
| MatrixofModels <- betas[c("y_var", "estimates","ses","label")] |
| colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group") |
| MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV)) |
| MatrixofModels$Group <- factor(MatrixofModels$Group, levels = paste0("Controlling for: ", labels)) |
|
|
|
|
| |
| OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError, |
| ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange", |
| ylab = NULL, xlab = NULL) |
| OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12)) |
| |
| OutputPlot <- OutputPlot + geom_hline(yintercept = 0.02, alpha = 0.05) |
| OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics |
|
|
| |
| OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.05),limits = c(-0.25,0.25)) + xlab("") |
|
|
| ggsave(filename="./Output/CoefPlot_NonCompliers.pdf", width=6, height=3) |