extended_data.R 9.96 KB
Newer Older
kunstler's avatar
kunstler committed
1
## # Extend data
2

3
## ```{r options-chunk, echo = FALSE, results = 'hide', message=FALSE}
4
5
6
## opts_chunk$set(dev= c('pdf','svg'), fig.width= 10, fig.height = 5)
## ```

kunstler's avatar
kunstler committed
7

Kunstler Georges's avatar
Kunstler Georges committed
8
## ![Map of the plot locations of all data sets analysed. LPP plots are represented with a large points and NFI plots with small points (The data set of Panama comprises both a 50ha plot and a network of 1ha plots).](../../figs/world_map.pdf)
kunstler's avatar
kunstler committed
9

kunstler's avatar
kunstler committed
10
11


12
## \newpage
kunstler's avatar
kunstler committed
13
14


15
16
17
18
19
20
21
22
23
24
25
26
27
28
##+ This deals with some path issues, echo = FALSE, results = 'hide'
git.root <- function() {
    system("git rev-parse --show-toplevel", intern=TRUE)
}
source.root <- function(filename) {
    source(file.path(git.root(), filename), chdir=TRUE)
}
readRDS.root <- function(filename) {
    readRDS(file.path(git.root(), filename))
}

##+ Load script, echo = FALSE, results = 'hide', message=FALSE
path.root <- git.root()

29

30
## # Data description
31
32
33

##+  kable2, echo = FALSE, results="asis", message=FALSE
library(pander)
kunstler's avatar
kunstler committed
34
data.set <-read.csv(file.path(path.root, 'output', 'data.set.csv'), stringsAsFactors = FALSE)
35
dat.2 <- data.set[, -(2)]
kunstler's avatar
kunstler committed
36
37
38
39
40
41
42
dat.2[dat.2$set == 'NVS',1] <- 'New Zealand'
dat.2[dat.2$set == 'NSW',1] <- 'Australia'
dat.2[dat.2$set == 'Swiss',1] <- 'Switzerland'
dat.2[dat.2$set == 'BCI',1] <- 'Panama'
dat.2[dat.2$set == 'Fushan',1] <- 'Taiwan'
dat.2[dat.2$set == 'Luquillo',1] <- 'Puerto Rico'
dat.2[dat.2$set == 'Mbaiki',1] <- 'Central African Republic'
43
dat.2[dat.2$set == 'Paracou',1] <- 'French Guiana'
kunstler's avatar
kunstler committed
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var.names <- colnames(dat.2)
var.names[2] <- '# of trees'
var.names[3] <- '# of species'
var.names[4] <- '# of plots/quadrats'
var.names[5] <- '% of angiosperm'
var.names[6] <- '% of evergreen'
var.names[7] <- '% cover Leaf N'
var.names[8] <- '% cover Seed mass'
var.names[9] <- '% cover SLA'
var.names[10] <- '% cover Wood density'
var.names[11] <- '% cover Max height'
colnames(dat.2) <-  var.names
dat.2 <-  as.data.frame(dat.2)
rownames(dat.2) <-  NULL
dat.2 <- dat.2[, 1:11]
60
61
62
dat.2[,5:11] <- dat.2[,5:11]*100

pandoc.table(dat.2[, 1:6],
63
             caption = "Data description, with number of individual trees, species and plots in NFI data and quadrats in LPP data, and percentage of angiosperm and evergreen species.",
64
65
66
67
             digits = c(3,3,3,0,0), split.tables = 200, split.cells = 35,
             justify = c('left', rep('right', 5)), keep.trailing.zeros = TRUE)

pandoc.table(dat.2[, c(1,9:11)],
68
             caption = "Traits coverage in each site. Percentage of species with species level trait data.",
69
70
71
             digits = 1, split.tables = 200, split.cells = 25,
             justify = c('left', rep('right', 3)),
             keep.trailing.zeros = TRUE)
72
73
74



kunstler's avatar
kunstler committed
75
76
77
78
##+ Describe data, echo = FALSE, results = 'hide', message=FALSE
source.root("R/analysis/lmer.output-fun.R")
source.root("R/analysis/lmer.run.R")
source.root("R/utils/plot.R")
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
library(pander)

## ## Species traits correlation

##+ Read Table_cor, echo = FALSE, results = 'hide', message=FALSE
cor.mat <-  read.csv(file.path(path.root,'output',
                               'formatted', 'cor.mat.traits.csv'),
                     row.names = 1)
cor.mat <- round(cor.mat,3)
cor.mat[is.na(cor.mat)] <-  ''
colnames(cor.mat)  <- row.names(cor.mat) <-  c("Wood density", "SLA",
                                               "Max height")
##+ Table1_cor, echo = FALSE, results='asis', message=FALSE
pandoc.table(cor.mat,
             caption = "Pairwise functional trait correlations (Pearson's r)",
             digits = 3)

## \newpage
kunstler's avatar
kunstler committed
97

98
## # Model results
kunstler's avatar
kunstler committed
99

Kunstler Georges's avatar
Kunstler Georges committed
100
101
## ![Variation of the four parameters linking wood density, specific leaf area and maximum height with maximum growth and competition - maximum growth ($t_f \, m_1$), tolerance to competition ($t_f \, \alpha_t$), competitive effect ($t_c \, \alpha_e$) and limiting similarity ($|t_f - t_c| \, \alpha_l$ ($t_c$ was fixed at the lowest value and $t_f$ varying from quantile 5 to 95\%). The shaded area represents the 95% confidence interval of the prediction (including uncertainty associated with $\alpha_0$ or $m_0$). $\alpha_{0 \, intra}$ and $\alpha_{0 \, inter}$, which do not vary with traits are also represented with their associated confidence intervals.](../../figs/
## figres4b_TP_intra.pdf)
102

103

Kunstler Georges's avatar
Kunstler Georges committed
104
105
## ![**Stabilising effect of competition between pairs of species in function of their traits distance, predicted according to the basal area growth models fitted for wood density, specific leaf area and maximum height.** $1 -\rho$ measure the relative strengh of intra-specific competition compared to inter-specific competition (see Methods), where $\rho$ is a measure of niche overlap between a pair of species. If inter-specific competition is equal or greater than intra-specific competition $1- \rho \leqslant 0$, and there is no stabilising processes. If inter-specific competition is smaller than intra-specific competition $1- \rho > 0$, and this indicates the occurence of stabilising processes resulting in stronger intra- than inter-specific competition. As the niche overlap $\rho$ is estimated only with competition effect on individual tree basal area growth and not on population growth, this can not be taken as a direct indication of coexistence.](../../figs/rho_set_TP_intra.pdf)

106
107


kunstler's avatar
kunstler committed
108
##+ ComputeTable_Effectsize, echo = FALSE, results = 'hide', message=FALSE
Kunstler Georges's avatar
Kunstler Georges committed
109
110
111
112
113
114
115
116
117
118
119
120
list.all.results <-
    readRDS.root('output/list.lmer.out.all.NA.intra.set.rds')

mat.param <- do.call('cbind',
               lapply(c('Wood.density', 'SLA', 'Max.height'),
                   extract.param, list.res = list.all.results,
                   model = 'lmer.LOGLIN.ER.AD.Tf.MAT.MAP.intra.r.set.species',
                   param.vec = c("(Intercept)", "logD", "Tf",
                                 "sumBn.intra","sumBn.inter",
                                 "sumTnBn","sumTfBn", "sumTnTfBn.abs"),
                   data.type = 'intra'))

Kunstler Georges's avatar
Kunstler Georges committed
121
122
123
124
mat.param[!row.names(mat.param) %in% c("(Intercept)", "logD",
                                       "Tf", "sumTfBn"),] <-
    -mat.param[!row.names(mat.param) %in% c("(Intercept)", "logD",
                                            "Tf", "sumTfBn"),]
Kunstler Georges's avatar
Kunstler Georges committed
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

mat.param.sd <- do.call('cbind',
                lapply(c('Wood.density', 'SLA', 'Max.height'),
                    extract.param.sd, list.res = list.all.results,
                    model = 'lmer.LOGLIN.ER.AD.Tf.MAT.MAP.intra.r.set.species',
                    param.vec = c("(Intercept)", "logD", "Tf",
                                  "sumBn.intra","sumBn.inter",
                                  "sumTnBn","sumTfBn", "sumTnTfBn.abs"),
                    data.type = 'intra'))

mat.R2c <- do.call('cbind',
              lapply(c('Wood.density', 'SLA', 'Max.height'),
                   extract.R2c, list.res = list.all.results,
                   model = 'lmer.LOGLIN.ER.AD.Tf.MAT.MAP.intra.r.set.species',
                   data.type = 'intra'))
mat.R2m <- do.call('cbind',
              lapply(c('Wood.density', 'SLA', 'Max.height'),
                   extract.R2m, list.res = list.all.results,
                   model = 'lmer.LOGLIN.ER.AD.Tf.MAT.MAP.intra.r.set.species',
                   data.type = 'intra'))
mat.AIC <- do.call('cbind',
              lapply(c('Wood.density', 'SLA', 'Max.height'),
                   extract.AIC, list.res = list.all.results,
                   model = 'lmer.LOGLIN.ER.AD.Tf.MAT.MAP.intra.r.set.species',
                   data.type = 'intra'))
mat.AIC.0 <- do.call('cbind',
                     lapply(c('Wood.density', 'SLA', 'Max.height'),
Kunstler Georges's avatar
Kunstler Georges committed
152
                            extract.AIC, list.res = list.all.results,
Kunstler Georges's avatar
Kunstler Georges committed
153
154
                            model = 'lmer.LOGLIN.MAT.MAP.intra.r.set.species',
                            data.type = 'intra'))
kunstler's avatar
kunstler committed
155

156
157
158
159
bold.index <- which(((mat.param - 1.96*mat.param.sd) >0 & mat.param > 0) |
                    ((mat.param + 1.96*mat.param.sd) <0 & mat.param <0),
                    arr.ind = TRUE)
mat.param.mean.sd <- matrix(paste0(round(mat.param, 3),
160
                            ' (',
161
                            round(mat.param.sd, 3),
162
163
                            ')'), ncol = 3)
mat.param <- rbind(mat.param.mean.sd,
kunstler's avatar
kunstler committed
164
                   round(mat.R2m, 4),
kunstler's avatar
kunstler committed
165
                   round(mat.R2c, 4),
Kunstler Georges's avatar
Kunstler Georges committed
166
167
                   round(mat.AIC- apply(rbind(mat.AIC,mat.AIC.0), MARGIN = 2, min), 0),
                   round(mat.AIC.0- apply(rbind(mat.AIC,mat.AIC.0), MARGIN = 2, min), 0))
168
colnames(mat.param) <- c('Wood density', 'SLA', 'Maximum height')
Kunstler Georges's avatar
Kunstler Georges committed
169
170
row.names(mat.param) <-  c('$m_0$', '$\\gamma$', '$m_1$',
                           '$\\alpha_{0 \\, intra}$','$\\alpha_{0 \\, inter}$',
171
                           '$\\alpha_e$', '$\\alpha_t$',
Kunstler Georges's avatar
Kunstler Georges committed
172
173
                           '$\\alpha_s$', '$R^2_m$*', '$R^2_c$*',
                           '$\\Delta$ AIC', '$\\Delta$ AIC no trait')
kunstler's avatar
kunstler committed
174
175

##+ Table2_Effectsize, echo = FALSE, results='asis', message=FALSE
Kunstler Georges's avatar
Kunstler Georges committed
176
pandoc.table(mat.param[c(1,3,2,4:12), ], caption = "Standardized parameters estimates and standard error (in bracket) estimated for each trait, $R^2$* of models and $\\Delta$ AIC of the model and of a model with no trait effect. Best model have a $\\Delta$ AIC of zero. See section Method for explanation of parameters",
177
178
             digits = 3,  justify = c('left', rep('right', 3)),
             emphasize.strong.cells = bold.index, split.tables = 200)
kunstler's avatar
kunstler committed
179

180
## \* We report the conditional and marginal $R^2$ of the models using the methods of reference[^1], modified by reference[^2]. $\Delta$ AIC is the difference in AIC between the model and the best model (lowest AIC). AIC is the Akaike's Information Criterion (as defined by reference[^3]), and the best-fitting model was identified as the one with a $\Delta$ AIC of zero. $\Delta$ AIC greater than 10 shows strong support for the best model^3^.
kunstler's avatar
kunstler committed
181
182
183
184

## [^1]: Nakagawa, S. & Schielzeth, H. A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution 4, 133–142 (2013).
## [^2]: Johnson, P. C. D. Extension of Nakagawa and Schielzeth’s R2GLMM to random slopes models. Methods in Ecology and Evolution 5, 944–946 (2014).
## [^3]: Burnham, K. P. & Anderson, D. R. Model selection and multimodel inference: A practical information-theoretic approach. (Springer-Verlag, New-York, 2002).
185

186
187