diff --git a/Analysis.r b/Analysis.r index f408f3a..9d32456 100644 --- a/Analysis.r +++ b/Analysis.r @@ -1,21 +1,65 @@ library(tidyverse) +library(scales) library(RcppRoll) RES <- readRDS("Results/Storage_Values_by_Facility_and_Variable_Discounts.Rds") -RES[[1]] -names(RES) -RES$Per_10.5 -read_csv("Data/Curie_Spent_Fuel_Site_Totals.csv") -CDATA <- RES$Per_5 %>% left_join(read_csv("Data/Curie_Spent_Fuel_Site_Totals.csv")) %>% mutate(Revenue=parse_number(Revenue),Year=parse_number(Year),Marginal_Value=Revenue/Total_Tons) %>% select(Facility,Year,Revenue,Marginal_Value,Total_Tons) -CDATA <- CDATA %>% group_by(Year) %>% arrange(Year,desc(Marginal_Value)) %>% mutate(CIFS_total=cumsum(Total_Tons)) %>% ungroup -CDATA <- CDATA %>% group_by(Year) %>% mutate(CIFS_20=CIFS_total<=20000,CIFS_40=CIFS_total<=40000,CIFS_80=CIFS_total<=80000,CIFS_150=CIFS_total<=150000) %>% ungroup -SUMMARY <- rbind(CDATA %>% filter(CIFS_20) %>% group_by(Year) %>% summarize(Revenue=sum(Revenue),Marginal_Value=min(Marginal_Value),Total_tons=sum(Total_Tons),CIFS_Size=20000), - CDATA %>% filter(CIFS_40) %>% group_by(Year) %>% summarize(Revenue=sum(Revenue),Marginal_Value=min(Marginal_Value),Total_tons=sum(Total_Tons),CIFS_Size=40000), -CDATA %>% filter(CIFS_80) %>% group_by(Year) %>% summarize(Revenue=sum(Revenue),Marginal_Value=min(Marginal_Value),Total_tons=sum(Total_Tons),CIFS_Size=80000), -CDATA %>% filter(CIFS_150) %>% group_by(Year) %>% summarize(Revenue=sum(Revenue),Marginal_Value=min(Marginal_Value),Total_tons=sum(Total_Tons),CIFS_Size=150000)) +RES +RES_REDUCED_FEE <- RES +RES_INCREASED_FEE <- RES + +CV <- 1.3074*(10607030-1060703) +LENGTH <- length(RES) +SUPPLY_RESULTS <- list() +for(i in 1:LENGTH){ + RES[[i]]$Revenue <-CV*as.numeric(RES[[i]]$Revenue) + RES[[i]]$Year<-as.numeric(RES[[i]]$Year) + DISCOUNT <- as.numeric(gsub("Per_","",names(RES)[i]))/100 + SUPPLY_RESULTS[[i]] <- RES[[i]] %>% left_join(read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv")) %>% mutate(Marginal_Value=Revenue/Total_Tons) %>% select(Year,Marginal_Value,Total_Tons) %>% group_by(Year) %>% arrange(Year,desc(Marginal_Value)) %>% mutate(Q=cumsum(Total_Tons),Discount=factor(percent(DISCOUNT,1),levels=c("3%","5%","7%","10%"))) +} +names(SUPPLY_RESULTS) <- names(RES) +KEY_DATA <- do.call(rbind,SUPPLY_RESULTS[c("Per_3","Per_5","Per_7","Per_10")]) +KEY_YEARS <- c(1986,2026,2066) +#Data for reduced and increased fee at 5% and 2026 +FEE_DATA <- rbind(KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Fee="Current Fee"),KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Marginal_Value=Marginal_Value/2,Fee="Reduced Fee"),KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Marginal_Value=2*Marginal_Value,Fee="Increased Fee")) +FEE_DATA$Fee <- factor(FEE_DATA$Fee,levels=c("Reduced Fee","Current Fee","Increased Fee")) + + +DEMAND_CURVE_YEARS <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500,Discount=="5%") ,aes(x=Q/1000,y=Marginal_Value/1000,group=Year,color=Year))+geom_step(linewidth=1,arrow = arrow(length = unit(0.25, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE)) +DEMAND_CURVE_YEARS + + +DEMAND_CURVE_YEARS_PLOT_FULL <-ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS,Discount=="5%" ) ,aes(x=Q/1000,y=log(Marginal_Value),group=Year,color=Year))+geom_step(linewidth=2,arrow = arrow(length = unit(0.3, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+ guides(color = guide_legend(reverse = TRUE))+scale_y_continuous(breaks=c(seq(4,20,by=0.5)))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price (Log dollar per Ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE)) +DEMAND_CURVE_YEARS_PLOT_FULL + + +DEMAND_CURVE_DISCOUNT <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500,Year==2026) ,aes(x=Q/1000,y=Marginal_Value/1000,group=Discount,color=Discount))+geom_step(linewidth=1,arrow = arrow(length = unit(0.1, "cm")))+theme_bw()+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+scale_color_manual(values = c("tomato1", "tomato2", "tomato3","tomato4")) +DEMAND_CURVE_DISCOUNT + +DEMAND_CURVE_FEE <- ggplot(FEE_DATA ,aes(x=Q/1000,y=Marginal_Value/1000,group=Fee,color=Fee))+geom_step(linewidth=1,arrow = arrow(length = unit(0.25, "cm")))+theme_bw()+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+scale_color_manual(values = c("forestgreen", "darkblue", "red3")) +DEMAND_CURVE_FEE + + + + +DEMAND_CURVE_FACET <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500) ,aes(x=Q/1000,y=Marginal_Value/1000,group=Year,color=Year))+geom_step(linewidth=1,arrow = arrow(length = unit(0.08, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+scale_y_continuous(breaks=seq(0,2000,by=200))+scale_x_continuous(breaks=seq(0,150,by=10))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+facet_grid(Discount~Year) +DEMAND_CURVE_FACET + +DEMAND_CURVE_YEARS_PLOT_FULL +DEMAND_CURVE_YEARS +DEMAND_CURVE_DISCOUNT +DEMAND_CURVE_FEE +DEMAND_CURVE_FACET + + + +### +CIFS <- readRDS("Data/Cleaned_Data/Texas_CIFS_Costs.Rds") +CIFS %>% mutate(NPC=Total/(1+0.05)^Year) %>% group_by(Phase) %>% summarize(Cost=sum(NPC)) %>% mutate(Marginal=Cost/ifelse(Phase=="Partial",5000,40000)/1000) +#Added cost per unit +M <- (3373397183-1401068722)/(40000-5000)/1000 +#Added cost for intial project +C <- 1401068722/5000/1000 + +####This is a plot of the supply curve in orange UNDER A COMPETITVE MARKET. Add in the monoplosty wating function next (value is gained by waiting another year. +DEMAND_CURVE_YEARS+geom_segment(aes(x = 0, y = C, xend = 5, yend = C),color="orange")+geom_segment(aes(x = 5, y = C, xend = 5, yend = M),color="orange")+geom_segment(aes(x = 5, y = M, xend = 140, yend = M),color="orange",arrow = arrow(length = unit(0.4, "cm"))) -###Graph the waiting value (value added by higher need, vs cost of waiting) -COST <- 500 -SUMMARY <- SUMMARY %>% group_by(CIFS_Size) %>% mutate(Waiting_Rev=lead(Revenue,1)-Revenue,Waiting_Rev=ifelse(is.na(Waiting_Rev),0,Waiting_Rev),Waiting_Cost=0.05*(Revenue-COST),Waiting_Profit=Waiting_Rev-Waiting_Cost) -ggsave(ggplot(SUMMARY ,aes(x=Year,y=Waiting_Profit,color=as.factor(CIFS_Size)))+geom_point()+ scale_x_continuous(breaks = seq(1960,2083, by=5))+theme_bw(),filename="test.png",width=20) -ggsave(ggplot(SUMMARY ,aes(x=Year,y=Revenue,color=as.factor(CIFS_Size)))+geom_point()+geom_smooth()+ scale_x_continuous(breaks = seq(1960,2083, by=5)),filename="test.png",width=20) diff --git a/Cost_Data_Proc.r b/Cost_Data_Proc.r index b3b3d3c..018990b 100644 --- a/Cost_Data_Proc.r +++ b/Cost_Data_Proc.r @@ -23,6 +23,7 @@ saveRDS(ISFSI_NUM,paste0(SAVE_DIR,"ISFSI_Data.Rds")) rm(ONE,TWO,THREE,FOUR) ######CIFS costs CIFS <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/Table_C-5_Undiscounted_Cost_Estimates_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/Table_C-6_Undiscounted_Cost_Estimates_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High")) +saveRDS(CIFS,"Data/Cleaned_Data/Texas_CIFS_Costs.Rds") ######Onsite costs ONSITE <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/Table_C-10_Undiscounted_No_Action_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/Table_C-11_Undiscounted_No_Action_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/Table_C-12_Undiscounted_No_Action_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/Table_C-13_Undiscounted_No_Action_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High"))