-
Notifications
You must be signed in to change notification settings - Fork 16
/
spatial-models.qmd
175 lines (131 loc) · 8.4 KB
/
spatial-models.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
## Gradient models
Similar to the disease progress curves, models can be fitted empirically to observed disease gradient curves and provide insights into the mechanisms of inoculum dispersal and deposition, the source of inoculum, and the physical processes underlying dispersal.
When modeling disease gradients, the distance is represented by $x$, a continuous variable which can be expressed by various units (cm, m, km, etc). The gradient models, similar to the population dynamics models (disease progress) are of the **deterministic** type. The difference is that, for disease progress curves, disease intensity tends to increase with increasing time, while in disease gradients the disease intensity tends to decrease with increasing distance from the source of inoculum. Two models are most commonly fitted to data on disease gradients. More details about these models can be obtained it [this tutorial.](https://www.apsnet.org/edcenter/disimpactmngmnt/topc/EcologyAndEpidemiologyInR/ModelingDispersalGradients/Pages/default.aspx)
## Exponential model
The exponential model is also known as Kiyosawa & Shiyomi model. The differential of the exponential model is given by
$\frac{dy}{dx}$ = $-b_{E}.y$ ,
where $b_{E}$ is the exponential form of the rate of decline and $y$ is the disease intensity. This model suggests that $y$ (any disease intensity) is greater close to the source of inoculum, or at the distance zero. The integral form of the model is given by
$y = a . e^{-b.x}$ ,
where $a$ is the disease intensity at the distance zero and $b$ is the rate of decline, in this case negative because disease intensity decreases with the increase of the distance from inoculum source. Let's make a plot for two disease gradients of varying parameters for this model.
First we need to load essential packages for programming, customizing the outputs and defining a global ggplot theme.
```{r}
#| warning: false
#| message: false
library(tidyverse)
library(r4pde)
theme_set(theme_r4pde()) # set global theme
```
Set the parameters for the exponential model with two rates and the same inoculum level at the source:
```{r}
a1 <- 0.2 # y at distance zero for gradient 1
a2 <- 0.2 # y at distance zero for gradient 2
b1 <- 0.1 # decline rate for gradient 1
b2 <- 0.05 # decline rate for gradient 2
max1 <- 80 # maximum distance for gradient 1
max2 <- 80 # maximum distance for gradient 2
dat <- data.frame(x = seq(1:max1), y = seq(0:a1))
```
The following code allows to visualize the model predictions.
```{r}
#| label: fig-exp1
#| fig-cap: "Exponential curves describing plant disease gradients"
dat |>
ggplot(aes(x, y)) +
theme_r4pde()+
stat_function(fun = function(x) a1 * exp(-b1 * x), linetype = 1) +
stat_function(fun = function(x) a2 * exp(-b2 * x), linetype = 2) +
ylim(0, a1) +
annotate("text", x = 20, y = 0.04, label = "b = 0.1") +
annotate("text", x = 20, y = 0.10, label = "b = 0.05") +
labs(x = "Distance (m)", y = "Disease incidence (proportion)"
)
```
## Power law model
Also known as the modified Gregory's model (Gregory was a pioneer in the use this model to describe plant disease gradients). In the power law model, $Y$ is proportional to the power of the distance, and is given by:
$Y = a_{P}.x - b_{P}$
where $a_{P}$ and $b_{P}$ are the two parameters of the power law model. They differ from the exponential because as closer to $x$ is to zero, $Y$ is indefinitely large (not meaningful biologically). However, the model can still be useful because it produces realistic values at any distance $x$ away from the source. The values of the $a_{P}$ parameter should be interpreted in accord to the scale of $x$, whether in centimeters or meters. If the distance between the source and the first measure away from the source is 0.5m, it is so more appropriate to record the distance in cm than in m or km.
Once $y$ at the distance zero from the source is undefined when using the power law model, this is usually modified by the addition of a positive constant $C$ in $x$:
$Y = a_{P}.(x + C) - b_{P}$
For this reason, the model is named as the modified power law. Here, the constant $C$ is of the same unit of $x$. At the distance zero, the positive constant is a term that express the size of the inoculum source. In other words, the $a$ parameter is a theoretical value of $Y$ at the distance $1-C$ from the center of the inoculum source.
Let's plot two gradients with two rate parameters for the modified power law model:
```{r}
C <- 0.5
a1 <- 0.2 # y at zero distance for gradient 1
a2 <- 0.2 # y at zero distance for gradient 2
b1 <- 0.5 # decline rate for gradient 1
b2 <- 0.7 # decline rate for gradient 2
max1 <- 80 # maximum distance for gradient 1
max2 <- 80 # maximum distance for gradient 2
dat2 <- data.frame(x = seq(1:max1), y = seq(0:a1))
```
```{r}
#| label: fig-power1
#| fig-cap: "Power law (modified) curves describing plant disease gradients"
dat2 |>
ggplot(aes(x, y)) +
theme_r4pde()+
stat_function(fun = function(x) a1 * ((x + C)^-b1), linetype = 1) +
stat_function(fun = function(x) a2 * ((x + C)^-b2), linetype = 2) +
ylim(0, a1 - 0.02) +
annotate("text", x = 20, y = 0.03, label = "b = 0.1") +
annotate("text", x = 20, y = 0.06, label = "b = 0.05") +
labs(x = "Distance (m)", y = "Disease incidence")
```
The differential equation of the power law model is given by:
$\frac{dy}{dx}$ = $\frac{-b_{P}.Y}{x - C}$
Similar to the exponential model, $\frac{dy}{dx}$ is proportional to $Y$, meaning that the gradient is steeper (more negative) at the highest disease intensity value, usually closer to the source.
## Linearization of the models
### Transformations of y
The gradient models, again similar to the temporal disease models, are **non linear in their parameters**. The model is intrinsically linear if transformations are applied (according to the model) in both sides of the equations. The linear model in its generic state is given by
$y* = a* + bx$ ,
where the asterisk in $a$ indicated that one of the transformations was applied in $y$ that produced the linear model. Note that $a*$ is the transformed version of the initial disease intensity, which needs to be returned to the original scale according to the respective back-transformation. Follows the linearized form of the two most common gradient models.
$ln(y) = ln(a_{E}) - b_{E}. x$
$ln(y) = ln(a_{P}) - b_{E}. ln(x+C)$
### Plot for the linearized form of models
Let's visualize the linearization of the exponential model with two different slopes (gradient 1 and 2). Note that the transformation used was $ln(y)$.
```{r}
#| label: fig-exp2
#| fig-cap: "Linearization of the exponential model describing plant disease gradients"
C <- 0.5
a1 <- 0.2 # y at zero distance for gradient 1
a2 <- 0.2 # y at zero distance for gradient 2
b1 <- 0.5 # decline rate for gradient 1
b2 <- 0.7 # decline rate for gradient 2
max1 <- 80 # maximum distance for gradient 1
max2 <- 80 # maximum distance for gradient 2
dat2 <- data.frame(x = seq(1:max1), y = seq(0:a1))
dat2 |>
ggplot(aes(x, y)) +
theme_r4pde()+
stat_function(fun = function(x) log(a1) - (b1 * x), linetype = 1) +
stat_function(fun = function(x) log(a2) - (b2 * x), linetype = 2) +
labs(x = "log of distance (m)", y = "log of disease incidence"
)
```
Follows the linearization of the modified power law model. Note that the transformation used was $ln(y)$ and $ln(x+C)$ .
```{r}
#| label: fig-power2
#| fig-cap: "Linearization of the modified power law curves describing plant disease gradients"
C <- 0.5
a1 <- 0.2 # y at zero distance for gradient 1
a2 <- 0.2 # y at zero distance for gradient 2
b1 <- 0.5 # decline rate for gradient 1
b2 <- 0.7 # decline rate for gradient 2
max1 <- log(80) # maximum distance for gradient 1
max2 <- log(80) # maximum distance for gradient 2
dat2 <- data.frame(x = seq(1:max1), y = seq(0:a1))
dat2 |>
ggplot(aes(x, y)) +
theme_r4pde()+
stat_function(fun = function(x) log(a1) - (b1 * log(x + C)), linetype = 1) +
stat_function(fun = function(x) log(a2) - (b2 * log(x + C)), linetype = 2) +
labs(
title = "Modified Power Law",
subtitle = "",
x = "log of distance (m)",
y = "log of disease incidence"
)
```
## Interactive application
A shiny app was developed to demonstrate these two models interactively. Click on the image below to get access to the app.
[![Screenshot of the application to visualize the spatial disease gradient models by varying the model's parameters](imgs/shiny_gradients.png){#fig-models fig-align="center" width="533"}](https://delponte.shinyapps.io/gradients)