From e8beb0bbbfceec93fd0fe3cf75ea777f678547e2 Mon Sep 17 00:00:00 2001 From: Alex Gebben Work Date: Tue, 12 May 2026 17:08:55 -0600 Subject: [PATCH] Checking on data issues --- temp.r | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/temp.r b/temp.r index f054d59..6d2b02c 100644 --- a/temp.r +++ b/temp.r @@ -1,14 +1,17 @@ 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) - +DF$SBD1 <- ifelse(DF$SBD1_year!=Inf,1,0) +DF$SBD1_year <- ifelse(DF$SBD1_year==2009,2011,DF$SBD1_year) +DF$POST <- ifelse(DF$year>=DF$SBD1_year,1,0) +feols(AF~SBD1*POST+CREP_temp+CREP_perm+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028|wdid+SBD2+SBD3+SBD4+SBD5+SBD6+wdid+ditch_2000812^year+ditch_2000631^year+ditch_Other^year+ditch_2000829^year+ditch_2000798^year+ditch_2000816^year+ditch_2000753^year+ditch_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,data=DF) +########### +#DF$SBD1_year <- ifelse(DF$SBD1_year==Inf,10000,DF$SBD1_year) +SUN_MOD <- feols(AF~sunab(SBD1_year,year)+CREP_temp+CREP_perm+SBD_half_fallow+SBD1_purchase+SBD1_temp_fallow+SB22_028+per_alfalfa+per_potatoes|SBD1+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_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,data=DF) +SUN_MOD <- feols(AF~sunab(SBD1_year,year)|wdid+SBD1+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_2000753^year+ditch_2000623^year+ditch_2200627^year+ditch_2200541^year+ditch_3500570^year,data=DF %>% filter(SBD1_year==2011|SBD1_year==Inf)) +etable(SUN_MOD,agg='cohort') +coefplot(SUN_MOD) +#######CHECK COHORTS IN HYDROBASE LOOKS LIKE MISSING DATA IN SOME LATER COHORTS. DATA MAY NEED WORK +GRAPH_DATA <- DF %>% group_by(SBD1_year,year) %>% summarize(AF=mean(AF)/max(AF)) +ggplot(GRAPH_DATA,aes(x=year,y=AF,color=as.factor(SBD1_year),group=SBD1_year))+geom_point()+geom_line()