Creating Database only with summer months

villes_s<-list()

for(i in 1:length(villes)) {
  villes_s[[i]]<-villes[[i]][villes[[i]]$saison=="summer",]
  villes_s[[i]]$temps <- ave(villes_s[[i]]$time,villes_s[[i]]$annee,  FUN = seq_along)
}

names(villes_s)<-cities

## table for month to check to have only summer month
for (i in 1:length(villes)){
print(table(villes_s[[i]]$mois))
}
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 540 558 558 540   0   0   0

Creating Heat Wave variable

trshld95<-c()

for (i in 1:length(villes_s)){
  trshld95[i]<-quantile(villes_s[[i]]$tempmax, probs=c(0.95),na.rm=TRUE)
  villes_s[[i]]$heat_wave<-0
  villes_s[[i]]$heat_wave[which(villes_s[[i]]$tempmax > trshld95[i])]<- 1 
}

 

Number of Heat Wave for each city:

Heat wave=0 Heat wave=1
bm 2087 109
bordeaux 2087 109
clermont 2088 108
dijon 2088 108
grenoble 2086 110
lehavre 2088 108
lille 2087 109
lyon 2087 109
marseille 2093 103
montpellier 2089 107
nancy 2086 110
nantes 2087 109
nice 2088 108
paris 2090 106
rennes 2089 107
rouen 2089 107
strasbourg 2086 110
toulouse 2086 110

Analysis

Model for Mortality with only Heat Wave variable

tot.lin <- matrix(NA, nrow = 18, ncol = 4)
colnames(tot.lin) <- c("Ville","Coefficient HW","SE","P. Value")
modtot_lin<-list()


# Model Loop 

for(i in 1:length(villes_s)) {
  modtot_lin[[i]]<-gam(nocc_tot~heat_wave+ns(time,df=round(8*length(time)/365.25))+Jours+Vacances+hol,data=villes_s[[i]],family=quasipoisson)
  est_lin<-summary(modtot_lin[[i]])
  tot.lin[i, 1] <- as.character(cities[[i]])
  tot.lin[i, 2] <- exp(est_lin$p.coeff[2])
  tot.lin[i, 3] <- exp(est_lin$se[2])
  tot.lin[i, 4] <- est_lin$p.pv[2]
}

kable(tot.lin)%>%kable_styling()%>%
  column_spec(1, bold = T, border_right = T)
Ville Coefficient HW SE P. Value
bm 1.09977433654036 1.04075569821681 0.0173744715082367
bordeaux 1.25898179584853 1.03209596719474 4.52730492676845e-13
clermont 1.17488328679852 1.04788314878924 0.000581732735114105
dijon 1.1768179590276 1.05207933657005 0.00136399813940323
grenoble 1.12431199584236 1.04076841635826 0.00340530271027816
lehavre 1.07219879270675 1.0484796571204 0.141043116557684
lille 1.14511155500603 1.02420693114565 1.69396631230619e-08
lyon 1.20460172091651 1.02809502633044 2.42186731181742e-11
marseille 1.09812615938439 1.02584150143236 0.000250327575302479
montpellier 0.999616651408222 1.0467868263928 0.993310429050776
nancy 1.09889515228232 1.04339303887159 0.0265298486967605
nantes 1.17586011251099 1.03625750473438 5.74299242046951e-06
nice 1.06618698786423 1.03323571652474 0.0501210455057561
paris 1.36459858868642 1.01905500432612 4.60760890117409e-57
rennes 1.16422403701448 1.05734957094175 0.00645749168356771
rouen 1.22176274158089 1.03454358805931 4.34829829437776e-09
strasbourg 1.25153041048858 1.03676084620068 6.29558569595906e-10
toulouse 1.0891896468803 1.03388644414046 0.0104337795565747

 

Model for Mortality with Heat Wave variable and Ozone

tot.lin2 <- matrix(NA, nrow = 18, ncol = 4)
colnames(tot.lin2) <- c("Ville","Coefficient HW","SE","P. Value")
modtot_lin2<-list()


# Model Loop 

for(i in 1:length(villes_s)) {
  modtot_lin2[[i]]<-gam(nocc_tot~heat_wave+o3+ns(time,df=round(8*length(time)/365.25))+Jours+Vacances+hol,data=villes_s[[i]],family=quasipoisson)
  est_lin2<-summary(modtot_lin2[[i]])
  tot.lin2[i, 1] <- as.character(cities[[i]])
  tot.lin2[i, 2] <- exp(est_lin2$p.coeff[2])
  tot.lin2[i, 3] <- exp(est_lin2$se[2])
  tot.lin2[i, 4] <- est_lin2$p.pv[2]
}

kable(tot.lin2)%>%kable_styling()%>%
  column_spec(1, bold = T, border_right = T)
Ville Coefficient HW SE P. Value
bm 1.06682484462061 1.04671537342705 0.156706505019946
bordeaux 1.21916243420399 1.03523336685487 1.21492570102421e-08
clermont 1.14539157770584 1.05053059087136 0.00594842295401679
dijon 1.10061391336632 1.05671154246011 0.0823854436718637
grenoble 1.0677372961082 1.04312230779808 0.120723044091003
lehavre 1.01244060157876 1.05709066513476 0.823801320639876
lille 1.08473357557485 1.02801839306222 0.00328661950361087
lyon 1.15203958355857 1.02965857371603 1.38607701487958e-06
marseille 1.07243061786674 1.02634383256471 0.00722453893954608
montpellier 0.993815798874218 1.0469931277585 0.892559378155612
nancy 1.0894898779675 1.0467681963947 0.060926556596481
nantes 1.10427482676764 1.04138672642058 0.0145409156689972
nice 1.05697427573795 1.03412350759165 0.0988313748364151
paris 1.24382624509049 1.02135424875 2.33124034308072e-24
rennes 1.09123434330078 1.06476209836305 0.16428446542245
rouen 1.14010506848073 1.03972826695536 0.000779098643771355
strasbourg 1.1291839242067 1.04444038064563 0.005256867876599
toulouse 1.03795601014901 1.03592944779288 0.291392396704406

 

Compare Heat Wave coefficient in model 1 and model 2

Model 1
Model 2
Ville Coefficient HW P. Value Coefficient HW P. Value
bm 1.09977433654036 0.0173744715082367 1.06682484462061 0.156706505019946
bordeaux 1.25898179584853 4.52730492676845e-13 1.21916243420399 1.21492570102421e-08
clermont 1.17488328679852 0.000581732735114105 1.14539157770584 0.00594842295401679
dijon 1.1768179590276 0.00136399813940323 1.10061391336632 0.0823854436718637
grenoble 1.12431199584236 0.00340530271027816 1.0677372961082 0.120723044091003
lehavre 1.07219879270675 0.141043116557684 1.01244060157876 0.823801320639876
lille 1.14511155500603 1.69396631230619e-08 1.08473357557485 0.00328661950361087
lyon 1.20460172091651 2.42186731181742e-11 1.15203958355857 1.38607701487958e-06
marseille 1.09812615938439 0.000250327575302479 1.07243061786674 0.00722453893954608
montpellier 0.999616651408222 0.993310429050776 0.993815798874218 0.892559378155612
nancy 1.09889515228232 0.0265298486967605 1.0894898779675 0.060926556596481
nantes 1.17586011251099 5.74299242046951e-06 1.10427482676764 0.0145409156689972
nice 1.06618698786423 0.0501210455057561 1.05697427573795 0.0988313748364151
paris 1.36459858868642 4.60760890117409e-57 1.24382624509049 2.33124034308072e-24
rennes 1.16422403701448 0.00645749168356771 1.09123434330078 0.16428446542245
rouen 1.22176274158089 4.34829829437776e-09 1.14010506848073 0.000779098643771355
strasbourg 1.25153041048858 6.29558569595906e-10 1.1291839242067 0.005256867876599
toulouse 1.0891896468803 0.0104337795565747 1.03795601014901 0.291392396704406

Model for Ozone with Heat Wave variable

tot.lin3 <- matrix(NA, nrow = 18, ncol = 4)
colnames(tot.lin3) <- c("Ville","Coefficient HW","SE","P. Value")
modtot_lin3<-list()


# Model Loop 

for(i in 1:length(villes_s)) {
  modtot_lin3[[i]]<-gam(o3~heat_wave+ns(time,df=round(8*length(time)/365.25))+Jours+Vacances+hol,data=villes_s[[i]],family=quasipoisson)
  est_lin3<-summary(modtot_lin3[[i]])
  tot.lin3[i, 1] <- as.character(cities[[i]])
  tot.lin3[i, 2] <- exp(est_lin3$p.coeff[2])
  tot.lin3[i, 3] <- exp(est_lin3$se[2])
  tot.lin3[i, 4] <- est_lin3$p.pv[2]
}

kable(tot.lin3)%>%kable_styling()%>%
  column_spec(1, bold = T, border_right = T)
Ville Coefficient HW SE P. Value
bm 1.67177885592159 1.02115950166425 2.20887739021856e-117
bordeaux 1.48300831046024 1.01987070871245 6.45079925150352e-82
clermont 1.32057728932902 1.01934754297563 1.42624712673864e-45
dijon 1.43604345055523 1.01992152441427 6.27639693599904e-70
grenoble 1.32731875687218 1.02082791866539 3.27632784535576e-41
lehavre 1.58683685722838 1.01833237337049 1.77183632101106e-124
lille 1.67802326779924 1.0219772917857 2.00624311282421e-110
lyon 1.37683023473197 1.02224022335646 9.98317762925197e-46
marseille 1.18888850206625 1.01835834970024 4.9140208591408e-21
montpellier 1.05697675453672 1.01885589900316 0.00304685766909904
nancy 1.42316333930161 1.02147525036126 3.14656194088058e-58
nantes 1.5665836449347 1.0213678262269 7.94258228684805e-91
nice 1.07353464227658 1.01600001222359 8.23020786876416e-06
paris 1.6543009233094 1.0238362132613 5.55401827949012e-92
rennes 1.55871146706808 1.02010703686503 3.5197507820167e-99
rouen 1.63384939675081 1.020502727194 1.81262411878895e-114
strasbourg 1.59383182635587 1.02533781543094 9.63212916537508e-72
toulouse 1.33858078358368 1.01841528218091 2.16830094765541e-54