diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5b6a0652566d10360493952aec6d4a4febc77083 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/module2/exo4/journalHelene31.html b/journal/journalHelene31.html similarity index 96% rename from module2/exo4/journalHelene31.html rename to journal/journalHelene31.html index b40e5c7a41ffaa17bb55a515af06fb38acbfcda9..bf22ccba6f316e71d06e0ada5ba4b454594429e6 100644 --- a/module2/exo4/journalHelene31.html +++ b/journal/journalHelene31.html @@ -9,10 +9,9 @@ - -
| Date | Count | Temperature | Pressure | Malfunction |
|---|---|---|---|---|
| <fct> | <int> | <int> | <int> | <int> |
| 4/12/81 | 6 | 66 | 50 | 0 |
| 11/12/81 | 6 | 70 | 50 | 1 |
| 3/22/82 | 6 | 69 | 50 | 0 |
| 11/11/82 | 6 | 68 | 50 | 0 |
| 4/04/83 | 6 | 67 | 50 | 0 |
| 6/18/82 | 6 | 72 | 50 | 0 |
| 8/30/83 | 6 | 73 | 100 | 0 |
| 11/28/83 | 6 | 70 | 100 | 0 |
| 2/03/84 | 6 | 57 | 200 | 1 |
| 4/06/84 | 6 | 63 | 200 | 1 |
| 8/30/84 | 6 | 70 | 200 | 1 |
| 10/05/84 | 6 | 78 | 200 | 0 |
| 11/08/84 | 6 | 67 | 200 | 0 |
| 1/24/85 | 6 | 53 | 200 | 2 |
| 4/12/85 | 6 | 67 | 200 | 0 |
| 4/29/85 | 6 | 75 | 200 | 0 |
| 6/17/85 | 6 | 70 | 200 | 0 |
| 7/29/85 | 6 | 81 | 200 | 0 |
| 8/27/85 | 6 | 76 | 200 | 0 |
| 10/03/85 | 6 | 79 | 200 | 0 |
| 10/30/85 | 6 | 75 | 200 | 2 |
| 11/26/85 | 6 | 76 | 200 | 0 |
| 1/12/86 | 6 | 58 | 200 | 1 |
| Date | Count | Temperature | Pressure | Malfunction | |
|---|---|---|---|---|---|
| <fct> | <int> | <int> | <int> | <int> | |
| 2 | 11/12/81 | 6 | 70 | 50 | 1 |
| 9 | 2/03/84 | 6 | 57 | 200 | 1 |
| 10 | 4/06/84 | 6 | 63 | 200 | 1 |
| 11 | 8/30/84 | 6 | 70 | 200 | 1 |
| 14 | 1/24/85 | 6 | 53 | 200 | 2 |
| 21 | 10/30/85 | 6 | 75 | 200 | 2 |
| 23 | 1/12/86 | 6 | 58 | 200 | 1 |
| Date | Count | Temperature | Pressure | Malfunction |
|---|---|---|---|---|
| 4/12/81 | 6 | 66 | 50 | 0 |
| 11/12/81 | 6 | 70 | 50 | 1 |
| 3/22/82 | 6 | 69 | 50 | 0 |
| 11/11/82 | 6 | 68 | 50 | 0 |
| 4/04/83 | 6 | 67 | 50 | 0 |
| 6/18/82 | 6 | 72 | 50 | 0 |
| 8/30/83 | 6 | 73 | 100 | 0 |
| 11/28/83 | 6 | 70 | 100 | 0 |
| 2/03/84 | 6 | 57 | 200 | 1 |
| 4/06/84 | 6 | 63 | 200 | 1 |
| 8/30/84 | 6 | 70 | 200 | 1 |
| 10/05/84 | 6 | 78 | 200 | 0 |
| 11/08/84 | 6 | 67 | 200 | 0 |
| 1/24/85 | 6 | 53 | 200 | 2 |
| 4/12/85 | 6 | 67 | 200 | 0 |
| 4/29/85 | 6 | 75 | 200 | 0 |
| 6/17/85 | 6 | 70 | 200 | 0 |
| 7/29/85 | 6 | 81 | 200 | 0 |
| 8/27/85 | 6 | 76 | 200 | 0 |
| 10/03/85 | 6 | 79 | 200 | 0 |
| 10/30/85 | 6 | 75 | 200 | 2 |
| 11/26/85 | 6 | 76 | 200 | 0 |
| 1/12/86 | 6 | 58 | 200 | 1 |
| Date | Count | Temperature | Pressure | Malfunction | |
|---|---|---|---|---|---|
| <fct> | <int> | <int> | <int> | <int> | |
| 2 | 11/12/81 | 6 | 70 | 50 | 1 |
| 9 | 2/03/84 | 6 | 57 | 200 | 1 |
| 10 | 4/06/84 | 6 | 63 | 200 | 1 |
| 11 | 8/30/84 | 6 | 70 | 200 | 1 |
| 14 | 1/24/85 | 6 | 53 | 200 | 2 |
| 21 | 10/30/85 | 6 | 75 | 200 | 2 |
| 23 | 1/12/86 | 6 | 58 | 200 | 1 |
| \n", - " | Date | \n", - "Count | \n", - "Temperature | \n", - "Pressure | \n", - "Malfunction | \n", - "
|---|---|---|---|---|---|
| 0 | \n", - "4/12/81 | \n", - "6 | \n", - "66 | \n", - "50 | \n", - "0 | \n", - "
| 1 | \n", - "11/12/81 | \n", - "6 | \n", - "70 | \n", - "50 | \n", - "1 | \n", - "
| 2 | \n", - "3/22/82 | \n", - "6 | \n", - "69 | \n", - "50 | \n", - "0 | \n", - "
| 3 | \n", - "11/11/82 | \n", - "6 | \n", - "68 | \n", - "50 | \n", - "0 | \n", - "
| 4 | \n", - "4/04/83 | \n", - "6 | \n", - "67 | \n", - "50 | \n", - "0 | \n", - "
| 5 | \n", - "6/18/82 | \n", - "6 | \n", - "72 | \n", - "50 | \n", - "0 | \n", - "
| 6 | \n", - "8/30/83 | \n", - "6 | \n", - "73 | \n", - "100 | \n", - "0 | \n", - "
| 7 | \n", - "11/28/83 | \n", - "6 | \n", - "70 | \n", - "100 | \n", - "0 | \n", - "
| 8 | \n", - "2/03/84 | \n", - "6 | \n", - "57 | \n", - "200 | \n", - "1 | \n", - "
| 9 | \n", - "4/06/84 | \n", - "6 | \n", - "63 | \n", - "200 | \n", - "1 | \n", - "
| 10 | \n", - "8/30/84 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "1 | \n", - "
| 11 | \n", - "10/05/84 | \n", - "6 | \n", - "78 | \n", - "200 | \n", - "0 | \n", - "
| 12 | \n", - "11/08/84 | \n", - "6 | \n", - "67 | \n", - "200 | \n", - "0 | \n", - "
| 13 | \n", - "1/24/85 | \n", - "6 | \n", - "53 | \n", - "200 | \n", - "2 | \n", - "
| 14 | \n", - "4/12/85 | \n", - "6 | \n", - "67 | \n", - "200 | \n", - "0 | \n", - "
| 15 | \n", - "4/29/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "0 | \n", - "
| 16 | \n", - "6/17/85 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "0 | \n", - "
| 17 | \n", - "7/29/85 | \n", - "6 | \n", - "81 | \n", - "200 | \n", - "0 | \n", - "
| 18 | \n", - "8/27/85 | \n", - "6 | \n", - "76 | \n", - "200 | \n", - "0 | \n", - "
| 19 | \n", - "10/03/85 | \n", - "6 | \n", - "79 | \n", - "200 | \n", - "0 | \n", - "
| 20 | \n", - "10/30/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "2 | \n", - "
| 21 | \n", - "11/26/85 | \n", - "6 | \n", - "76 | \n", - "200 | \n", - "0 | \n", - "
| 22 | \n", - "1/12/86 | \n", - "6 | \n", - "58 | \n", - "200 | \n", - "1 | \n", - "
| \n", - " | Date | \n", - "Count | \n", - "Temperature | \n", - "Pressure | \n", - "Malfunction | \n", - "
|---|---|---|---|---|---|
| 1 | \n", - "11/12/81 | \n", - "6 | \n", - "70 | \n", - "50 | \n", - "1 | \n", - "
| 8 | \n", - "2/03/84 | \n", - "6 | \n", - "57 | \n", - "200 | \n", - "1 | \n", - "
| 9 | \n", - "4/06/84 | \n", - "6 | \n", - "63 | \n", - "200 | \n", - "1 | \n", - "
| 10 | \n", - "8/30/84 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "1 | \n", - "
| 13 | \n", - "1/24/85 | \n", - "6 | \n", - "53 | \n", - "200 | \n", - "2 | \n", - "
| 20 | \n", - "10/30/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "2 | \n", - "
| 22 | \n", - "1/12/86 | \n", - "6 | \n", - "58 | \n", - "200 | \n", - "1 | \n", - "
| Dep. Variable: | Frequency | No. Observations: | 7 | \n", - "
|---|---|---|---|
| Model: | GLM | Df Residuals: | 5 | \n", - "
| Model Family: | Binomial | Df Model: | 1 | \n", - "
| Link Function: | logit | Scale: | 1.0000 | \n", - "
| Method: | IRLS | Log-Likelihood: | -2.5250 | \n", - "
| Date: | Sat, 13 Apr 2019 | Deviance: | 0.22231 | \n", - "
| Time: | 19:12:05 | Pearson chi2: | 0.236 | \n", - "
| No. Iterations: | 4 | Covariance Type: | nonrobust | \n", - "
| coef | std err | z | P>|z| | [0.025 | 0.975] | \n", - "|
|---|---|---|---|---|---|---|
| Intercept | -1.3895 | 7.828 | -0.178 | 0.859 | -16.732 | 13.953 | \n", - "
| Temperature | 0.0014 | 0.122 | 0.012 | 0.991 | -0.238 | 0.240 | \n", - "
| \n", - " | Date | \n", - "Count | \n", - "Temperature | \n", - "Pressure | \n", - "Malfunction | \n", - "
|---|---|---|---|---|---|
| 0 | \n", - "4/12/81 | \n", - "6 | \n", - "66 | \n", - "50 | \n", - "0 | \n", - "
| 1 | \n", - "11/12/81 | \n", - "6 | \n", - "70 | \n", - "50 | \n", - "1 | \n", - "
| 2 | \n", - "3/22/82 | \n", - "6 | \n", - "69 | \n", - "50 | \n", - "0 | \n", - "
| 3 | \n", - "11/11/82 | \n", - "6 | \n", - "68 | \n", - "50 | \n", - "0 | \n", - "
| 4 | \n", - "4/04/83 | \n", - "6 | \n", - "67 | \n", - "50 | \n", - "0 | \n", - "
| 5 | \n", - "6/18/82 | \n", - "6 | \n", - "72 | \n", - "50 | \n", - "0 | \n", - "
| 6 | \n", - "8/30/83 | \n", - "6 | \n", - "73 | \n", - "100 | \n", - "0 | \n", - "
| 7 | \n", - "11/28/83 | \n", - "6 | \n", - "70 | \n", - "100 | \n", - "0 | \n", - "
| 8 | \n", - "2/03/84 | \n", - "6 | \n", - "57 | \n", - "200 | \n", - "1 | \n", - "
| 9 | \n", - "4/06/84 | \n", - "6 | \n", - "63 | \n", - "200 | \n", - "1 | \n", - "
| 10 | \n", - "8/30/84 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "1 | \n", - "
| 11 | \n", - "10/05/84 | \n", - "6 | \n", - "78 | \n", - "200 | \n", - "0 | \n", - "
| 12 | \n", - "11/08/84 | \n", - "6 | \n", - "67 | \n", - "200 | \n", - "0 | \n", - "
| 13 | \n", - "1/24/85 | \n", - "6 | \n", - "53 | \n", - "200 | \n", - "2 | \n", - "
| 14 | \n", - "4/12/85 | \n", - "6 | \n", - "67 | \n", - "200 | \n", - "0 | \n", - "
| 15 | \n", - "4/29/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "0 | \n", - "
| 16 | \n", - "6/17/85 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "0 | \n", - "
| 17 | \n", - "7/29/85 | \n", - "6 | \n", - "81 | \n", - "200 | \n", - "0 | \n", - "
| 18 | \n", - "8/27/85 | \n", - "6 | \n", - "76 | \n", - "200 | \n", - "0 | \n", - "
| 19 | \n", - "10/03/85 | \n", - "6 | \n", - "79 | \n", - "200 | \n", - "0 | \n", - "
| 20 | \n", - "10/30/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "2 | \n", - "
| 21 | \n", - "11/26/85 | \n", - "6 | \n", - "76 | \n", - "200 | \n", - "0 | \n", - "
| 22 | \n", - "1/12/86 | \n", - "6 | \n", - "58 | \n", - "200 | \n", - "1 | \n", - "
| \n", - " | Date | \n", - "Count | \n", - "Temperature | \n", - "Pressure | \n", - "Malfunction | \n", - "
|---|---|---|---|---|---|
| 1 | \n", - "11/12/81 | \n", - "6 | \n", - "70 | \n", - "50 | \n", - "1 | \n", - "
| 8 | \n", - "2/03/84 | \n", - "6 | \n", - "57 | \n", - "200 | \n", - "1 | \n", - "
| 9 | \n", - "4/06/84 | \n", - "6 | \n", - "63 | \n", - "200 | \n", - "1 | \n", - "
| 10 | \n", - "8/30/84 | \n", - "6 | \n", - "70 | \n", - "200 | \n", - "1 | \n", - "
| 13 | \n", - "1/24/85 | \n", - "6 | \n", - "53 | \n", - "200 | \n", - "2 | \n", - "
| 20 | \n", - "10/30/85 | \n", - "6 | \n", - "75 | \n", - "200 | \n", - "2 | \n", - "
| 22 | \n", - "1/12/86 | \n", - "6 | \n", - "58 | \n", - "200 | \n", - "1 | \n", - "
| Dep. Variable: | Frequency | No. Observations: | 7 | \n", - "
|---|---|---|---|
| Model: | GLM | Df Residuals: | 5 | \n", - "
| Model Family: | Binomial | Df Model: | 1 | \n", - "
| Link Function: | logit | Scale: | 1.0000 | \n", - "
| Method: | IRLS | Log-Likelihood: | -2.5250 | \n", - "
| Date: | Sat, 13 Apr 2019 | Deviance: | 0.22231 | \n", - "
| Time: | 19:11:24 | Pearson chi2: | 0.236 | \n", - "
| No. Iterations: | 4 | Covariance Type: | nonrobust | \n", - "
| coef | std err | z | P>|z| | [0.025 | 0.975] | \n", - "|
|---|---|---|---|---|---|---|
| Intercept | -1.3895 | 7.828 | -0.178 | 0.859 | -16.732 | 13.953 | \n", - "
| Temperature | 0.0014 | 0.122 | 0.012 | 0.991 | -0.238 | 0.240 | \n", - "
En 1958, Charles David Keeling a initié une mesure de la concentration de CO2 dans l’atmosphère à l’observatoire de Mauna Loa, Hawaii, États-Unis qui continue jusqu’à aujourd’hui. L’objectif initial était d’étudier la variation saisonnière, mais l’intérêt s’est déplacé plus tard vers l’étude de la tendance croissante dans le contexte du changement climatique. En honneur à Keeling, ce jeu de données est souvent appelé “Keeling Curve” (voir (https://en.wikipedia.org/wiki/Keeling_Curve) pour l’histoire et l’importance de ces données).
+Les données sont disponibles sur le site Web de l’institut Scripps. Utilisez le fichier avec les observations hebdomadaires. Attention, ce fichier est mis à jour régulièrement avec de nouvelles observations. Notez donc bien la date du téléchargement, et gardez une copie locale de la version précise que vous analysez. Faites aussi attention aux données manquantes.
+Traitement de suites chronologiques
+Quelques références:
+The data file below contains 10 columns.
+Missing values are denoted by -99.99
+CO2 concentrations are measured on the ‘08A’ calibration scale
+library(tidyverse)
+## Warning: package 'tidyverse' was built under R version 3.5.3
+## -- Attaching packages -------------------------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
+## v ggplot2 3.1.0 v purrr 0.3.2
+## v tibble 2.1.1 v dplyr 0.8.0.1
+## v tidyr 0.8.3 v stringr 1.4.0
+## v readr 1.3.1 v forcats 0.4.0
+## Warning: package 'tibble' was built under R version 3.5.3
+## Warning: package 'tidyr' was built under R version 3.5.3
+## Warning: package 'readr' was built under R version 3.5.3
+## Warning: package 'purrr' was built under R version 3.5.3
+## Warning: package 'dplyr' was built under R version 3.5.3
+## Warning: package 'stringr' was built under R version 3.5.3
+## Warning: package 'forcats' was built under R version 3.5.3
+## -- Conflicts ----------------------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
+## x dplyr::filter() masks stats::filter()
+## x dplyr::lag() masks stats::lag()
+library(forecast)
+## Warning: package 'forecast' was built under R version 3.5.3
+library(lubridate)
+## Warning: package 'lubridate' was built under R version 3.5.3
+##
+## Attaching package: 'lubridate'
+## The following object is masked from 'package:base':
+##
+## date
+library(car)
+## Warning: package 'car' was built under R version 3.5.3
+## Loading required package: carData
+## Warning: package 'carData' was built under R version 3.5.2
+##
+## Attaching package: 'car'
+## The following object is masked from 'package:dplyr':
+##
+## recode
+## The following object is masked from 'package:purrr':
+##
+## some
+library(scales)
+##
+## Attaching package: 'scales'
+## The following object is masked from 'package:purrr':
+##
+## discard
+## The following object is masked from 'package:readr':
+##
+## col_factor
+library(patchwork)
+## Warning: package 'patchwork' was built under R version 3.5.3
+library(kableExtra)
+## Warning: package 'kableExtra' was built under R version 3.5.3
+##
+## Attaching package: 'kableExtra'
+## The following object is masked from 'package:dplyr':
+##
+## group_rows
+dataCO2 <- read.csv("monthly_in_situ_co2_mlo.csv", sep="," ,skip = 57)
+colnames(dataCO2) <- c("Year", "Month","Date1", "Date2", "ObsCO2", "SeasAdjCO2","SplineAdjCO2", "SplineAdjCO2Trend", "ObsCO2Comp", "SeasAdjCO2Comp")
+summary(dataCO2)
+## Year Month Date1 Date2
+## Min. :1958 Min. : 1.000 Min. :21231 Min. :1958
+## 1st Qu.:1973 1st Qu.: 4.000 1st Qu.:26968 1st Qu.:1974
+## Median :1989 Median : 7.000 Median :32704 Median :1990
+## Mean :1989 Mean : 6.507 Mean :32705 Mean :1990
+## 3rd Qu.:2005 3rd Qu.: 9.500 3rd Qu.:38442 3rd Qu.:2005
+## Max. :2020 Max. :12.000 Max. :44180 Max. :2021
+## ObsCO2 SeasAdjCO2 SplineAdjCO2 SplineAdjCO2Trend
+## Min. :-99.99 Min. :-99.99 Min. :-99.99 Min. :-99.99
+## 1st Qu.:328.40 1st Qu.:328.70 1st Qu.:328.46 1st Qu.:328.82
+## Median :351.34 Median :352.13 Median :351.33 Median :352.03
+## Mean :346.18 Mean :346.18 Mean :348.95 Mean :348.95
+## 3rd Qu.:377.55 3rd Qu.:377.35 3rd Qu.:377.69 3rd Qu.:377.37
+## Max. :414.83 Max. :413.33 Max. :414.94 Max. :413.35
+## ObsCO2Comp SeasAdjCO2Comp
+## Min. :-99.99 Min. :-99.99
+## 1st Qu.:328.40 1st Qu.:328.70
+## Median :351.34 Median :352.13
+## Mean :348.96 Mean :348.95
+## 3rd Qu.:377.55 3rd Qu.:377.35
+## Max. :414.83 Max. :413.33
+dataCO2$Date <- ymd(paste0(dataCO2$Year, " ", dataCO2$Month, " ", "15"))
+** Remplacement dans la série des valeurs observées, des valeurs manquantes -99.99 par celles qui sont interpolées ** on enlève ensuite les observations manquantes
+dataCO2 <- dataCO2[dataCO2$ObsCO2Comp != "-99.99", ]
+** Create a column Date with format YYYY MM DD
+dataCO2$Date <- ymd(paste0(dataCO2$Year, "-", dataCO2$Month, "-", "15"))
+ggplot(dataCO2,aes(Date, dataCO2$ObsCO2Comp)) +
+ geom_line(color='orange') +
+ xlab("Year, Month") +
+ scale_x_date(date_labels = "%Y-%m", date_breaks = "5 year") +
+ theme(axis.text.x = element_text(face = "bold", color = "#993333",
+ size = 12, angle = 45, hjust = 1)) +
+ ylab("CO2 Concentration (ppm)") +
+ scale_y_continuous() +
+ theme(axis.text.y = element_text(face = "bold", color = "#993333",
+ size = 10, hjust = 1),axis.title.y = element_text(size = 10)) +
+ ggtitle("Graphique 1")
+ library(viridis)
+## Loading required package: viridisLite
+##
+## Attaching package: 'viridis'
+## The following object is masked from 'package:scales':
+##
+## viridis_pal
+dataCO2_by_year <- dataCO2 %>% group_by("Year")
+ggplot(dataCO2_by_year, aes(dataCO2_by_year$Month,dataCO2_by_year$ObsCO2Comp )) +
+ geom_line(aes( group = dataCO2_by_year$Year , colour=dataCO2_by_year$Year)) +
+ xlab("Month")+
+ ylab("CO2 Concentration (ppm)") +
+ ggtitle("Graphique saisonnier")
+Série n’est pas stationnaire comme le montre le graphique
+Série montre une saisonnalité
+