@@ -27,6 +27,13 @@ knitr::opts_chunk$set(
27
27
fig.retina = 3,
28
28
fig.align = 'center'
29
29
)
30
+
31
+ hook_source <- knitr::knit_hooks$get('source')
32
+ knitr::knit_hooks$set(source = function(x, options) {
33
+ x <- stringr::str_replace(x, "^[[:blank:]]?([^*].+?)[[:blank:]]*#<<[[:blank:]]*$", "*\\1")
34
+ hook_source(x, options)
35
+ })
36
+
30
37
options(repos=structure(c(CRAN="http://cran.r-project.org")))
31
38
```
32
39
@@ -1081,19 +1088,25 @@ exclude:true
1081
1088
---
1082
1089
# Défi 2 - Solution ![ : cube ] ( )
1083
1090
1091
+ ** 1.** Créez deux nouveaux modèles: Ajoutez la variable ` Latitude ` à ` two_smooth_model ` , premièrement comme paramètre linéaire, et ensuite comme fonction non-linéaire.
1092
+
1084
1093
``` {r, eval=TRUE}
1085
1094
# Ajouter Latitude comme terme linéaire
1086
1095
three_term_model <- gam(Sources ~
1087
1096
Season + s(SampleDepth) + s(RelativeDepth) +
1088
- Latitude,
1097
+ Latitude, #<<
1089
1098
data = isit, method = "REML")
1099
+
1090
1100
three_term_summary <- summary(three_term_model)
1101
+ ```
1091
1102
1103
+ ``` {r, eval=TRUE}
1092
1104
# Ajouter Latitude comme terme non-linéaire
1093
1105
three_smooth_model <- gam(Sources ~
1094
1106
Season + s(SampleDepth) + s(RelativeDepth) +
1095
- s(Latitude),
1107
+ s(Latitude), #<<
1096
1108
data = isit, method = "REML")
1109
+
1097
1110
three_smooth_summary <- summary(three_smooth_model)
1098
1111
```
1099
1112
@@ -1104,6 +1117,25 @@ __2.__ Est-ce que `Latitude` est un terme important à inclure dans le modèle?
1104
1117
1105
1118
Commençons par visualiser les 4 effets qui sont maintenant inclus dans chaque modèle.
1106
1119
1120
+ .pull-left4[
1121
+
1122
+ ``` {r, eval = FALSE}
1123
+ par(mfrow = c(2,2))
1124
+
1125
+ plot(three_smooth_model,
1126
+ all.terms = TRUE)
1127
+ ```
1128
+ ]
1129
+
1130
+
1131
+ .pull-right4[
1132
+
1133
+ ``` {r, fig.width = 7, fig.height = 6.5, echo = FALSE}
1134
+ plot(three_smooth_model, page = 1, all.terms = TRUE)
1135
+ ```
1136
+
1137
+ ]
1138
+
1107
1139
---
1108
1140
exclude: true
1109
1141
# Défi 2 - Solution ![ : cube ] ( )
0 commit comments