General updates
[covid19.git] / euromomo / FluMOMO_v42.R
1 # Install required packages (if not already installed)
2 #install.packages("ISOweek")
3
4
5 ### Clear enviromnet i.e. delete all data and variabels
6 rm(list = ls())
7 # Clear console
8 cat("\014")
9
10 ### Country
11 country <- ""
12 country.code <- ""
13
14 ### Work directory - directory where the R programs are placed
15 wdir <- "."
16
17 ### Period: Start and end (both included)
18 start_year <- 2013
19 start_week <- 40
20 end_year <- 2018
21 end_week <- 40
22
23 ### Deaths data source
24 ### Must be placed in the subdirectory /data in the work directory
25 # 1 = A-MOMO complete file, renamed to A-MOMO data.txt
26 # 0 = you provide a ;-separated file: deaths.txt, containing at least the variable: agegrp, year, week, deaths
27 A_MOMO <- 1
28
29 ### Weather data source
30 # 1 = automatic download from EuroMOMO website
31 # 0 = you provide a ;-separated file: wdata_'country.code'.txt, containing at least the variables: date, pop3, NUTS3, temp and placed in the subdirectory /data in the work directory
32 WeatherData <- 1
33
34 ### Population data (TRUE/FALSE)
35 ### A ;-separated file: population.txt, must be placed in the subdirectory /data in the work directory
36 population <- FALSE
37
38 # Restrict IA to only positive (TRUE/FALSE)
39 IArest <- TRUE
40
41 # Number of IA lags
42 # 0 = no lag, 1 = one week lag, ...(max=9)
43 IAlags <- 2
44
45 # Number of OF lags
46 # 0 = no lag, 1 = one week lag, ...(max=9)
47 ETlags <- 2
48
49
50 ### Directory setup ######################################################################
51
52 ### Create general output dir
53 if (!dir.exists(paste0(wdir,"/FluMOMO_",end_year,"w",formatC(end_week, width=2, flag="0")))) {
54 dir.create(paste0(wdir,"/FluMOMO_",end_year,"w",formatC(end_week, width=2, flag="0")))
55 }
56 ### Copy data directory - directory where input data are stored
57 indir <- paste0(wdir,"/FluMOMO_",end_year,"w",formatC(end_week, width=2, flag="0"),"/data")
58 if (!dir.exists(indir)) dir.create(indir)
59 file.copy(from = list.files(paste0(wdir,"/data"), all.files = TRUE, full.names = TRUE, no.. = TRUE),
60 to = indir, overwrite = TRUE, recursive = FALSE, copy.mode = TRUE)
61 #file.remove(list.files(paste0(wdir,"/data"), all.files = TRUE, full.names = TRUE, no.. = TRUE))
62
63 ### Create output directory - directory where output are created
64 outdir <- paste0(wdir,"/FluMOMO_",end_year,"w",formatC(end_week, width=2, flag="0"),"/output")
65 if (!dir.exists(outdir)) dir.create(outdir)
66 #########################################################################################
67
68 # Estimation
69 source(paste0(wdir,"/Estimation_v42.R"), echo = FALSE)
70 # Output: txt-files
71 source(paste0(wdir,"/Output_txt_v42.R"))
72 # Output: graphs IA and ET
73 source(paste0(wdir,"/Output_IA_ET_v42.R"))
74 # Output: graphs over calendar time
75 source(paste0(wdir,"/Output_calendar_v42.R"))
76 # Output: graphs cumulated IA
77 source(paste0(wdir,"/Output_cumulated_v42.R"))