-
Notifications
You must be signed in to change notification settings - Fork 0
/
pars_size.qmd
166 lines (144 loc) · 5.22 KB
/
pars_size.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
# Size effect {#sec-parsSize}
In this section I discuss the size effect on both growth and survival vital rates.
In the growth von Bertalanffy growth function, size is implicit in the model where the growth rate exponently decreases with size accroding to the parameter $r$, reaching zero when size reach $L_{\infty}$.
So the size effect is the growth rate itself (Figure 1 in @sec-parsIntercept).
In the survival, we used a log-normal function to capture the lower survival at small individuals and at very large individuals.
This function is composed of an optimal size parameter where survival reach its peak, and a variance parameter defined how survival reduces when moving from the optimal to the extreme sizes.
```{r,include=FALSE,echo=FALSE}
Echo=FALSE
Eval=TRUE
Cache=TRUE
Warng=FALSE
Msg=FALSE
library(tidyverse)
library(cmdstanr)
library(posterior)
library(ggdist)
library(ggpubr)
library(ggrepel)
```
```{r size_loadPars,echo=Echo,eval=Eval,cache=Cache,warning=Warng,message=Msg}
data_path <- readLines('_data.path')
pars_path <- file.path(data_path, 'output_sim_processed')
models <- c(
'growth' = 'intcpt_plot_comp_clim',
'mort' = 'intcpt_plot_comp_clim',
'recruit' = 'intcpt_plot_comp_clim'
)
## Species if info
spIds <- read_csv(
file.path(
data_path, 'species_id.csv'
)
) |>
mutate(
shade = factor(shade, levels = c('tolerant', 'intermediate', 'intolerant')),
shade_sylvics = factor(shade_sylvics, levels = c('very-tolerant',
'tolerant',
'intermediate',
'intolerant',
'very-intolerant'
)),
succession = factor(succession, levels = c('pioneer',
'intermediate',
'climax'))
) |>
filter(sp_to_analyze)
# Load parameters
map_dfr(
spIds$species_id_old,
~ readRDS(
paste0(
pars_path, '/mort/', models['mort'], '/posterior_pop_', .x, '.RDS'
)
) |>
filter(par %in% c('size_opt', 'size_var')) |>
pivot_wider(names_from = par) |>
bind_cols(species_id = .x)
) ->
pars_survival
treeData <- readRDS(file.path(data_path, 'treeData.RDS')) |>
filter(species_id %in% spIds$species_id_old)
```
## Survival
#### Optimal size
The optimal size parameter for the survival vital rate represents the size in which survival reach its peak.
In @fig-survOpt we show the posterior distribution of optimal size for survival across the 31 forest species along with the density distribution of observed size in the dataset.
Species are ordered by the average observed size in dataset.
The second panel shows how the optimal size for survival relates to the shade tolerance of the species, where the optimal survival size increases when species are more intolerant.
```{r size_r,echo=Echo,eval=Eval,cache=Cache,warning=Warng,message=Msg}
#| label: fig-survOpt
#| fig-width: 8.5
#| fig-height: 5.5
#| fig-cap: "Posterior distribution of the optimal size for the survival model is represented by the point interval. Gray density is the size distribution of all observations across space and time. Species are classified by their shade tolerance trait following @burns1990silvics"
treeData |>
left_join(
spIds,
by = c('species_id' = 'species_id_old')
) |>
filter(!is.na(dbh)) |>
group_by(species_id) |>
filter(dbh < quantile(dbh, .999)) |>
ungroup() |>
ggplot() +
aes(dbh/10, fct_reorder(species_name, dbh)) +
ggridges::geom_density_ridges2(color = NA, alpha = 0.5) +
stat_pointinterval(
data = pars_survival |>
left_join(
spIds,
by = c('species_id' = 'species_id_old')
),
aes(size_opt/10, fct_reorder(species_name, size_opt))
) +
theme_classic() +
xlab('Optimal size for survival (cm)') +
ylab('') +
theme(
axis.text.y = element_text(face = "italic")
) ->
p1
pars_survival |>
left_join(
spIds,
by = c('species_id' = 'species_id_old')
) |>
ggplot() +
aes(shade_sylvics, size_opt/10) +
aes(fill = shade_sylvics) +
geom_boxplot() +
scale_fill_manual(
# values = c("#87bc45", "#edbf33", "#ea5545")
values = c("#20bc45", "#87bc45", "#edbf33", "#ea5545", "#ba0000")
) +
xlab('Shade tolerance') +
ylab('Optimal size for survival (cm)') +
theme_classic() +
theme(legend.position = 'none') +
labs(fill = '') ->
p2
ggarrange(p1, p2, ncol = 2)
```
#### Size variance
The size variance parameter defines the shape of the log-normal function around the optimal size parameter.
The larger the size variance, the closer to a flat line shape the log-normal becomes, meaning that survival is independent of size.
```{r size_r,echo=Echo,eval=Eval,cache=Cache,warning=Warng,message=Msg}
#| label: fig-survSizeVar
#| fig-width: 6.5
#| fig-height: 5.5
#| fig-cap: "Posterior distribution of the size variance parameter for the survival model."
pars_survival |>
left_join(
spIds,
by = c('species_id' = 'species_id_old')
) |>
ggplot() +
aes(size_var, fct_reorder(species_name, size_var)) +
stat_pointinterval() +
theme_classic() +
xlab('Size variance') +
ylab('') +
theme(
axis.text.y = element_text(face = "italic")
)
```