testing changes

This commit is contained in:
Alex Gebben Work 2026-05-07 16:29:02 -06:00
parent 6024203d1c
commit f4b3d3c683
2 changed files with 14 additions and 29 deletions

View File

@ -1,29 +0,0 @@
library(tidyverse)
library(fixest)
DF <- readRDS("Data/Output_Data/Full_Data_Set.rds")
DF$POST <- ifelse(DF$year>=2011,1,0)
REG_LN1 <- feols(log(AF+0.001)~POST*SBD1,cluster="wdid",data=DF)
REG_AF1 <- feols(AF~POST*SBD1,cluster="wdid",data=DF)
REG_AF1 <- feols(AF~POST*SBD1+CREP_any+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_potatoes+per_alfalfa|SBD2+SBD3+SBD4+SBD5+SBD6+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,cluster="wdid",data=DF)
REG_LN1 <- feols(log(AF+0.001)~POST*SBD1+CREP_any+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_potatoes+per_alfalfa|SBD2+SBD3+SBD4+SBD5+SBD6+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,cluster="wdid",data=DF)
DF$SBD1 <- ifelse(DF$year>=DF$SBD1_year,1,0)
DF
DF$CROPS_PRE_2009
REG_AF2 <- feols(AF~POST*SBD1+CREP_any+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_potatoes+per_alfalfa|SBD2+SBD3+SBD4+SBD5+SBD6+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,cluster="wdid",data=DF)
REG_LN2 <- feols(log(AF+0.001)~POST*SBD1+CREP_any+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_potatoes+per_alfalfa|SBD2+SBD3+SBD4+SBD5+SBD6+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,cluster="wdid",data=DF)
?i
DF$I_VAL <- DF$SBD1_year-as.numeric(DF$year)
summary(DF$I_VAL)
iplot( feols(AF~i(I_VAL,ref=-1)+CREP_any+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_potatoes+per_alfalfa|SBD2+SBD3+SBD4+SBD5+SBD6+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,cluster="wdid",data=DF))
DF$SBD1_year <- ifelse(DF$SBD1_year>10000,-Inf,DF$SBD1_year)
DF <- DF %>% group_by(wdid) %>% mutate(SBD1=max(SBD1))
etable(REG_AF1,REG_AF2,headers=c("Static SBD1","Dynamic SBD1"),fixef.group=list("Other Subdistricts"=c("SBD"),"Ditch-Year"="ditch"),file="Reg.tex",export="Reg.png",replace=TRUE)
coefplot(REG_AF1,REG_AF2)

14
temp.r Normal file
View File

@ -0,0 +1,14 @@
library(tidyverse)
library(fixest)
DF <- readRDS("Data/Output_Data/Full_Data_Set.rds") %>% mutate(year=as.numeric(year)) %>% group_by(wdid) %>% mutate(SBD1=max(SBD1)) %>% ungroup
DF %>% filter(SBD1_year<2011) %>% pull(SBD1_year) %>% unique
DF[DF$SBD1_year==2009,"SBD1_year"] <- 2011
DF[DF$SBD1==1,"POST"] <-
DF$POST <- 0
DF[DF$SBD1==1& DF$SBD1_year>=DF$year,"POST"] <- 1
#DF$POST <- ifelse(DF$year>=2011,1,0)
feols(log(AF+0.01)~SBD1+POST|wdid,data=DF)