library(tidyverse) library(scales) library(janitor) library(paletteer) dir.create("Results", showWarnings = FALSE) source("Scripts/Load_IMPLAN.r") IMPLAN <- GET_IMPLAN_DATA() IMPLAN_DOLLAR <- IMPLAN %>% filter(Impact!='Employment') IMPLAN_DOLLAR <- IMPLAN_DOLLAR %>% group_by(Type,Year,Impact,Source) %>% mutate(value=ifelse(Region=='US',value-min(value),value) ) %>% ungroup TEMP <- IMPLAN_DOLLAR %>% filter(Year==2028) %>% mutate(value=0) IMPLAN_DOLLAR <- rbind(IMPLAN_DOLLAR,rbind(TEMP %>% mutate(Year=2025),TEMP %>% mutate(Year=2026),TEMP %>% mutate(Year=2027))) IMPLAN_DOLLAR$Impact <- factor(IMPLAN_DOLLAR$Impact,levels=c('Output','Value Added','Income','Federal','State','County')) IMPLAN_DOLLAR$Region <- factor(ifelse(IMPLAN_DOLLAR$Region=="WY",'Wyoming',"Rest of United States"),levels=rev(c("Wyoming","Rest of United States"))) IMPLAN_DOLLAR_REGION <- IMPLAN_DOLLAR %>% filter(Impact %in% c('Income','Output','Value Added')) %>% group_by(Year,Region,Impact) %>% summarize(value=sum(value)) %>% ungroup ########################Plot of total impact in US and in Wyoming IMPLAN_REGION_DOLLAR_PLOT <- ggplot(IMPLAN_DOLLAR_REGION ,aes(x=Year,y=value/10^9,fill=Region,group=Region))+geom_area()+facet_wrap(~Impact,ncol=1)+ylab("Billion Dollars")+theme_bw()+ theme(plot.title = element_text(size = 22, face = "bold"), axis.title = element_text(size = 18),axis.text = element_text(size = 16),legend.text = element_text(size = 14),strip.text = element_text(size = 14),legend.position="top")+ theme(legend.title=element_blank())+scale_fill_manual(values=c("#3C3B6E","#FFC425"))+scale_x_continuous(breaks=seq(2025,2060,by=5))+scale_y_continuous(breaks=seq(0,5000,by=1)) IMPLAN_REGION_DOLLAR_PLOT ggsave( filename = "./Results/Dollar Values of Model.png", plot = IMPLAN_REGION_DOLLAR_PLOT, width = 8.5, height = 11*(3./4), units = "in", dpi = 300) ########################Taxes #########################Post 2035 Values to show smaller scale IMPLAN_DOLLAR_PROD_PLOT <- ggplot(IMPLAN_DOLLAR %>% filter(Year>2035) ,aes(x=Year,y=value/10^6,fill=Region,group=Region))+geom_area()+facet_wrap(~Impact,ncol=1)+ylab("Million Dollars")+theme_bw()+ theme(plot.title = element_text(size = 22, face = "bold"), axis.title = element_text(size = 18),axis.text = element_text(size = 16),legend.text = element_text(size = 14),strip.text = element_text(size = 14),legend.position="top")+ theme(legend.title=element_blank())+scale_fill_manual(values=c("#3C3B6E","#FFC425"))+scale_x_continuous(breaks=seq(2025,2060,by=5))+scale_y_continuous(breaks=seq(0,5000,by=100)) ggsave( filename = "./Results/Dollar Values of Model in Production.png", plot = IMPLAN_DOLLAR_PROD_PLOT , width = 8.5, height = 11*(3./4), units = "in", dpi = 300) #############Dollar values table NPV <- IMPLAN_DOLLAR %>% mutate(value=value/10^9,Discount_0=value,Discount_2=value/(1+0.02)^(Year-2028),Discount_5=value/(1+0.05)^(Year-2028),Discount_10=value/(1+0.1)^(Year-2028)) %>% group_by(Impact,Region) %>% summarize(Discount_0=sum(Discount_0),Discount_2=sum(Discount_2),Discount_5=sum(Discount_5),Discount_10=sum(Discount_10)) %>% ungroup NPV[,3:6] <-round(NPV[,3:6],2) write.csv(NPV,"./Results/NPV_Values.csv",row.names=FALSE) ############Employment IMPLAN_EMPLOY <- DATA %>% filter(Impact=='Employment',Source=='IMPLAN') %>% group_by(Year,Region,Impact) %>% summarize(value=sum(value)) %>% ungroup IMPLAN_EMPLOY <- rbind(IMPLAN_EMPLOY, IMPLAN_EMPLOY %>% left_join(ADJUST) %>% mutate(value=value*RATIO,Region='US') %>% select(-RATIO)) IMPLAN_EMPLOY$Region <- factor(ifelse(IMPLAN_EMPLOY$Region=="WY",'Wyoming',"Rest of United States"),levels=rev(c("Wyoming","Rest of United States"))) IMPLAN_EMPLOYMENT_PLOT <- ggplot(IMPLAN_EMPLOY ,aes(x=Year,y=value,fill=Region,group=Region))+geom_area()+ylab("Employment (Full-Time Equivalent)")+theme_bw()+ theme(plot.title = element_text(size = 22, face = "bold"), axis.title = element_text(size = 18),axis.text = element_text(size = 16),legend.text = element_text(size = 14),strip.text = element_text(size = 14),legend.position="top")+ theme(legend.title=element_blank())+scale_fill_manual(values=c("#3C3B6E","#FFC425"))+scale_x_continuous(breaks=seq(2025,2060,by=5))+scale_y_continuous(breaks=c(seq(0,50000,by=1500),13000),labels = label_comma()) ggsave( filename = "./Results/Employment.png", plot = IMPLAN_EMPLOYMENT_PLOT , width = 8.5, height = 11*(2/4), units = "in", dpi = 600) ################IMPLAN IMPLAN$Year %>% unique IMPLAN <- rbind(IMPLAN, rbind(IMPLAN %>% filter(Year==2030) %>% mutate(value=0,Year=2025),IMPLAN %>% filter(Year==2030) %>% mutate(value=0,Year=2026),IMPLAN %>% filter(Year==2030) %>% mutate(value=0,Year=2027))) IMPLAN <- GET_IMPLAN_DATA() DATA <- rbind(IMPLAN,IMPLAN) DATA ggplot(DATA %>% filter(Region=='WY'),aes(x=Year,y=value,color=Type,linetype=Source))+geom_line()+facet_wrap(~Impact) DATA TOTAL_DATA <- DATA %>% filter(Region=='WY',Impact!='Employment') %>% group_by(Year,Impact,Source) %>% summarize(value=sum(value)) %>% ungroup TOTAL_DATA$Impact <- factor(TOTAL_DATA$Impact,levels=c('Output','Value Added','Income')) IMPLAN_IMPLAN <- ggplot(TOTAL_DATA ,aes(x=Year,y=value/10^9,color=Source,linetype=Source))+geom_line()+facet_wrap(~Impact,ncol=1)+theme_bw()+ theme(plot.title = element_text(size = 22, face = "bold"), axis.title = element_text(size = 18),axis.text = element_text(size = 16),legend.text = element_text(size = 14),strip.text = element_text(size = 14),legend.position="top")+ theme(legend.title=element_blank())+scale_fill_manual(values=c("#3C3B6E","#FFC425"))+scale_x_continuous(breaks=seq(2025,2060,by=5))+scale_y_continuous(breaks=seq(0,5000,by=0.5))+ylab("Billion USD") ggsave( filename = "./Results/IMPLAN_IMPLAN_COMP.png", plot = IMPLAN_IMPLAN , width = 8.5, height = 11*(2/4), units = "in", dpi = 600)