d0[which(d0$Dest.iso3c=='JOR'&d0$Orig.iso3c=='SYR'),'RAS']=1.1e6 #This changes refugee numbers of Jordan and Lebanon to account for unregistered
d0[which(d0$Dest.iso3c=='LBN'&d0$Orig.iso3c=='SYR'),'RAS']=1.2e6
d=d0%>%
filter(Dest.iso3c!=Orig.iso3c, Year==2016, iso3c==Dest.iso3c)%>%select(Dest.iso3c,Orig.iso3c,RAS,EFR,IWR,IWW,TFWW,TRWR)
ffm_d<-ffm%>%
filter(Dest.iso3c!=Orig.iso3c, iso3c==Dest.iso3c)
rlang::last_error()
setwd("~/Desktop/_RepoV2")
library(fst)
library(tidyverse)
library(ggplot2)
library(countrycode)
library(CoordinateCleaner)
library(ggthemes)
library(scales)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
limH=0.5e5
limL=0.01e5
yr=2016
Cr=c('AFG','IRQ','SYR','PSE')
d=read.fst('../Data/mainData_new.fst')
d=read.fst('mainData_new.fst')
ref=d%>%filter(Dest.iso3c!=Orig.iso3c,Year==yr)%>%group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(RAS=mean(RAS,na.rm=T))%>%mutate(RAS = replace_na(RAS, 0))
library(maps)
data("countryref")
crf=countryref[!duplicated(countryref$iso3),]
crf=rbind(crf,subset(crf,iso3=='DEU'))
crf[nrow(crf),'iso3']='EU'
mp <- map_data("world")%>%mutate(iso3c=countryname(.$region,'iso3c'))
g0=ggplot() +
geom_polygon(data = mp, aes(x=long, y = lat, group = group), fill="light grey", alpha=0.3)+theme_void()
refFiltL=ref%>%filter(RAS>limL,RAS<limH)
ref_OrL=refFiltL%>%
group_by(Orig.iso3c)%>%summarise_if(is.numeric,sum)%>%rename(iso3=Orig.iso3c)%>%
inner_join(crf)
ref_DeL=refFiltL%>%
group_by(Dest.iso3c)%>%summarise_if(is.numeric,sum)%>%rename(iso3=Dest.iso3c)%>%
inner_join(crf)
refLinkL=refFiltL%>%
inner_join(crf%>%select(iso3,centroid.lon,centroid.lat)%>%rename(Orig.iso3c=iso3,Orig.lon=centroid.lon,Orig.lat=centroid.lat))%>%
inner_join(crf%>%select(iso3,centroid.lon,centroid.lat)%>%rename(Dest.iso3c=iso3,Dest.lon=centroid.lon,Dest.lat=centroid.lat))
gr=g0+
geom_curve(data=refLinkL,aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat),size=0.1,col='gray',alpha=1)+
geom_point(data=ref_DeL,aes(x=centroid.lon, y=centroid.lat,label=iso3),pch=1,size=0.1,fill='gray',col=' gray',alpha=1)+
geom_point(data=ref_OrL,aes(x=centroid.lon, y=centroid.lat,label=iso3),pch=1,size=0.1,fill='gray',col=' gray',alpha=1)
refFilt=ref%>%filter(RAS>limH)
ref16_Or=refFilt%>%
group_by(Orig.iso3c)%>%summarise_if(is.numeric,sum)%>%rename(iso3=Orig.iso3c)%>%
inner_join(crf)%>%mutate(Crisis=ifelse(iso3%in%Cr,iso3,'Z_Other'))
ref16_De=refFilt%>%
group_by(Dest.iso3c)%>%summarise_if(is.numeric,sum)%>%rename(iso3=Dest.iso3c)%>%
inner_join(crf)
refLink=refFilt%>%
inner_join(crf%>%select(iso3,centroid.lon,centroid.lat)%>%rename(Orig.iso3c=iso3,Orig.lon=centroid.lon,Orig.lat=centroid.lat))%>%
inner_join(crf%>%select(iso3,centroid.lon,centroid.lat)%>%rename(Dest.iso3c=iso3,Dest.lon=centroid.lon,Dest.lat=centroid.lat))%>%
mutate(Crisis=ifelse(Orig.iso3c%in%Cr,Orig.iso3c,'Z_Other'))
gall=gr+
geom_point(data=ref16_Or,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3,fill=Crisis),alpha=0.9,pch=21)+
geom_point(data=ref16_De,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3),alpha=0.7,fill='white',pch=21)+
geom_curve(data=subset(refLink,Crisis=='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat),size=0.3,arrow=arrow(length=unit(0.05,'inches'),type='closed'))+
geom_curve(data=subset(refLink,Crisis!='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat,col=Crisis),size=0.3,arrow=arrow(length=unit(0.05,'inches'),type='closed'))+
scale_size(range = c(1, 8), name="Z_Other (M)")+scale_colour_manual(values =  mycol[c(4,3,2,1,10)])+scale_fill_manual(values = mycol[c(4,3,2,1,10)])
print(gall)
print(paste('Total Refugees:',sum(ref$RAS)/1e6))
gME=g0+
geom_point(data=ref16_Or,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3,fill=Crisis),alpha=0.9,pch=21)+
geom_point(data=ref16_De,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3),alpha=0.7,fill='white',pch=21)+
geom_curve(data=subset(refLink,Crisis=='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat),size=0.3,arrow=arrow(length=unit(0.1,'inches'),type='closed'))+
geom_curve(data=subset(refLink,Crisis!='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat,col=Crisis),size=0.5,arrow=arrow(length=unit(0.1,'inches'),type='closed'))+
scale_size(range = c(2, 16), name="Population (M)")+scale_colour_manual(values =  mycol[c(4,3,2,1,10)])+scale_fill_manual(values = mycol[c(4,3,2,1,10)])+
coord_sf(xlim = c(29,72), ylim = c(26,40), expand = FALSE)
print(gME)
print(paste('Refugee Middle East:',sum(subset(ref16_Or,centroid.lon>29&centroid.lon<45&centroid.lat<40&centroid.lat>26)$RAS)/1e6))
gAfr=g0+
geom_point(data=ref16_Or,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3,fill=Crisis),alpha=0.9,pch=21)+
geom_point(data=ref16_De,aes(x=centroid.lon, y=centroid.lat,size=RAS,label=iso3),alpha=0.7,fill='white',pch=21)+
geom_curve(data=subset(refLink,Crisis=='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat),size=0.3,arrow=arrow(length=unit(0.05,'inches'),type='closed'))+
geom_curve(data=subset(refLink,Crisis!='Z_Other'),aes(x=Orig.lon,y=Orig.lat,xend=Dest.lon,yend=Dest.lat,col=Crisis),size=0.3,arrow=arrow(length=unit(0.05,'inches'),type='closed'))+
scale_size(range = c(2, 16), name="Population (M)")+scale_colour_manual(values = mycol[c(4,3,2,1,10)])+scale_fill_manual(values = mycol[c(4,3,2,10,1)])+
coord_sf(xlim = c(-10,50), ylim = c(-10,20), expand = FALSE)
print(gAfr)
print(paste('Refugee Africa:',sum(subset(ref16_Or,centroid.lon>(-10)&centroid.lon<50&centroid.lat>(-10)&centroid.lat<20)$RAS)/1e6))
refAll=d%>%filter(Dest.iso3c!=Orig.iso3c)%>%group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(RAS=mean(RAS,na.rm=T))%>%mutate(RAS = replace_na(RAS, 0))%>%
mutate(Crisis=ifelse(Orig.iso3c%in%Cr,Orig.iso3c,'Z_Other'))%>%
group_by(Year,Crisis)%>%dplyr::summarise(RAS=sum(RAS)/1e6)
ghr=ggplot(refAll,aes(fill=Crisis,y=RAS,x=Year))+geom_bar(position='stack',stat='identity')+theme_classic()+
scale_fill_manual(values = mycol[c(4,3,2,1,10)])
print(ghr)
VWAll=d%>%mutate(RAS = replace_na(RAS, 0))%>%
#mutate(VW_a_T=RAS*(PC.a.B+PC.a.G))%>%
mutate(VW_a_T=RAS*(PC.a.T))%>%
filter(Dest.iso3c!=Orig.iso3c)%>%group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(VW_a_T=sum(VW_a_T,na.rm=T))%>% #!!Here take sum;na=T because destinations to no-water-data countries are na. These are not numerous though
mutate(Crisis=ifelse(Orig.iso3c%in%Cr,Orig.iso3c,'Z_Other'))%>%
group_by(Year,Crisis)%>%dplyr::summarise(VW_a_T=sum(VW_a_T)/1e9)
ghV=ggplot(VWAll,aes(fill=Crisis,y=VW_a_T,x=Year))+geom_bar(position='stack',stat='identity')+
theme_classic()+
scale_fill_manual(values = mycol[c(4,3,2,1,10)])
print(ghV)
countryNA=as.character(subset(read.csv('../Data/TableS1.csv'),comment=="No Footprint or IWR")$iso3c)
countryNA=as.character(subset(read.csv('TableS1.csv'),comment=="No Footprint or IWR")$iso3c)
refAll=d%>%filter(Dest.iso3c!=Orig.iso3c)%>%group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(RAS=mean(RAS,na.rm=T))%>%mutate(RAS = replace_na(RAS, 0))%>%
mutate(Crisis=ifelse(Orig.iso3c%in%countryNA,'NA',ifelse(Orig.iso3c%in%Cr,Orig.iso3c,'Z_Other')))%>%
group_by(Year,Crisis)%>%dplyr::summarise(RAS=sum(RAS)/1e6)
ghr=ggplot(refAll,aes(fill=Crisis,y=RAS,x=Year))+geom_bar(position='stack',stat='identity')+theme_classic()+
scale_fill_manual(values = mycol[c(4,3,2,1,10)])
print(ghr)
library(fst)
library(ggthemes)
library(scales)
library(weights)
library(plotly)
library(tidyverse)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
d=read.fst('mainData_new.fst')
refAll_old=d%>%filter(Dest.iso3c!=Orig.iso3c, iso3c==Dest.iso3c)%>%group_by(Dest.iso3c,Year)%>%summarise(RAS_TOT=sum(RAS,na.rm=T))
refAll = d%>%filter(Dest.iso3c!=Orig.iso3c, iso3c==Dest.iso3c) %>%
group_by(Year)%>%summarise(RAS_TOT=sum(RAS,na.rm=T))
ors=c('AFG','IRQ','SYR','PSE')
dOr=d%>%filter(Dest.iso3c!=Orig.iso3c)%>%mutate(RAS = replace_na(RAS, 0))%>%#Standard First Ops!! Double check everywhere!
mutate(VW.na.B=PC.a.B*RAS,VW.a.B=PC.a.B*RAS)%>%
group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarize(VW.a.B=sum(VW.na.B,a.rm=T),VW.a.B=sum(VW.a.B,na.rm=T))%>%#na.rm=T because dest==nowaterdata is na
mutate(or=ifelse(Orig.iso3c%in%ors,Orig.iso3c,'Other'))%>%
group_by(or,Year)%>%dplyr::summarize(VW.na.B=sum(VW.a.B)/1e6,VW.a.B=sum(VW.a.B)/1e6)
dOr$or=factor(dOr$or,levels=c('Other',ors))
Fig2E=ggplot(dOr, aes(x=Year, y=VW.a.B, fill=or)) +
geom_area()+
theme_classic()+
scale_fill_manual(values = mycol[c(10,4,3,2,1)])+ylab('Short Run displaced BWD\n[MCM/y]')
print(Fig2E)
dests=c('IRN','JOR','LBN','PAK','TUR')
EU=c('AUT','BEL','BGR','HRV','CYP','CZE','DNK','EST','FIN','FRA','DEU','GRC','HUN','IRL','ITA','LVA','LTU','LUX','MLT','NLD','POL','PRT','ROM','SVK','SVN','ESP','SWE')
dDe=d%>%filter(Dest.iso3c!=Orig.iso3c)%>%mutate(RAS = replace_na(RAS, 0))%>%##Standard first op!
mutate(VW.na.B=PC.na.B*RAS,VW.a.B=PC.a.B*RAS)%>%
group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarize(VW.na.B=sum(VW.na.B,na.rm=T),VW.a.B=sum(VW.a.B,na.rm=T))%>%#na.rm=T because dest==nowaterdata is na
mutate(de=ifelse(Dest.iso3c%in%c(dests,EU),Dest.iso3c,'Other'))%>%
mutate(de=ifelse(de%in%EU,'EU',de))%>%##Compile Europe!!
group_by(de,Year)%>%dplyr::summarize(VW.na.B=sum(VW.na.B)/1e6,VW.a.B=sum(VW.a.B)/1e6)
dDe$de=factor(dDe$de,levels=c('Other','IRN','PAK','EU','JOR','LBN','TUR'))
Fig2F=ggplot(dDe, aes(x=Year, y=VW.a.B, fill=de)) +
geom_area()+
theme_classic()+
scale_fill_manual(values = mycol[c(10,5,2,6,4,3,1)])+ylab('Long Run displaced BWD\n[MCM/y]')
print(Fig2F)
library(fst)
library(ggthemes)
library(scales)
library(weights)
library(plotly)
library(tidyverse)
library(boot)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
d=read.fst('mainData.fst')%>%
mutate(RAS = replace_na(RAS, 0))%>%
mutate(VW_a_B=RAS*PC.a.B,VW_a_Tot=RAS*(PC.a.G+PC.a.B),VW_na_B=RAS*PC.na.B,VW_na_Tot=RAS*(PC.na.G+PC.na.B))
d=read.fst('mainData_new.fst')%>%
mutate(RAS = replace_na(RAS, 0))%>%
mutate(VW_a_B=RAS*PC.a.B,VW_a_Tot=RAS*(PC.a.T),VW_na_B=RAS*PC.na.B,VW_na_Tot=RAS*(PC.na.T))
pc0=d%>% filter(Dest.iso3c!=Orig.iso3c)%>%select(Dest.iso3c,Orig.iso3c,Year,PC.a.B,PC.a.T,PC.na.B,PC.na.T)%>%#this groups across origin#Removes "emigration" rows, which are equivalent to the assumilation PC value
group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),sum,na.rm=T))
pc0L=d%>% filter(Dest.iso3c!=Orig.iso3c,Dest.iso3c==iso3c)%>%select(Dest.iso3c,Orig.iso3c,Year,PC.a.B,PC.a.T,PC.na.B,PC.na.T,RAS)%>%
rename_with(~paste0(., ".L"), -c("Dest.iso3c", "Orig.iso3c","Year",'RAS'))
pc0T=d%>% filter(Dest.iso3c!=Orig.iso3c,Dest.iso3c!=iso3c)%>%select(Dest.iso3c,Orig.iso3c,Year,PC.a.B,PC.a.T,PC.na.B,PC.na.T)%>%
rename_with(~paste0(., ".T"), -c("Dest.iso3c", "Orig.iso3c","Year"))%>%
group_by(Dest.iso3c,Orig.iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),sum,na.rm=T))
pc0<-pc0%>%full_join(pc0L)%>%full_join(pc0T)
pcNa<-pc0%>%group_by(Dest.iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),~weighted.mean(., RAS,na.rm=T)))%>%## weighted mean to model a composite refugee (no assimilation)
select(Dest.iso3c,Year,PC.na.B,PC.na.T,PC.na.B.L,PC.na.T.L,PC.na.B.T,PC.na.T.T)#Gives NA for RAS=0. These are rows that are in the water database but not in the refugee one! IRQ->MMR 2015 is an example
pcA<-pc0%>%group_by(Dest.iso3c,Year)%>%summarise(across(where(is.numeric),mean,na.rm=T))%>%## simple mean to model an assimilated refugee
select(Dest.iso3c,Year,PC.a.B,PC.a.T,PC.a.B.L,PC.a.T.L,PC.a.B.T,PC.a.T.T)
pc<-pcNa%>%left_join(pcA)%>% #per capita annual footprint of a refugee by country.
mutate(PC.na.B = coalesce(PC.na.B,PC.a.B),PC.na.T = coalesce(PC.na.T,PC.a.T))%>%#NA values for no assimilation arise when there is no immigration. We here replace them with the footprint of the native pop (assimmilated)
rename(iso3c=Dest.iso3c)#This is to facilitate the merge
wbNeg=d%>% filter(Dest.iso3c==Orig.iso3c)%>%##Outgoing!
group_by(iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),sum,na.rm=T))%>%#tGroup by water origin. It is the water that does not need to be provided anymore if refugees move out.
select(iso3c,Year,VW_a_B,VW_a_Tot,VW_na_B,VW_na_Tot)%>%##
mutate_at(vars(-iso3c,-Year),`-`)##Sets negative,
wbPos=d%>% filter(Dest.iso3c!=Orig.iso3c)%>%
group_by(iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),sum,na.rm=T))%>%#Group by water origin. It is the water that now has to be provided if refugees move in
select(iso3c,Year,VW_a_B,VW_a_Tot,VW_na_B,VW_na_Tot)
wb<-bind_rows(wbNeg, wbPos) %>%group_by(iso3c,Year) %>%summarise_all(sum)%>%##Sums two tibles.
mutate_all(., ~coalesce(., 0))#NAs in wb are locations with no local water footprint (i.e. no imigration), so replace with zero
wstr<-d%>%group_by(iso3c,Year)%>%dplyr::summarise(across(where(is.numeric),mean,na.rm=T))%>%select(iso3c,Year,EFR,IWR,IWW,TFWW,TRWR,Pop.iso3c)%>%
mutate(S_SDG=100*TFWW/(TRWR-EFR))%>%mutate(WaterAvail.PC=(TRWR-EFR)/Pop.iso3c)#mean of ratio is not ratio of means!
pltdf0<-wb%>%
full_join(pc)%>%
full_join(wstr)
pltdf0$PC.na.B=ifelse(pltdf0$VW_na_B<0,pltdf0$PC.a.B,pltdf0$PC.na.B)
pltdf0$PC.na.B.L=ifelse(pltdf0$VW_na_B<0,pltdf0$PC.a.B.L,pltdf0$PC.na.B.L)
pltdf0$PC.na.B.T=ifelse(pltdf0$VW_na_B<0,pltdf0$PC.a.B.T,pltdf0$PC.na.B.T)
pltdf=pltdf0%>%filter(Year==2016)
wmn=function(x) return(weighted.mean(x$val,x$w,na.rm=T))
xmn1=pltdf%>%filter(VW_na_B >0)%>%mutate(val=(WaterAvail.PC),w=(abs(VW_na_B)))%>%select(iso3c,val,w)
xmn2=pltdf%>%filter(VW_na_B <=0)%>%mutate(val=(WaterAvail.PC),w=(abs(VW_na_B)))%>%select(iso3c,val,w)
ymn1=pltdf%>%filter(VW_na_B >0)%>%mutate(val=(PC.na.B),w=(abs(VW_na_B)))%>%select(iso3c,val,w)
ymn2=pltdf%>%filter(VW_na_B <=0)%>%mutate(val=(PC.na.B),w=(abs(VW_na_B)))%>%select(iso3c,val,w)
dfL=data.frame(x=c(wmn(xmn1),wmn(xmn2)),y=c(wmn(ymn1),wmn(ymn2)),cl=c(T,F,T,F))
py=wtd.t.test(ymn1$val,ymn2$val,ymn1$w,ymn2$w)$coef[3]
px=wtd.t.test(xmn1$val,xmn2$val,xmn1$w,xmn2$w)$coef[3]
fig2A=ggplot()+
geom_point(data=pltdf%>%filter(abs(VW_na_B) > 10e6),aes(x=WaterAvail.PC,y=PC.na.B,size=abs(VW_na_B)/1e6,fill=(VW_na_B >0),label=iso3c),alpha=0.7,pch=21)+
theme_classic()+scale_size(range = c(1,10))+scale_y_continuous(trans='log10')+scale_x_continuous(trans='log10')+
ylab('Short Range BWD (m3 per year per refugee)')+
xlab('Blue Water Availability (m3 per year per person)')+
scale_fill_manual(values = mycol[c(1,3)])
st=data.frame(x=c(10^rep(min(layer_scales(fig2A)$x$range$range),1),mean(c(wmn(xmn1),wmn(xmn2)))),
y=c(mean(c(wmn(ymn1),wmn(ymn2))),10^rep(min(layer_scales(fig2A)$y$range$range),1)),
p=c(py,px),stars=ifelse(c(py,px)<0.01,'***',ifelse(c(py,px)<0.05,'**',ifelse(c(py,px)<0.1,'*',''))))
fig2A=fig2A+
geom_vline(data=dfL,aes(xintercept = x,col=cl),lwd=0.1,alpha=1,lty=2)+geom_hline(data=dfL,aes(yintercept = y,col=cl),lwd=0.1,alpha=1,lty=2)+
geom_text(data=st, aes( x=x, y=y, label=stars),fontface="bold" ,size=5,col=1)+
scale_color_manual(values = mycol[c(1,3)])
print(fig2A)
ggplotly(fig2A)
view(d%>%filter(Year==2016,iso3c==Dest.iso3c,Dest.iso3c!=Orig.iso3c,VW_a_B>=1e7)) ##Only from blue!
library(fst)
library(tidyverse)
library(ggthemes)
library(scales)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
d=read.fst('mainData_new.fst')%>%
mutate(RAS = replace_na(RAS, 0))
d=d%>%
#mutate(VW_a_B=RAS*PC.a.B,VW_a_Tot=RAS*(PC.a.G+PC.a.B),VW_na_B=RAS*PC.na.B,VW_na_Tot=RAS*(PC.na.G+PC.na.B))%>%
mutate(VW_a_B=RAS*PC.a.B,VW_a_Tot=RAS*(PC.a.T),VW_na_B=RAS*PC.na.B,VW_na_Tot=RAS*(PC.na.T))%>%
filter(Dest.iso3c=='JOR'&Orig.iso3c=='SYR')%>%
#Aggregate water origins other than SYR, JOR, SAU , EGY and USA into "others"
mutate(Orig2=ifelse(iso3c%in%c('SYR','JOR','SAU','EGY','USA'),iso3c,'Other'))%>%
group_by(Orig2,Year)%>%summarise(across(where(is.numeric),sum))%>%mutate(Orig2=factor(Orig2,levels= rev(c('JOR','SYR','SAU','EGY','USA','Other'))))
yrm=read.csv('Yrmk.csv')#This gives changes in annual flows compared to 2005-2010 averages
yrm=yrm%>%mutate(D_Qymk_m=D_Qymk,D_Qymk_M=D_Qymk)
yrm=yrm%>%select(c(Year,D_Qymk,D_Qymk_ref,D_Qymk_ref_use))%>%pivot_longer(cols=c(D_Qymk,D_Qymk_ref,D_Qymk_ref_use))%>%
cbind(yrm%>%select(c(D_Qymk_m,D_Qymk_ref_m,D_Qymk_ref_use_m))%>%pivot_longer(cols=c(D_Qymk_m,D_Qymk_ref_m,D_Qymk_ref_use_m),values_to='min',names_to='name2'))%>%
cbind(yrm%>%select(c(D_Qymk_M,D_Qymk_ref_M,D_Qymk_ref_use_M))%>%pivot_longer(cols=c(D_Qymk_M,D_Qymk_ref_M,D_Qymk_ref_use_M),values_to='max',names_to='name3'))%>%
mutate(name=factor(name,levels=c('D_Qymk','D_Qymk_ref','D_Qymk_ref_use')))
g2=ggplot() +
geom_area(data=d%>%filter(Year>2009&Year<2016), aes(x = Year, y = VW_na_B/1e6, fill = Orig2))+ylab('MCM/yr')+
scale_fill_manual('Footprint of Syrians in JOR\nby blue water origin',values=mycol[c(10,9,8,7,2,4)],labels=rev(c('JOR (Local)','SYR','SAU','EGY','USA','Other Imports')))+
geom_line(data=yrm,aes(x=Year,y=value,lty=name),col='blue')+geom_ribbon(data=yrm,aes(x=Year,ymin = min , ymax = max,lty=name), alpha = 0.15)+theme_classic()+
scale_linetype_manual("Yarmouk Flow Increase\nvs. '06-10 average",values=c(1,2,3),labels=c('Total','Attributable to Refugees','Attr. to Refugees and used by JOR'))+
theme(plot.margin=unit(c(25, 5.5, 5.5, 5.5), "points"))
print(g2)
library(tidyverse)
library(ggthemes)
library(scales)
library(plotly)
library(fst)
library(RColorBrewer)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
pl=read.csv('ResettlementPlan.csv',header=T)%>%select(Dest.iso3c,RES_SUB)
ref20=read.csv('unhcr2020.csv',skip=14)%>%#Out Migration by destination
mutate(RAS=Refugees.under.UNHCR.s.mandate+Asylum.seekers+ifelse(is.na(Venezuelans.displaced.abroad),0,Venezuelans.displaced.abroad))%>%
rename(Orig.iso3c=Country.of.origin..ISO.,Dest.iso3c=Country.of.asylum..ISO.)%>%
select(RAS,Orig.iso3c,Dest.iso3c)%>%
mutate_if(is.factor,as.character)%>%
filter(Dest.iso3c!=Orig.iso3c)%>%mutate(RAStot=RAS)
d0=read.fst('mainData_new.fst')
d=d0%>%filter(Year==2016,Dest.iso3c!=Orig.iso3c,Dest.iso3c==iso3c)%>% #We exclude outmigration and are only interested in locally extracted water; now Dest.iso3c==iso3c!
select(Dest.iso3c,Orig.iso3c,PC.na.B,EFR:TRWR)%>%left_join(ref20)%>%
mutate(RAS = replace_na(RAS, 0))%>%
group_by(Dest.iso3c)%>%dplyr::summarise(PC.na.B.L=weighted.mean(PC.na.B,RAS,na.rm=T),RAS=sum(RAS,na.rm=T),RAStot=sum(RAStot,na.rm=T),IWR=mean(IWR),IWW=mean(IWW),TRWR=mean(TRWR),EFR=mean(EFR))%>%
mutate(DS_d=(PC.na.B.L/(IWR/IWW))/(TRWR-EFR))%>% #marginal SR effect of a refugee on ntl water stress
right_join(pl)%>%
mutate(lamc=log(RAS)-log(RES_SUB))%>%#average hardship. Uses UNHCR refugees.
rename(RASin=RAS)%>%#we use the number of registered refugees as cap
select(Dest.iso3c,lamc,RASin,DS_d,RES_SUB,RAStot)
d=d0%>%filter(Year==2016,Dest.iso3c!=Orig.iso3c,Dest.iso3c==iso3c)%>% #We exclude outmigration and are only interested in locally extracted water; now Dest.iso3c==iso3c!
select(Dest.iso3c,Orig.iso3c,PC.a.B,EFR:TRWR)%>%left_join(ref20)%>%
mutate(RAS = replace_na(RAS, 0))%>%
group_by(Dest.iso3c)%>%dplyr::summarise(PC.a.B.L=weighted.mean(PC.a.B,RAS,na.rm=T),RAS=sum(RAS,na.rm=T),RAStot=sum(RAStot,na.rm=T),IWR=mean(IWR),IWW=mean(IWW),TRWR=mean(TRWR),EFR=mean(EFR))%>%
mutate(DS_d=(PC.a.B.L/(IWR/IWW))/(TRWR-EFR))%>% #marginal SR effect of a refugee on ntl water stress
right_join(pl)%>%
mutate(lamc=log(RAS)-log(RES_SUB))%>%#average hardship. Uses UNHCR refugees.
rename(RASin=RAS)%>%#we use the number of registered refugees as cap
select(Dest.iso3c,lamc,RASin,DS_d,RES_SUB,RAStot)
runALPHA=function(beta=10){
#estimate mu
getMu=function(mua0){
xtmpc=NULL
for(i in 1:nrow(d)){
xtmpp=with(d[i,],min(c(  RASin*exp(lamc*(beta*DS_d-mua0))     ,RASin)))
xtmpc=c(xtmpc,xtmpp)
}
return(sum(xtmpc)-sum(d$RES_SUB))
}
sol=uniroot(getMu,c(0,1e3),extendInt="downX",check.conv=TRUE,tol=1e-16)
mua=sol$root
#Get xc
xc=NULL
for(i in 1:nrow(d)){
xtmp=with(d[i,],min(c(  RASin*exp(lamc*(beta*DS_d-mua))     ,RASin))) #number of swapped refugees
xc=c(xc,xtmp)
}
xc=ifelse(xc<1,1,xc)
d$xc=xc
#Estimate pareto space
Dtau=(sapply(1:nrow(d),function(i) integrate(function(x) return(-1/d$lamc[i]*log(x/d$RASin[i])),0,d$xc[i])$value)) #Change to analytical expression when available
DDS=(d$DS_d*d$xc)
SIM=(sapply(1:nrow(d),function(i) return(min(c(d$RES_SUB[i],d$xc[i])))))/sum(d$RES_SUB)
return(list(data.frame(beta,d$Dest.iso3c,d$xc,Dtau,DDS,SIM),data.frame(beta,Dtau=sum(Dtau),DDS=sum(DDS),SIM=sum(SIM),mua)))
}
out=NULL
out2=NULL
out3=NULL
xold=d$RES_SUB
for(beta in 10^seq(6,10,0.01)){
# print(beta)
sol=runALPHA(beta)
out=rbind(out,sol[[2]])
out2=rbind(out2,data.frame(sol[[1]]))
deltax=sol[[1]]$d.xc-xold
xold=sol[[1]]$d.xc
out3=rbind(out3,data.frame(deltax,beta,country=sol[[1]]$d.Dest.iso3c))
}
out$Dtau_=out$Dtau/max(out$Dtau)
out$DDS_=out$DDS/min(out$DDS)
g=ggplot()+geom_point(data=out,aes(x=DDS_,y=Dtau_,col=SIM,lab=log10(beta))) +scale_colour_gradient(low='#c6e2ff',high='#4E79A7')+
xlab('Relative loss in average water stress compared to UN plan')+ylab('Relative loss in individual Welfare compared to UN plan')+labs(col="Similarity\nto UN plan")+
theme_classic()+scale_x_continuous(trans='log2')+scale_y_continuous(trans='log2',limits=c(0.25,1))
plt=ggplot(out2, aes(fill=d.Dest.iso3c, y=d.xc, x=as.factor(log10(beta)))) +
geom_bar(position="stack", stat="identity")
betas=c(1e6,10^6.48,10^6.8,1e10)
paretoplt=g+geom_point(data=out[which(out$beta%in%betas),],aes(x=DDS_,y=Dtau_),size=6,pch=21,fill=NA)
i=1
outpie=NULL
for(i in 1:length(betas)){
print(i)
outpie=rbind(outpie,out2%>%filter(beta==betas[i])%>%mutate(gp=ifelse(d.xc>sum(d$RES_SUB)/20,as.character(d.Dest.iso3c),'Others'))%>%group_by(gp,beta)%>%summarize_if(is.numeric,sum))
}
outpie$gp=factor(outpie$gp,levels=c('TUR','YEM','LBN','JOR','IRN','ETH','TZA','UGA','Others'))
pies=ggplot(outpie,aes(x='',y=d.xc,fill=gp))+geom_bar(width=1,stat='identity')+coord_polar('y',start=0)+theme_classic()+facet_wrap(vars(beta),nrow=1)+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),axis.title.y=element_blank(),axis.ticks.y=element_blank())+scale_fill_manual(values = mycol[c(1:8,10)])
outstack=out2%>%filter(beta%in%betas)%>%rename(Dest.iso3c =d.Dest.iso3c)%>%left_join(d)%>%
mutate(Sr_Plan=DS_d*(RAStot-d.xc),Sr_NoPlan=DS_d*d.xc,Sr=DS_d*RAStot)%>%mutate(beta=as.factor(beta))%>%filter(Sr>0.01)%>%
select(beta,Dest.iso3c,Sr_Plan,Sr_NoPlan)%>%
pivot_longer(Sr_Plan:Sr_NoPlan)
outstack$name=factor(outstack$name,levels=c('Sr_NoPlan','Sr_Plan'))
bars=ggplot(outstack,aes(x=Dest.iso3c,y=value,fill=name))+geom_bar(width=0.8,stat='identity')+facet_wrap(~beta,nrow=1)+
theme_classic()+ylab('SR refugee-associated water stress (∆S)')+scale_fill_manual(values = mycol[c(10,1)])
print(paretoplt)
print(pies)
print(bars)
library(tidyverse)
library(ggthemes)
library(scales)
library(rmatio)
library(plotly)
library(abind)
library(reshape2)
library(fst)
library(countrycode)
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
d0=read.fst('../Data/mainData_new.fst')%>%mutate(RAS = replace_na(RAS, 0))%>%filter(Dest.iso3c%in%c('JOR','YEM','LBN','PAK','IRN','DEU'))
d0=read.fst('mainData_new.fst')%>%mutate(RAS = replace_na(RAS, 0))%>%filter(Dest.iso3c%in%c('JOR','YEM','LBN','PAK','IRN','DEU'))
d0[which(d0$Dest.iso3c=='JOR'&d0$Orig.iso3c=='SYR'),'RAS']=1.1e6 #This changes refugee numbers of Jordan and Lebanon to account for unregistered
d0[which(d0$Dest.iso3c=='LBN'&d0$Orig.iso3c=='SYR'),'RAS']=1.2e6
d=d0%>%
filter(Dest.iso3c!=Orig.iso3c, Year==2016, iso3c==Dest.iso3c)%>%select(Dest.iso3c,Orig.iso3c,RAS,EFR,IWR,IWW,TFWW,TRWR)%>%left_join(ffm)
dmod0=d%>%filter(is.na(PC.na.B))%>%select(FAOBalance.Number,RAS,Orig.iso3c,Dest.iso3c)
dmodNAs=d%>%filter(Dest.iso3c%in%dmod0$Dest.iso3c)%>%select(FAOBalance.Number,Dest.iso3c,iso3c,PC.na.B,RAS)%>%drop_na()%>% #non assimilated is the weighted average of the other origin countries.
group_by(FAOBalance.Number,Dest.iso3c,iso3c)%>%summarise(PC.na.B=weighted.mean(PC.na.B,RAS,na.rm=T))
setwd("~/Google Drive/My Drive/VW Syria/_FinalTablesAndFigures/Fig3")
ffm=read.fst('../Data/blue2016.fst')%>%
filter(Dest.iso3c%in%c('JOR','YEM','LBN','PAK','IRN','DEU'))%>%
filter(Dest.iso3c!=Orig.iso3c& iso3c==Dest.iso3c)
d0=read.fst('../Data/mainData_new.fst')%>%mutate(RAS = replace_na(RAS, 0))%>%filter(Dest.iso3c%in%c('JOR','YEM','LBN','PAK','IRN','DEU'))
d0[which(d0$Dest.iso3c=='JOR'&d0$Orig.iso3c=='SYR'),'RAS']=1.1e6 #This changes refugee numbers of Jordan and Lebanon to account for unregistered
d0[which(d0$Dest.iso3c=='LBN'&d0$Orig.iso3c=='SYR'),'RAS']=1.2e6
d=d0%>%
filter(Dest.iso3c!=Orig.iso3c, Year==2016, iso3c==Dest.iso3c)%>%select(Dest.iso3c,Orig.iso3c,RAS,EFR,IWR,IWW,TFWW,TRWR)%>%left_join(ffm)
dmod0=d%>%filter(is.na(PC.na.B))%>%select(FAOBalance.Number,RAS,Orig.iso3c,Dest.iso3c)
dmodNAs=d%>%filter(Dest.iso3c%in%dmod0$Dest.iso3c)%>%select(FAOBalance.Number,Dest.iso3c,iso3c,PC.na.B,RAS)%>%drop_na()%>% #non assimilated is the weighted average of the other origin countries.
group_by(FAOBalance.Number,Dest.iso3c,iso3c)%>%summarise(PC.na.B=weighted.mean(PC.na.B,RAS,na.rm=T))
dmod=dmod0%>%select(RAS,Orig.iso3c,Dest.iso3c)%>%left_join(dmodNAs)
d<-d%>%filter(!is.na(PC.na.B))%>%bind_rows(dmod) #remaining NA are for folks moving into countries with no water data!
FoodFamDS=d%>%mutate(VW.na.B=RAS*PC.na.B)%>% #get total waterfootprints for all refugees.
group_by(Dest.iso3c,FAOBalance.Number)%>%summarise(WFb=sum(VW.na.B,na.rm=T))%>% #sum across refugee origins.
left_join(d%>%group_by(Dest.iso3c)%>%summarise(EFR=mean(EFR,na.rm=T),IWR=mean(IWR,na.rm=T),IWW=mean(IWW,na.rm=T),TFWW=mean(TFWW,na.rm=T),TRWR=mean(TRWR,na.rm=T)))%>%
mutate(DS=(WFb*(IWW/IWR))/(TRWR-EFR)) #finally get DS by family of goods and per country of destination across refugee types.
dr='../../AdamsFinalDataset/Background Data/'
load(paste(dr,"../Produced Data/FTonandPhi.RData",sep=''))
fd=FTonandPhi%>%filter(Year==2016)%>%select(iso3,FPC,Item.Code)%>%rename(Orig.iso3c=iso3)
fd$FPC=ifelse(fd$FPC>0,fd$FPC,0) #respect non negativity values.
load(paste(dr,"./Organizational Tables/countries.RData",sep='')) ##dataset of countries
countriesInd=which(countries$iso3c%in%unique(fd$Orig.iso3c)) ##those are the countries included in the analysis.
cntr=countries$iso3c[countriesInd]
Fams0=read.csv(paste(dr,'./Organizational Tables/GoodsAndFamilies.csv',sep=''),skip=1,header=F)[,c(2,3,15,16,18,19)]#Families-Good dataset
Fams=Fams0%>%rename(Commodity.Name=V2,Commodity.Code=V3 ,FAOBalance.Number=V15,FAOBalance.Name=V16,NewFamily.Number=V18,NewFamily.Name=V19)%>%rename(Item.Code=NewFamily.Number)
dr='../../AdamsFinalDataset/Background Data/VW Data/'
load(paste(dr,"../FAO Balance/FAOBalanceNew_clean.RData",sep=''))
rLoc=FAOBalanceNew_clean%>%filter(Element%in%c('Production', 'Import Quantity','Stock Variation'),Item.Code%in%c(Fams$FAOBalance.Number),Year==2016)%>%
pivot_wider(id_cols=c('Area.Code','Item.Code'),names_from='Element',values_from='Value')%>%rename(Import='Import Quantity')%>%
mutate(r=Production/(Production+Import))%>%rename(FAOBalance.Number=Item.Code)%>%
left_join(countries%>%rename(Area.Code=FAO.code)%>%select(Area.Code,iso3c))%>%
left_join(Fams%>%select(FAOBalance.Number,Item.Code)%>%distinct())%>%
select(iso3c,r,Item.Code,FAOBalance.Number)%>%rename(Dest.iso3c=iso3c)
load(paste(dr,"../FAO Trade & Production/E.RData",sep=''))
load(paste(dr,"../FAO Trade & Production/I.RData",sep=''))
load(paste(dr,"../FAO Trade & Production/P.RData",sep=''))
wgt0=E%>%left_join(I)%>%left_join(P)%>%
filter(Year==2016)%>%replace(is.na(.), 0)%>% #NA indicates zero production so replace with zero.
mutate(DSQ=Imports+ifelse(Production-Exports>0,Production-Exports,0))%>%#Estimate DSQ==Imports + whatever production is not exported. There seems to be a discrepancy between production and trade data so the "normal" calculation fo DSQ is messed up.
rename(Commodity.Code=Item.Code)%>%
left_join(Fams)
wgt=wgt0%>%
left_join(wgt0%>%group_by(Area.Code,FAOBalance.Number)%>%summarise(DSQFam=sum(DSQ,na.rm=T)))%>%
mutate(w=DSQ/DSQFam)%>%
select(iso3,FAOBalance.Number, Commodity.Code,w)%>%rename(Dest.iso3c=iso3)
FoodInv=d%>%left_join(fd)%>%mutate(TonsT=FPC*RAS)%>%#Food consumption per country of origin and per food type
#Get total of each food type consumed by all refugees (across origins) in each destination country
group_by(Dest.iso3c,Item.Code)%>%summarise(TonsT=sum(TonsT,na.rm=T),RAS=sum(RAS,na.rm=T))%>% # RAS
#Get the subset of each food type that is *sourced locally*.
left_join(rLoc)%>%mutate(Tons=r*TonsT)%>%
#disaggregate families of goods --> commodities
left_join(Fams)%>%left_join(wgt)
leo <- d%>%left_join(fd)%>%mutate(TonsT=FPC*RAS) %>%
select(Dest.iso3c,Orig.iso3c,RAS,iso3c,Item.Code,TonsT)
leo_un <- unique(leo)%>%
group_by(Dest.iso3c,Item.Code)%>%summarise(TonsT=sum(TonsT,na.rm=T),RAS=sum(RAS,na.rm=T)) # RAS
FoodInv=d%>%left_join(fd)%>%mutate(TonsT=FPC*RAS)%>%
select(Dest.iso3c,Orig.iso3c,RAS,iso3c,Item.Code,TonsT)#Food consumption per country of origin and per food type
FoodInv<-unique(FoodInv)%>%
#Get total of each food type consumed by all refugees (across origins) in each destination country
group_by(Dest.iso3c,Item.Code)%>%summarise(TonsT=sum(TonsT,na.rm=T),RAS=sum(RAS,na.rm=T))%>% # RAS
#Get the subset of each food type that is *sourced locally*.
left_join(rLoc)%>%mutate(Tons=r*TonsT)%>%
#disaggregate families of goods --> commodities
left_join(Fams)%>%left_join(wgt)
FoodImp=NULL
for(i in unique(FoodInv$Commodity.Code)){ #Loop across commodity types
print(i)
if(!file.exists(paste(dr,'VWT_1986-2016/VWT_item',i,'.mat',sep=''))) next
print('found')
m=read.mat(paste(dr,'VWT_1986-2016/VWT_item',i,'.mat',sep=''))$VWT
if(length(dim(m))==3){ VWT=m[,,dim(m)[3]] #Virtual water trade matrix (B+G)
}else VWT=m
mm=read.mat(paste(dr,'uWF_1961-2016/uWF_item',i,'.mat',sep=''))$uWF
if(!is.null(dim(mm))){ uWF=mm[,ncol(mm)] #Unit water footprint (B+G)
}else uWF=mm
mmm=read.mat(paste(dr,'uWF_1961-2016/uWFb_item',i,'.mat',sep=''))$uWF
if(!is.null(dim(mmm))){ uWFb=mmm[,ncol(mmm)] #Unit blue water footprint
}else uWFb=mmm
MT=sweep(VWT, 1, uWF, FUN = '/') #That's the retrieved trade matrix (tons)
wgts=sweep(MT,2,colSums(MT,na.rm=T),FUN='/') #each column represents the fraction of tons imported from each country row.
# #Solution 1. Import country who already meets at least x% (e.g., 0%) of import needs and has the smallest uWFb
# uWFbMAT=sweep(wgts>0.01,1,uWFb,FUN='*')
# index_bMin=apply(uWFbMAT,2,function(x){ #index of row-exporter with largest market share for each importer-column.
#   x[which(x==0)]=NA
#   if(sum(x,na.rm=T)==0){
#     return(NA)
#   }else{
#     ind=which.min(x)}
#   if(length(ind)==0){
#     return(NA)
#   }else{
#     return(ind)
#   }
# })
# uWFb.iso3c_bMin=uWFb[index_bMin]
# uWF.iso3c_bMin=uWF[index_bMin]
#
#Solution 2 all trade partners increase proportionally
uWFb.iso3c=colSums(sweep(wgts,1,uWFb,FUN='*'),na.rm=T) #weighted unit footprint of imported food
uWF.iso3c=colSums(sweep(wgts,1,uWF,FUN='*'),na.rm=T) #weghted blue water footprint of imported food
pct=apply(wgts,2,max,na.rm=T) #pct market share of largest importer
index=apply(MT,2,function(x){ #index of row-exporter with largest market share for each importer-column.
if(sum(x,na.rm=T)==0){
return(NA)
}else{
ind=which.max(x)}
if(length(ind)==0){
return(NA)
}else{
return(ind)
}
})
FoodImp=rbind(FoodImp,data.frame(Commodity.Code=i,Dest.iso3c=countries$iso3c,iso3cMax=countries$iso3c[index],uWFb.iso3c,uWF.iso3c,pct))
}
Food=FoodInv%>%
left_join(FoodImp)%>%mutate(WFb.iso3c=Tons*uWFb.iso3c,WF.iso3c=Tons*uWF.iso3c)%>%na.omit
FoodFam=Food%>%
group_by(Dest.iso3c,FAOBalance.Number)%>%summarise(WFb.iso3c=sum(WFb.iso3c*w,na.rm=T),WF.iso3c=sum(WF.iso3c*w,na.rm=T))%>%
left_join(Food%>%group_by(Dest.iso3c,FAOBalance.Number,FAOBalance.Name)%>%summarise(iso3cM=names(which.max(table(iso3cMax))),pct=pct[which.max(table(iso3cMax))]))
pltdat=FoodFamDS%>%left_join(FoodFam)%>%left_join(FoodInv%>%select(Dest.iso3c,FAOBalance.Number,Tons)%>%distinct())
View(pltdat)
save(pltdat,file='./foodInv.rdata')
setwd("~/Desktop/_RepoV2")
load("~/Desktop/_RepoV2/foodInv.rdata")
mycol=tableau_color_pal('Tableau 10')(10)
show_col(mycol)
pltdat<- load("foodInv.rdata")
load("~/Desktop/_RepoV2/foodInv.rdata")
load("foodInv.rdata")
View(pltdat)
pltdat1= pltdat%>%mutate(pltVar=WFb.iso3c,pltcntr=iso3cM,pct=pct)
pltdat1=  pltdat1%>%mutate(slp=DS/pltVar)%>%group_by(Dest.iso3c) %>% arrange(desc(slp)) %>%mutate(cumDS=cumsum(DS),cumpltVar=cumsum(pltVar))%>%
select(Dest.iso3c,pltcntr,cumDS,cumpltVar,FAOBalance.Name,Tons,pct)%>%arrange(Dest.iso3c,cumDS)
pltdat1=rbind(pltdat1,data.frame(Dest.iso3c=unique(pltdat$Dest.iso3c),pltcntr=NA,cumDS=0,cumpltVar=0,FAOBalance.Name=NA,pct=NA,Tons=NA))
pltdat1=pltdat1%>%filter(Dest.iso3c%in%c('JOR','LBN','PAK','IRN','DEU','YEM'))%>%arrange(Dest.iso3c,cumDS)
plt1=ggplot(pltdat1)+
geom_line(aes(x=cumpltVar/1e6,y=cumDS,col=Dest.iso3c))+
geom_point(aes(x=cumpltVar/1e6,y=cumDS,col=Dest.iso3c,text=paste(FAOBalance.Name,': main origin',pltcntr,'(',format(100*pct,digit=2),'%)',sep=' ')))+theme_classic()+
ylab('Relief on refugee-induced water stress (%-point)')+xlab('Blue water import (MCM)') + labs(color='') +ggtitle('Added imports proportional to current')
print(plt1)
ggplotly(plt1)
