| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| rm(list=ls()) |
|
|
| s = function(x){summary(factor(x))} |
| Num = function(x){as.numeric(as.factor(x))} |
|
|
| library(plyr);library(dplyr, warn.conflicts = FALSE) |
| library(tidyr);library(ggplot2) |
| suppressMessages(library(multiwayvcov, warn.conflicts = F)) |
| suppressMessages(library(lmtest, warn.conflicts = F)) |
| library(stargazer) |
|
|
| |
| dir.create(paste0(getwd(), '/Output/')) |
| dir.create(paste0(getwd(), '/Output/Table_1-2/')) |
| path0 = paste0(getwd(), '/Output/Table_1-2/', Sys.Date(),'/') |
| dir.create(path0) |
|
|
| A = readRDS('4-20-20_HH-KNearest_DeID_demed.RDS') |
|
|
| A = A[-which(A$Wave == 'Bangalore 2015'),] |
|
|
| Aprime = A[A$A.A7_Area.Neighborhood %in% names(which(table(A$A.A7_Area.Neighborhood) >= 30)),] |
| Aprime = Aprime[which(!is.na(Aprime$A.A7_Area.Neighborhood)),] |
| Aprime = Aprime[which(Aprime$A.A7_Area.Neighborhood != 'Bangalore NA'),] |
|
|
| A = Aprime |
| |
|
|
| |
|
|
| A$Muslim = A$C.C6_Religion == 'Muslim' |
|
|
| |
| A$HtH = A$J.J3_Source.of.water == 4 |
| WaterReg = glm('HtH ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A, family = 'binomial') |
|
|
| |
| A$Voter = A$L.L8_Voter.ID == 1 |
| VoterIDReg = glm('Voter ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A, family = 'binomial') |
|
|
| |
| A$Ration = A$L.L9_Ration.card == 1 |
| RationCardReg = glm('Ration ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A, family = 'binomial') |
|
|
| |
| A$Security = mapvalues(A$J.J24_Eviction, |
| from = c(888, 999), |
| to = c(NA, NA)) |
| SecurityReg = lm('Security ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A) |
|
|
| |
| A$L20 = mapvalues(A$L.L20_Primary.School, |
| from = c(777, 888, 999), |
| to = c(NA, NA, NA)) |
| PrimSchReg = lm('-L20 ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A) |
|
|
| |
| A$L21 = mapvalues(A$L.L21_Secondary.School, |
| from = c(777, 888, 999), |
| to = c(NA, NA, NA)) |
| SecSchReg = lm('-L21 ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A) |
|
|
| |
| A$L24 = mapvalues(A$L.L24_Waste.Disposal, |
| from = c(777, 888, 999), |
| to = c(NA, NA, NA)) |
| WasteSatReg = lm('-L24 ~ AssetSum + Muslim + City + A.A7_Area.Neighborhood', data = A) |
| |
|
|
| |
| |
|
|
| |
| MuslimServices_1 = stargazer(WaterReg, |
| VoterIDReg, |
| RationCardReg, |
| dep.var.labels.include = T, |
| model.names = FALSE, |
| digits = 2, |
| omit = c("A.A7_Area.Neighborhood","City"), |
| omit.labels = c("Neighborhood dummies?","City dummies?"), |
| omit.stat = c("rsq","ll","ser","f"), |
| order=c(2,1,3), |
| covariate.labels = c('Muslim', |
| 'Assets', |
| 'Constant'), |
| dep.var.labels = c("Water Connection","Voter ID","Ration Card"), |
| title = 'Public Services by Religion', |
| label = 'table:Muslim_Services_1') |
| writeLines(MuslimServices_1,con = paste0(path0,'Muslim_Services_1.tex')) |
| |
| |
| |
|
|
| MuslimServices_2 = stargazer(SecurityReg, |
| PrimSchReg, |
| SecSchReg, |
| WasteSatReg, |
| dep.var.labels.include = T, |
| model.names = FALSE, |
| digits = 2, |
| omit = c("A.A7_Area.Neighborhood","City"), |
| omit.labels = c("Neighborhood dummies?","City dummies?"), |
| omit.stat = c("rsq","ll","ser","f"), |
| order=c(2,1,3), |
| covariate.labels = c('Muslim', |
| 'Assets', |
| 'Constant'), |
| dep.var.labels = c("Tenure Security","Prim. Sch. Satis.","Sec. Sch. Satis.", "Waste Remov. Satis."), |
| title = 'Services Satisfaction by Religion', |
| label = 'table:Muslim_Services_2') |
| writeLines(MuslimServices_2,con = paste0(path0,'Muslim_Services_2.tex')) |
| |
| |
| |
|
|
| |
|
|
| |
| |
| |
| |
|
|
| A$L.L50_Neighborhood.Leader[which(A$L.L50_Neighborhood.Leader == '-999')] = NA |
| A$L.L50_Neighborhood.Leader = factor(A$L.L50_Neighborhood.Leader) |
|
|
| L = A %>% group_by(A.A7_Area.Neighborhood) %>% summarize( |
| HinLeaderName = names(sort(table(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Hindu')], useNA = 'no'),decreasing=T))[1], |
| MusLeaderName = names(sort(table(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Muslim')], useNA = 'no'),decreasing=T))[1], |
| nHin = sum(C.C6_Religion == 'Hindu', na.rm = T), |
| nMus = sum(C.C6_Religion == 'Muslim', na.rm = T), |
| nHinAns = sum(!is.na(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Hindu')])), |
| nMusAns = sum(!is.na(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Muslim')])), |
| nHinLeader = sort(table(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Hindu')], useNA = 'no'),decreasing=T)[1], |
| nMusLeader = sort(table(L.L50_Neighborhood.Leader[which(C.C6_Religion == 'Muslim')], useNA = 'no'),decreasing=T)[1] |
| ) |
|
|
| L = L %>% data.frame() %>% |
| mutate(Match = HinLeaderName == MusLeaderName, |
| PropHin = nHin / (nHin + nMus), |
| PropMus = nMus / (nHin + nMus)) |
|
|
|
|
| |
| s(L$Match[which(L$nMusLeader > 0 & L$nHinLeader > 0)]) |
| 37 / (37 + 21) |
| 37 + 21 |
|
|