Skip to content
Snippets Groups Projects
Commit ae1506f7 authored by Nathanael  HOZÉ's avatar Nathanael HOZÉ
Browse files

added new comments

parent 597af71f
No related branches found
No related tags found
No related merge requests found
for(j in 1:(L-2)){
qj =1
SEQ = as.array(seq(-j+1,L-j))
qj =sum(apply(SEQ,1,delay_fun))
S=0
for(i in seq(j+1,L)){
S=S+delay_fun(i-j)*Hospitalization[i]/(Din[i]+0.00001) # I added a small number after Din to avoid dividing by 0 (happens when there is a long sequence of 0 in the hospitalization data)
}
lambda1[j] = lambda0[j]/qj*S
}
lambda0=lambda1
Ein = rep(0, L)# expected number of hospitalization to occur on day j
for(i in 1:L){
s=0
for(j in 1:i){
s=s+delay_fun(i-j)*lambda0[j]
}
Ein[i]=s
}
w=which(Ein>0)
KHI = 1/N0*sum((Ein[w]-Din[w])^2/Ein[w])
}
# lambda1[1]=0
lambda1[L]=0
}
lambda1=lambda1[-seq(1,N1)]
return(lambda1)
}
# Compute the number of infection for different age class and region ----
number_infected <- function(dataframe, age.cat,region, ph){
if(!is.null(age.cat) & !is.null(region) ){ if(!is.null(age.cat) & !is.null(region) ){
nb_filtered= dataframe[which(dataframe$region == region & dataframe$age == age.cat ),] nb_filtered= dataframe[which(dataframe$region == region & dataframe$age == age.cat ),]
} }
...@@ -510,3 +480,33 @@ ylab('Proportion infected (%)')+xlab('') + scale_x_date(date_breaks = "2 mont ...@@ -510,3 +480,33 @@ ylab('Proportion infected (%)')+xlab('') + scale_x_date(date_breaks = "2 mont
print(p) print(p)
I1=rbind(I1,Infected.France) I1=rbind(I1,Infected.France)
} }
##################################################################
## ##
## ##
## Monitoring the proportion of the population ##
## infected by SARS-CoV-2 using age-stratified ##
## hospitalisation and serological data: a modelling study ##
## ##
## ##
## Author: Nathanael Hoze ##
## Email: nathanael.hoze@pasteur.fr ##
## Last update: 20/04/2021 ##
## ##
## ##
##################################################################
# load libraries
library(lubridate)
library(ggplot2)
library(dplyr)
library(gridExtra)
library(RColorBrewer)
library(reshape)
library(pdftools)
library(ggpubr)
############################################################
## Load Data and functions ##
############################################################
source("load.R")
getwd()
source('C:/Users/natha/monitoring-infection/load.R')
source('C:/Users/natha/monitoring-infection/main.R')
# French map, proportion infected by region # French map, proportion infected by region
########################################################
# How to make maps with ggplot2
# Author : Juliette Paireau
# Creation date : 15/12/2017
########################################################
library(maptools)
library(ggplot2)
library(rgeos)
library(dplyr)
library(scales)
workdir <- "Samples" workdir <- "Samples"
setwd(workdir) setwd(workdir)
......
# load a simulated dataset of hospitalisation in different regions of France
# between March 1st 2020 to April 15th 2021
daily.numbers.hosp = read.csv(file = 'data/Simulated_SIVIC_dataset.csv', sep = ';') daily.numbers.hosp = read.csv(file = 'data/Simulated_SIVIC_dataset.csv', sep = ';')
daily.numbers.hosp$date = as.Date(daily.numbers.hosp$date) daily.numbers.hosp$date = as.Date(daily.numbers.hosp$date)
...@@ -5,6 +7,7 @@ selected_dates = unique(daily.numbers.hosp$date) ...@@ -5,6 +7,7 @@ selected_dates = unique(daily.numbers.hosp$date)
all.age.classes = unique(daily.numbers.hosp$age) all.age.classes = unique(daily.numbers.hosp$age)
Region.France.Metropolitaine = unique(daily.numbers.hosp$region) Region.France.Metropolitaine = unique(daily.numbers.hosp$region)
# load 1000 values of the infection hospitalisation ratio for the different age classes
PH =read.csv('data/IHR.csv', sep=';', header=FALSE, row.names =all.age.classes ) PH =read.csv('data/IHR.csv', sep=';', header=FALSE, row.names =all.age.classes )
......
...@@ -21,7 +21,9 @@ library(RColorBrewer) ...@@ -21,7 +21,9 @@ library(RColorBrewer)
library(reshape) library(reshape)
library(pdftools) library(pdftools)
library(ggpubr) library(ggpubr)
library(maptools)
library(rgeos)
library(scales)
############################################################ ############################################################
## Load Data and functions ## ## Load Data and functions ##
############################################################ ############################################################
...@@ -36,4 +38,3 @@ source('Proportion Infected.R') ...@@ -36,4 +38,3 @@ source('Proportion Infected.R')
# plot a map of France with the proportion infected in each region # plot a map of France with the proportion infected in each region
source('FrenchMap.R') source('FrenchMap.R')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment