Updated figure file

This commit is contained in:
alex 2025-12-30 23:53:48 +00:00
parent 09d67623fa
commit 1002561b08

View File

@ -28,26 +28,26 @@ FAN_DATA <- rbind(FAN_DATA %>% filter(Year==2025) %>% mutate(Year=2024,value=ST_
GRAPH_DATA <- FAN_DATA %>% group_by(Year) %>% mutate(MIN_RANGE=lag(parse_number(Percentile)/100),MAX_RANGE=parse_number(Percentile)/100,MIN_VAL=lag(value),MAX_VAL=value) %>% filter(!is.na(DIFF)) GRAPH_DATA <- FAN_DATA %>% group_by(Year) %>% mutate(MIN_RANGE=lag(parse_number(Percentile)/100),MAX_RANGE=parse_number(Percentile)/100,MIN_VAL=lag(value),MAX_VAL=value) %>% filter(!is.na(DIFF))
GRAPH_DATA[GRAPH_DATA$Year==2024,'DIFF'] <- 0 GRAPH_DATA[GRAPH_DATA$Year==2024,'DIFF'] <- 0
return(ggplot(GRAPH_DATA %>% filter(MIN_RANGE>=0.002,MAX_RANGE<=0.998) )+geom_ribbon(aes(group=Percentile,x=Year,ymin=MIN_VAL,ymax=MAX_VAL,fill=DIFF,alpha=-DIFF))+geom_line(data=CI_BANDS %>% filter(Interval=='Median Prediction'),aes(x=Year,y=value,group=Percentile,linetype=Interval,color=Interval),linewidth=0.75)+scale_color_manual(values=c("grey80","black"),name='Median Prediction')+scale_linetype_manual(values = c("dotdash"),guide="none")+ggtitle(TITLE)+ theme_gray()+ theme(legend.position = "top",panel.grid.minor = element_blank())+scale_alpha(range = c(0, 1),guide="none")+theme(legend.text = element_blank())) return(ggplot(GRAPH_DATA %>% filter(MIN_RANGE>=0.002,MAX_RANGE<=0.998) )+geom_ribbon(aes(group=Percentile,x=Year,ymin=MIN_VAL,ymax=MAX_VAL,fill=DIFF,alpha=-DIFF))+geom_line(data=CI_BANDS %>% filter(Interval=='Median Prediction'),aes(x=Year,y=value,group=Percentile,linetype=Interval,color=Interval),linewidth=0.75)+scale_color_manual(values=c("grey80","black"),name='Median Prediction')+scale_linetype_manual(values = c("dotdash"),guide="none")+ggtitle(TITLE)+ theme_gray(base_size = 16)+ theme(legend.position = "top",panel.grid.minor = element_blank())+scale_alpha(range = c(0, 1),guide="none")+theme(legend.text = element_blank()))
} }
###Main Results ###Main Results
SCALE_FACTOR <- 1.25 SCALE_FACTOR <- 1.25
png(paste0(SAVE_RES_LOC,"Population_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC,"Population_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelhood\n(0%-100%)", trans = 'reverse') MAKE_GRAPH(RES,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelihood\n(0%-100%)", trans = 'reverse')
dev.off() dev.off()
png(paste0(SAVE_RES_LOC,"Birth_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC,"Birth_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC,"Mortality_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC,"Mortality_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC,"Migration_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC,"Migration_Fan_Chart_Main_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= "#132B43", low= "#56B1F7",name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
###########High Estiamtes ###########High Estiamtes
if(!exists("SAVE_RES_LOC_HIGH")){SAVE_RES_LOC_HIGH <- "./Results/Primary_Simulation_Results/Upper_Bound_Results/"} if(!exists("SAVE_RES_LOC_HIGH")){SAVE_RES_LOC_HIGH <- "./Results/Primary_Simulation_Results/Upper_Bound_Results/"}
@ -57,19 +57,19 @@ dev.off()
COLOR2 <- 'yellow' COLOR2 <- 'yellow'
png(paste0(SAVE_RES_LOC_HIGH,"Population_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_HIGH,"Population_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_HIGH,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse') MAKE_GRAPH(RES_HIGH,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_HIGH,"Birth_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_HIGH,"Birth_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_HIGH,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_HIGH,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_HIGH,"Mortality_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_HIGH,"Mortality_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_HIGH,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_HIGH,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_HIGH,"Migration_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_HIGH,"Migration_Fan_Chart_High_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_HIGH,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_HIGH,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
###########Low Estiamtes ###########Low Estiamtes
if(!exists("SAVE_RES_LOC_LOW")){SAVE_RES_LOC_LOW <- "./Results/Primary_Simulation_Results/Lower_Bound_Results/"} if(!exists("SAVE_RES_LOC_LOW")){SAVE_RES_LOC_LOW <- "./Results/Primary_Simulation_Results/Lower_Bound_Results/"}
@ -79,20 +79,20 @@ dev.off()
COLOR2 <- 'white' COLOR2 <- 'white'
png(paste0(SAVE_RES_LOC_LOW,"Population_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_LOW,"Population_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_LOW,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse') MAKE_GRAPH(RES_LOW,3 ,"")+geom_line(data=HIST,aes(x=Year,y=Population),color='black',linewidth=1)+ scale_y_continuous(breaks = seq(0, 35000, by = 500))+ expand_limits( y = 0)+labs(y="Population")+ scale_x_continuous(breaks = c(seq(1940, 2060, by = 10),2065))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_LOW,"Birth_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_LOW,"Birth_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_LOW,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_LOW,4 ,"")+geom_line(data=HIST %>% filter(!is.na(Births)),aes(x=Year,y=Births),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Births")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_LOW,"Mortality_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_LOW,"Mortality_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_LOW,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_LOW,5 ,"")+geom_line(data=HIST %>% filter(!is.na(Deaths)),aes(x=Year,y=Deaths),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(0, 35000, by = 10))+ expand_limits( y = 0)+labs(y="Deaths")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
png(paste0(SAVE_RES_LOC_LOW,"Migration_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600) png(paste0(SAVE_RES_LOC_LOW,"Migration_Fan_Chart_Low_Growth_Results.png"), width = 12*SCALE_FACTOR, height = 8*SCALE_FACTOR, units = "in", res = 600)
MAKE_GRAPH(RES_LOW,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelhood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none") MAKE_GRAPH(RES_LOW,6 ,"")+geom_line(data=HIST %>% filter(!is.na(Migration)),aes(x=Year,y=Migration),color='black',linewidth=0.75)+ scale_y_continuous(breaks = seq(-1000, 35000, by = 100))+ expand_limits( y = 0)+labs(y="Migration")+ scale_x_continuous(breaks = c(2009,seq(2015, 2065, by = 5)))+scale_fill_gradient(high= COLOR1, low= COLOR2,name ="Likelihood\n(0%-100%)", trans = 'reverse')+theme(legend.position = "none")
dev.off() dev.off()
################################# Key Year Summaries ################################# Key Year Summaries
@ -127,7 +127,8 @@ KEY_YEAR_DATA <- RES %>% filter(Year %in% KEY_YEARS_OF_STUDY )
AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population)) AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population))
AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean")) AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean"))
HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), linewidth= 0.75)+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 10000, by = 500)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1)) HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), linewidth= 0.75)+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 10^6, by = 1000)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1))
HISTOGRAM
png(paste0(SAVE_RES_LOC,"Population_Histogram_Main_Results.png"), width = 8, height = 12, units = "in", res = 600) png(paste0(SAVE_RES_LOC,"Population_Histogram_Main_Results.png"), width = 8, height = 12, units = "in", res = 600)
HISTOGRAM HISTOGRAM
@ -137,7 +138,7 @@ KEY_YEAR_DATA <- RES_HIGH %>% filter(Year %in% KEY_YEARS_OF_STUDY )
AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population)) AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population))
AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean")) AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean"))
HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), size = 0.75)+scale_fill_gradient(low = "grey", high = "darkgreen")+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 100000, by = 1000)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1)) HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), size = 0.75)+scale_fill_gradient(low = "grey", high = "darkgreen")+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 10^6, by = 1000)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1))
png(paste0(SAVE_RES_LOC_HIGH,"Population_Histogram_Upper_Bound.png"), width = 8, height = 12, units = "in", res = 600) png(paste0(SAVE_RES_LOC_HIGH,"Population_Histogram_Upper_Bound.png"), width = 8, height = 12, units = "in", res = 600)
HISTOGRAM HISTOGRAM
dev.off() dev.off()
@ -145,7 +146,7 @@ dev.off()
KEY_YEAR_DATA <- RES_LOW %>% filter(Year %in% KEY_YEARS_OF_STUDY ) KEY_YEAR_DATA <- RES_LOW %>% filter(Year %in% KEY_YEARS_OF_STUDY )
AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population)) AVG_VALUES <- KEY_YEAR_DATA %>% group_by(Year) %>% summarize(MED=median(Population),MEAN=mean(Population))
AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean")) AVG_VALUES <- rbind(AVG_VALUES[,1:2]%>% rename(Value=MED) %>% mutate('Summary Stat.'="Median"),AVG_VALUES[,c(1,3)] %>% rename(Value=MEAN) %>% mutate('Summary Stat.'="Mean"))
HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), size = 0.75)+scale_fill_gradient(low = "grey", high = "darkred")+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 10000, by = 500)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1)) HISTOGRAM <- ggplot(KEY_YEAR_DATA, aes(x = Population,group=-Year,Color=Year,fill=Year)) + geom_histogram(alpha=0.3,bins=800)+geom_vline(data = AVG_VALUES, aes(xintercept = Value,group=`Summary Stat.`,color = `Summary Stat.`), size = 0.75)+scale_fill_gradient(low = "grey", high = "darkred")+scale_color_manual(values=c("red","black","black"))+ facet_grid(rows=vars(Year))+ scale_x_continuous(breaks = c(seq(0, 10^6, by = 500)))+ theme_bw()+ theme(legend.position = "top",panel.grid.minor = element_blank())+ylab("Number of Simulation")+guides(fill= guide_legend(nrow = 1))
png(paste0(SAVE_RES_LOC_LOW,"Population_Histogram_Lower_Bound.png"), width = 8, height = 12, units = "in", res = 600) png(paste0(SAVE_RES_LOC_LOW,"Population_Histogram_Lower_Bound.png"), width = 8, height = 12, units = "in", res = 600)
HISTOGRAM HISTOGRAM