Temperature Data Management

Creating Database only with summer months

table of N obs per months to check to have only summer month

## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0 
## 
##   1   2   3   4   5   6   7   8   9  10  11  12 
##   0   0   0   0   0 480 496 496 480   0   0   0

Creation of Heat Wave Variable

## First condition for heat wave
for (i in 1:length(villes_s)){
  villes_s[[i]]$heat_wave1<-NA
  for (r in 3:nrow(villes_s[[i]])){
  villes_s[[i]]$heat_wave1[r]<-  if (villes_s[[i]]$tempmoy[r] >= trshld975[i] & villes_s[[i]]$tempmoy[r-1] >= trshld975[i] & villes_s[[i]]$tempmoy[r-2] >= trshld975[i] ) 1 else 0
  }}

## Second condition for heat wave
for (i in 1:length(villes_s)){
  for (r in 3:nrow(villes_s[[i]])){
  villes_s[[i]]$heat_wave[r]<-  if (villes_s[[i]]$heat_wave1[r] == 1 & (villes_s[[i]]$tempmoy[r] >= trshld995[i] | villes_s[[i]]$tempmoy[r-1] >= trshld995[i] | villes_s[[i]]$tempmoy[r-2] >= trshld995[i])) 1 else 0
  }}

 

Number of Heat Wave for each city:

Heat wave=0 Heat wave=1
bordeaux 1924 26
clermont 1926 24
grenoble 1914 36
lehavre 1927 23
lyon 1918 32
marseille 1915 35
montpellier 1922 28
nancy 1918 32
nantes 1926 24
nice 1924 26
paris 1923 27
rennes 1918 32
rouen 1925 25
strasbourg 1912 38
toulouse 1921 29

Analysis On Non-Accidental Mortality

BOOTSTRAP METHOD

Code:

# some data management
 for (i in 1:length(villes_s)){
   villes_s[[i]]$time<-1:nrow(villes_s[[i]]) # Create a new variable for time 
 } 
   

    
  # start bootstrap
     
  nreps=700 #number of bootstrap reps
  results<-matrix(NA,nrow = 15,ncol=10)
  colnames(results)<-c("city","NDE","NDE_2.5","NDE_97.5","NIE","NIE_2.5","NIE_97.5","PMM","PMM_2.5","PMM_97.5")
  
for (i in (1:length(villes_s))){
  boot.nde<- rep(NA,nreps)
  boot.nie <- rep(NA,nreps)
  boot.pmm <- rep(NA,nreps)
  for (rep in 1:nreps)
      
    {
      dat_resample <- sample(1:nrow(villes_s[[i]]),nrow(villes_s[[i]]),replace=T)
      dat_boot <- villes_s[[i]][dat_resample,]
        
      # outcome model - Poisson Regression: Mortality, HW and O3
      m.outcome<-glm(nocc_75~heat_wave+o3+ns(time,df=round(3*length(time)/122))+Jours+Vacances+hol,data=dat_boot,family=quasipoisson)
      
      # mediator model - multinomial linear regression
      m.mediator<-lm(o3~heat_wave+no2moy+ns(time,df=round(3*length(time)/122))+Jours+Vacances+hol,data=dat_boot) 
      
      # save coefficients
      theta1<-coef(m.outcome)[2]
      
      theta2<-coef(m.outcome)[3]
     
      beta1<-coef(m.mediator)[2]
      
      # estimate CDE and NIE
      
      boot.nde[rep] <- exp(theta1) #NDE
      
      boot.nie[rep] <-exp(theta2*beta1) #NIE 
      
      boot.pmm[rep] <-boot.nde[rep]*(boot.nie[rep]-1)/(boot.nde[rep]*boot.nie[rep]-1) #NIE 
                   
      
    } #end bootstrap

  results[i,1]<-cities[[i]]
  results[i,2]<-median(boot.nde, na.rm=T)
  results[i,3]<-quantile(boot.nde, 0.025, na.rm=T)
  results[i,4]<-quantile(boot.nde, 0.975, na.rm=T)
  results[i,5]<-median(boot.nie, na.rm=T)
  results[i,6]<-quantile(boot.nie, 0.025, na.rm=T)
  results[i,7]<-quantile(boot.nie, 0.975, na.rm=T)
  results[i,8]<-median(boot.pmm, na.rm=T)
  results[i,9]<-quantile(boot.pmm, 0.025, na.rm=T)
  results[i,10]<-quantile(boot.pmm, 0.975, na.rm=T)
       }
  
  # output CDE and NIE and confidence intervals

Results:

res<-data.frame(results)

for (i in (2:10)){
res[,i]<-as.numeric(as.character(res[,i]))
}

res[,2:10]<-round(res[,2:10],digits = 4)

kable(res)%>%kable_styling()%>%
  column_spec(1, bold = T, border_right = T)%>%
  column_spec(4, border_right = T)%>%
  column_spec(7, border_right = T)
city NDE NDE_2.5 NDE_97.5 NIE NIE_2.5 NIE_97.5 PMM PMM_2.5 PMM_97.5
bordeaux 1.6082 1.3726 1.8968 1.0180 0.9926 1.0466 0.0464 -0.0196 0.1210
clermont 1.6079 1.3161 1.9230 1.0109 0.9802 1.0428 0.0283 -0.0561 0.1200
grenoble 1.2836 1.1400 1.4615 1.0426 1.0154 1.0753 0.1626 0.0575 0.3175
lehavre 1.3759 1.0673 1.6973 1.0348 0.9721 1.0972 0.1135 -0.1268 0.4314
lyon 1.4410 1.2110 1.7086 1.0309 1.0123 1.0513 0.0914 0.0374 0.1788
marseille 1.1831 1.0822 1.3103 1.0056 1.0003 1.0145 0.0359 0.0020 0.1005
montpellier 1.0148 0.8430 1.2075 1.0132 0.9984 1.0331 0.0757 -1.7190 1.7776
nancy 1.3853 1.1174 1.6784 0.9983 0.9702 1.0255 -0.0060 -0.1474 0.1194
nantes 1.3037 1.0087 1.6868 1.0709 1.0197 1.1274 0.2389 0.0485 0.8293
nice 1.2639 1.1076 1.4286 1.0067 0.9992 1.0206 0.0313 -0.0046 0.1149
paris 1.8633 1.4550 2.3550 1.0613 1.0366 1.0985 0.1179 0.0734 0.1790
rennes 1.1498 0.9612 1.3788 1.0673 1.0156 1.1267 0.3382 0.0556 1.7666
rouen 1.3556 1.1146 1.6294 1.0994 1.0509 1.1602 0.2745 0.1454 0.5174
strasbourg 1.4998 1.3119 1.7151 1.0118 0.9847 1.0410 0.0340 -0.0457 0.1253
toulouse 1.3089 1.1497 1.4966 1.0368 1.0110 1.0688 0.1384 0.0444 0.2765
write_xlsx(res,"C:/Users/Anna/Dropbox/Heat wave and O3/Meteo France/mortality/nonaccidental/results.xlsx")

Meta-Analysis and Forestplot

Natural Direct Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0196 (SE = 0.0125)
## tau (square root of estimated tau^2 value):      0.1398
## I^2 (total heterogeneity / total variability):   63.30%
## H^2 (total variability / sampling variability):  2.73
## 
## Test for Heterogeneity:
## Q(df = 14) = 36.6740, p-val = 0.0008
## 
## Model Results:
## 
## estimate      se     zval    pval   ci.lb   ci.ub 
##   1.3391  0.0475  28.1897  <.0001  1.2460  1.4322  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Natural Indirect Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0003 (SE = 0.0002)
## tau (square root of estimated tau^2 value):      0.0181
## I^2 (total heterogeneity / total variability):   74.75%
## H^2 (total variability / sampling variability):  3.96
## 
## Test for Heterogeneity:
## Q(df = 14) = 43.8615, p-val < .0001
## 
## Model Results:
## 
## estimate      se      zval    pval   ci.lb   ci.ub 
##   1.0263  0.0061  167.6788  <.0001  1.0143  1.0383  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Analysis On Cardiovascular Mortality

Results:

city NDE NDE_2.5 NDE_97.5 NIE NIE_2.5 NIE_97.5 PMM PMM_2.5 PMM_97.5
bordeaux 1.6965 1.3660 2.0676 1.0216 0.9829 1.0714 0.0499 -0.0432 0.1686
clermont 1.8573 1.3953 2.4995 1.0058 0.9510 1.0650 0.0138 -0.1191 0.1407
grenoble 1.3117 1.0144 1.6295 1.0702 1.0273 1.1209 0.2341 0.0734 0.7104
lehavre 1.2961 0.8084 1.8913 1.1531 1.0446 1.3006 0.3940 -1.1878 2.9206
lyon 1.4880 1.1859 1.8850 1.0307 0.9995 1.0642 0.0885 -0.0014 0.2219
marseille 1.0598 0.8909 1.2526 1.0037 0.9990 1.0163 0.0295 -0.4556 0.8918
montpellier 0.9386 0.6074 1.3262 1.0089 0.9840 1.0384 -0.0161 -1.1444 1.1618
nancy 1.4800 1.0858 1.9707 0.9662 0.9173 1.0130 -0.1154 -0.5889 0.0724
nantes 1.3415 0.9866 1.7901 1.0822 0.9918 1.1728 0.2420 -0.0464 0.9601
nice 1.1193 0.8710 1.3801 1.0103 0.9969 1.0334 0.0639 -0.6662 1.1165
paris 1.8589 1.4316 2.3687 1.0531 1.0246 1.0915 0.1048 0.0541 0.1687
rennes 1.2899 0.7829 1.9540 1.0388 0.9449 1.1363 0.1166 -1.1896 1.1095
rouen 1.1260 0.8052 1.5437 1.1067 1.0335 1.2063 0.4210 -3.2023 3.7583
strasbourg 1.6350 1.3260 2.0138 0.9785 0.9237 1.0305 -0.0586 -0.2494 0.0926
toulouse 1.1673 0.9277 1.4165 1.0665 1.0283 1.1141 0.3113 -0.8998 1.4418

Meta-Analysis and Forestplot

Natural Direct Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0430 (SE = 0.0290)
## tau (square root of estimated tau^2 value):      0.2074
## I^2 (total heterogeneity / total variability):   59.46%
## H^2 (total variability / sampling variability):  2.47
## 
## Test for Heterogeneity:
## Q(df = 14) = 34.0266, p-val = 0.0020
## 
## Model Results:
## 
## estimate      se     zval    pval   ci.lb   ci.ub 
##   1.3423  0.0725  18.5246  <.0001  1.2003  1.4843  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Natural Indirect Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0007 (SE = 0.0004)
## tau (square root of estimated tau^2 value):      0.0257
## I^2 (total heterogeneity / total variability):   71.87%
## H^2 (total variability / sampling variability):  3.56
## 
## Test for Heterogeneity:
## Q(df = 14) = 39.9934, p-val = 0.0003
## 
## Model Results:
## 
## estimate      se      zval    pval   ci.lb   ci.ub 
##   1.0271  0.0091  112.9338  <.0001  1.0093  1.0450  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Analysis On Respiratory Mortality

Results:

city NDE NDE_2.5 NDE_97.5 NIE NIE_2.5 NIE_97.5 PMM PMM_2.5 PMM_97.5
bordeaux 2.2799 1.4428 3.5080 1.0631 0.9550 1.1806 0.1071 -0.0866 0.2950
clermont 0.8229 0.2402 1.7800 0.9371 0.8235 1.0501 0.0429 -3.2717 2.0564
grenoble 1.7015 1.0495 2.7732 0.9803 0.8649 1.1193 -0.0564 -0.7172 0.3467
lehavre 1.8958 0.6578 3.6727 0.9269 0.7456 1.1564 -0.1499 -1.3752 0.7358
lyon 2.0282 1.4494 2.7194 1.0748 1.0046 1.1660 0.1302 0.0077 0.2896
marseille 1.2729 0.9471 1.6978 0.9999 0.9847 1.0170 -0.0004 -0.1887 0.1777
montpellier 0.9903 0.4128 1.7261 1.0632 1.0035 1.1624 0.1111 -2.0844 1.9176
nancy 2.2048 1.1948 3.9453 0.9632 0.8647 1.0529 -0.0763 -0.3625 0.1045
nantes 1.1927 0.7053 1.8482 1.2825 1.0916 1.6019 0.6372 -0.9816 2.5399
nice 1.1490 0.7257 1.7224 1.0134 0.9930 1.0533 0.0445 -1.1999 0.8858
paris 2.0358 1.5994 2.5522 1.0906 1.0467 1.1503 0.1523 0.0821 0.2470
rennes 1.8965 0.8796 3.4426 1.0273 0.8348 1.2567 0.0611 -0.7908 0.8782
rouen 1.2439 0.6668 2.2194 1.0516 0.8947 1.2361 0.1218 -2.2686 2.2845
strasbourg 1.9691 1.2385 3.0994 1.0611 0.9454 1.1862 0.1143 -0.1005 0.4128
toulouse 1.7951 1.1076 2.8231 0.9731 0.8959 1.0667 -0.0705 -0.4560 0.2049

Meta-analysis and Forestplot

Natural Direct Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0910 (SE = 0.0842)
## tau (square root of estimated tau^2 value):      0.3017
## I^2 (total heterogeneity / total variability):   42.43%
## H^2 (total variability / sampling variability):  1.74
## 
## Test for Heterogeneity:
## Q(df = 14) = 23.1072, p-val = 0.0585
## 
## Model Results:
## 
## estimate      se     zval    pval   ci.lb   ci.ub 
##   1.5333  0.1262  12.1479  <.0001  1.2859  1.7807  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Natural Indirect Effect

## 
## Random-Effects Model (k = 15; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0009 (SE = 0.0009)
## tau (square root of estimated tau^2 value):      0.0304
## I^2 (total heterogeneity / total variability):   48.25%
## H^2 (total variability / sampling variability):  1.93
## 
## Test for Heterogeneity:
## Q(df = 14) = 25.2940, p-val = 0.0318
## 
## Model Results:
## 
## estimate      se     zval    pval   ci.lb   ci.ub 
##   1.0247  0.0140  73.3943  <.0001  0.9973  1.0520  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1