Commit 90e76830 authored by Kunstler Georges's avatar Kunstler Georges
Browse files

start revision text

parent b797e7d7
......@@ -10,10 +10,10 @@ summarise.jags.output <- function(x,
param.to.save = c('intercept', 'mean_logD', 'mean_Tf',
'mean_sumBn', 'mean_sumTfBn', 'mean_sumTnBn',
'mean_sumTnTfBn_abs')){
list(niter = x$n.iter,
summary = x$BUGSoutput$summary[param.to.save,],
DIC = x$BUGSoutput$DIC,
deviance = quantile(x$BUGSoutput$sims.matrix[, "deviance"], probs = c(0.025, 0.5, 0.975)))
library(runjags)
list(niter = x$output$sample,
summary = summary(x$output)[param.to.save, ],
DIC = x$output$dic)
}
summarise.jags.output.list <- function(f, probs = c(0.05, 0.1, 0.5, 0.9, 0.95) ){
......
......@@ -6,7 +6,7 @@ library(rworldmap, quietly = TRUE)
world.map <- function(Lon, Lat, col = "red", add = FALSE, cex=0.2){
if(!add){
par(mar = c(0, 0, 0, 0))
par(mar = c(0, 0, 0, 0), mai = c(0, 0, 0, 0))
newmap <- getMap(resolution = 'low')
plot(newmap, col= "white")
}
......
......@@ -5,7 +5,7 @@
## ```
## ![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).](image/worldmapB.png)
## ![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)
......
......@@ -118,9 +118,9 @@ form
\log{G_{i,f,p,s,t}} = \log{G_{\textrm{max} \, f,p,s}} + \gamma_f \, \log{D_{i,f,p,s,t}} + \sum_{c=1}^{N_i} {-\alpha_{c,f} B_{i,c,p,s}}.
\end{equation}
To include the effect of a focal species' traits, \(t_f\), on its
maximum growth,
we let:
To include the effects of traits on the parameters of the growth model we build on previous studies that explored the role of traits for tree performances and tree competition\citep{Uriarte-2010, Kunstler-2012, Lasky-2014}. We modelled the effect of trait, one trait at a time.
The effect of a focal species' trait value, \(t_f\), on its
maximum growth was include as:
\begin{equation} \label{Gmax}
\log{G_{\textrm{max} \, f,p,s}} = m_{0} + m_1 \, t_f + \varepsilon_{G_{\textrm{max}}, f} + \varepsilon_{G_{\textrm{max}}, p} + \varepsilon_{G_{\textrm{max}}, s}.
......@@ -136,7 +136,12 @@ quadrat \(p\) (see below), and data set \(s\) {[}where
and
\(\varepsilon_{G_{\textrm{max}, s}} \sim \mathcal{N} (0,\sigma_{G_{\textrm{max}, s}})\){]}.
To include trait effects on competition presented in Fig. 1, competitive
Previous studies have proposed different decomposition of the competition parameter into key trait-based processes\footnote{There has been different approach to model $\alpha$ from traits. In one of the first study Uriarte et al.\citep{Uriarte-2010} modelled $\alpha$ as $\alpha =
\alpha_0 + \alpha_s \vert t_f-t_c \vert$. Then Kunstler et al.\citep{Kunstler-2012} used two different models: $\alpha = \alpha_0 + \alpha_s \vert t_f-t_c \vert$ or $\alpha =
\alpha_0 + \alpha_h ( t_f-t_c )$. Finally, Lasky et al.\citep{Lasky-2014} developped one single model inculding multiple-processes as $\alpha =
\alpha_0 + \alpha_t t_f +\alpha_h ( t_f-t_c ) + \alpha_s \vert t_f-t_c
\vert$. In this study, we extended this last model by considering that it was more clear to split
$\alpha_h (t_f - t_c)$ in $\alpha_t t_f + \alpha_e t_c$, which is equivalent to the hierarchical distance if $\alpha_t = - \alpha_e$ (thus avoiding replication of $t_f$ effect through both $\alpha_h$ and $\alpha_t$).}, here we extended the approach of the most recent study\citep{Lasky-2014}. As presented in Fig. 1, competitive
interactions were modelled using an equation of the form\footnote{For
fitting the model the equation of \(\alpha_{c,f}\) was developped with
species basal area in term of community weighted mean of the trait,
......
......@@ -157,15 +157,14 @@ vegetation\citep{Keddy-1989}. Here we use growth data from
more than 3 million trees in more than 140000 plots across the world to
show how three key functional traits -- wood density, specific leaf area
and maximum height -- consistently influence competitive interactions.
Both low wood density and high specific leaf area directly increased
the maximum growth of a focal tree. At the same time, low wood density
reduced the ability of focal trees to tolerate competition, while high
specific leaf area reduced the competitive effect of that tree on its
Both low wood density and high specific leaf area were correlated to high maximum growth of a focal tree. At the same time, low wood density
was correlated with a low ability of focal trees to tolerate competition, while high
specific leaf area with a low competitive effect on its
neighbours. Smaller than these effects, but still detectable for all
three traits, was a limiting similarity effect, through which
neighbouring plants suffered more from competition when their traits were more similar. By demonstrating at a global scale that
neighbouring plants suffered more from competition when their traits were more similar. We thus demonstrate at a global scale that
traits generate trade-offs between performance with \emph{vs.} without
competition, we provide broad-scale support for the classic hypothesis
competition, a fundamental ingredient in the classic hypothesis
that coexistence of plant species is enabled via differentiation in
successional strategy\citep{Rees-2001}. In addition, our
trait-based approach to modelling competition reveals generalisations
......@@ -187,10 +186,9 @@ particularly for long-lived forest ecosystems. Competition is a key
filter through which ecological and evolutionary success is
determined\citep{Keddy-1989}. The few
studies\citep{Uriarte-2010, Kunstler-2012, HilleRisLambers-2012, Lasky-2014, Kraft-2015, Mayfield-2010}
that have explored links between traits and competition have questioned
that have explored links between traits and competition have shown that
the long-standing hypothesis that competition is stronger when two species have
similar trait values\citep{MacArthur-1967}, instead proposing that particular trait values may
confer competitive advantage\citep{Mayfield-2010, Kunstler-2012}. This
similar trait values\citep{MacArthur-1967} was not the only process at play. Links between traits and competition may also be the results of a correlation between particular trait values and a high competitive advantage\citep{Mayfield-2010, Kunstler-2012, Kraft-2014}. This
distinction is fundamental to understand species coexistence and the
local mixture of traits. If neighbourhood competition is driven
mainly by trait similarity, this will favour a wide spread of trait
......@@ -257,10 +255,9 @@ competitive effects, or better tolerance of competition (Fig.
importance to the direct effects of traits on maximum growth (Extended
data Table 3; Fig \ref{res1}). Low SLA caused species to exert a strong
competitive effect on their neighbours, whereas high wood density allowed species
to be more tolerant of competition from neighbours. Finally, there was a
small but consistent effect of trait similarity between focal and
to be more tolerant of competition from neighbours. Finally, there was a consistent effect of trait similarity between focal and
neighbour species, with greater similarity leading to stronger
competitive suppression of focal tree growth (Fig. \ref{res1}). This `limiting
competitive suppression of focal tree growth (Fig. \ref{res1}). This `trait
similarity' effect has generally been considered as the key mechanism
by which traits affect competition, but has rarely been confirmed with
field data\citep{Mayfield-2010}. Our analysis shows at
......@@ -273,14 +270,13 @@ biomes for SLA. This may reflect fundamental differences between
deciduous and evergreen plant lifeforms\citep{Lusk-2008} (further
details in Supplementary Discussion).
Importantly, our global study supports the hypothesis that trait values
Our global study supports the hypothesis that trait values
favouring high tolerance of competition or high competitive effects also
render species slow growing in the absence of competition across all
forested biomes (Fig. \ref{res3}). This trait-based trade-off is
critical because it confirms the classical model for successional
coexistence of species in forests, where fast-growing species dominate
forested biomes (Fig. \ref{res3}). This trait-based trade-off is a key ingredients in the classical model for successional
coexistence of species in forests, where fast-growing species are more abundant
in open areas where competitors are absent, and are later replaced by
slow-growing species that dominate in closed vegetation where
slow-growing species that are more abundant in closed vegetation where
competitors are present\citep{Rees-2001}. These trade-offs were
found for wood density and SLA (Fig. \ref{res3}). The
directions of trait-effects underpinning growth trade-offs agreed well with existing
......@@ -301,7 +297,7 @@ been expected\citep{Goldberg-1996, Kunstler-2012}.
However, we found little evidence for such coordination (see also
references \citep{Goldberg-1990, Goldberg-1991, Wang-2010}). Wood density and specific leaf area had
the same direction for their competitive effect and
tolerance of competition parameters. However, this coordination was weak because confidences intervals
tolerance of competition parameters. However, this coordination was weak because confidence intervals
intercepted zero for one parameter of both traits (Fig. \ref{res1}).
Finally, the underlying mechanisms explaining the limiting similarity
effect are unknown for these traits. They could include neighbouring
......@@ -316,13 +312,12 @@ globally consistent links that we report here between traits and
competition have considerable promise to overcome these problems, allowing
us to predict the complex species interactions governing forest communities
at a global scale. A challenge for the future is to analyse survival, fecundity and
recruitment as well as growth on the basis of traits. This would span
recruitment as well as growth on the basis of traits, for all the key life history stages. This would span
the whole life-cycle and build a more complete picture of the fitness
consequences of different traits. The analysis of growth presented
here already
demonstrates, that trait similarity is not the major determinant of local
scale competition among trees (see also references \citep{Mayfield-2010, Adler-2013, Kraft-2015}) and is thus not the central mechanism explaining the coexistence of species with diverse traits. However, at
the regional scale, a mosaic of successional stages can favour different
scale competition among trees (see also references \citep{Mayfield-2010, Adler-2013, Kraft-2015}) and is thus not the central mechanism explaining the coexistence of species with diverse traits. However, a mosaic of successional stages created from single tree deaths to large disturbances, can favour different
compromises along a trade-off axis between maximum growth and
performance in conditions of high competition, and thus promotes
coexistence of species with diverse traits.
......
......@@ -18,13 +18,11 @@ fi
samplesize=$1
for trait in "'SLA'" "'Wood.density'" "'Max.height'" ; do
for trait in "'SLA'""'Max.height'" ; do
# ALL data
for i in `seq 1 2` ; do
Rscript -e "source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[$i], run.lmer,$trait, sample.size =10, sample.vec.TF = TRUE) "
done
Rscript -e "source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[1], run.lmer,$trait, sample.size =10, sample.vec.TF = TRUE) "
done
......
......@@ -20,15 +20,15 @@ fi
samplesize=$1
# "'Seed.mass'" "'Leaf.N'"
for trait in "'SLA'" "'Wood.density'" "'Max.height'" ; do
for trait in "'Wood.density'" ; do
# # ALL data 1
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[1], run.lmer,$trait, sample.vec.TF = TRUE);print('done')\"" > Rscript_temp/allf${trait}.sh
qsub Rscript_temp/allf${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.f${trait}" -q opt32G -j oe
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[2], merge.biomes.TF = TRUE, run.lmer,$trait, sample.vec.TF = TRUE);print('done')\"" > Rscript_temp/allf2${trait}.sh
qsub Rscript_temp/allf2${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.f2${trait}" -q opt32G -j oe
# echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[2], merge.biomes.TF = TRUE, run.lmer,$trait, sample.vec.TF = TRUE);print('done')\"" > Rscript_temp/allf2${trait}.sh
# qsub Rscript_temp/allf2${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.f2${trait}" -q opt32G -j oe
......
......@@ -12,3 +12,4 @@ format.all.output.jags(file.name = "wwf.results.jags.rds",
traits = c("SLA", "Wood.density", "Max.height"))
# save all output in a list
source("R/analysis/lmer.output-fun.R")
source("R/analysis/lmer.run.R")
## ## save list of all output for NA
format.all.output.lmer(file.name = "NA.wwf.results.nolog.all.rds",
list.file.name = 'list.lmer.out.all.NA.simple.sample.rds',
models = c(model.files.lmer.Tf.1[1]),
traits = c("SLA", "Wood.density", "Max.height"))
## format.all.output.lmer(file.name = "NA.wwf.results.nolog.all.rds",
## list.file.name = 'list.lmer.out.all.NA.simple.set.rds',
## models = c(model.files.lmer.Tf.0, model.files.lmer.Tf.1,
## model.files.lmer.Tf.2, model.files.lmer.Tf.3),
## traits = c("SLA", "Wood.density", "Max.height"))
## format.all.output.lmer(file.name = "NA.wwf.results.nolog.all.rds",
## list.file.name = 'list.lmer.out.all.NA.intra.set.rds',
## models = c(model.files.lmer.Tf.intra.1,
## model.files.lmer.Tf.intra.2),
## traits = c("SLA", "Wood.density", "Max.height"),
## data.type = 'intra')
......@@ -8,335 +8,91 @@ library(runjags)
for(trait in c('SLA', 'Wood.density', 'Max.height')){
run.jags.b(model.files.jags.Tf.1[1], trait = trait,
init.TF = TRUE, var.sample = 'wwf',
sample.size = 10000, iter = 200,
sample.size = 20000, iter = 200,
warmup = 20, chains = 4,
thin = 2)
}
for(trait in c('SLA', 'Wood.density', 'Max.height')){
for(trait in c('Wood.density')){
run.jags.b(model.files.jags.Tf.1[1], trait = trait,
init.TF = FALSE, var.sample = 'wwf',
sample.size = 10000, iter = 10000,
sample.size = 10000, iter = 15000,
warmup = 5000, chains = 2,
thin = 5, method = 'parallel')
thin = 15, method = 'parallel')
}
## run.multiple.model.for.set.one.trait(model.files.jags.Tf.1[1], run.jags.b, trait = 'Wood.density',data.type='simple', sample.size = 1000, var.sample = 'wwf',iter = 200, warmup = 100, chains = 3, thin = 1, init.TF = FALSE, method = 'parallel')
## Rscript -e "source('R/analysis/jags.run.R'); library(runjags); sessionInfo(); run.multiple.model.for.set.one.trait(c(model.files.jags.Tf.1[1]), run.jags.b, trait = 'Wood.density',data.type='simple', sample.size = 1000, var.sample = 'wwf',iter = 200, warmup = 100, chains = 3, thin = 1, init.TF = FALSE, method = 'parallel');print('done')"
## echo "source('R/analysis/jags.run.R'); library(runjags); sessionInfo(); run.multiple.model.for.set.one.trait(c(model.files.jags.Tf.1[1]), run.jags.b, trait = 'Wood.density',data.type='simple', sample.size = 1000, var.sample = 'wwf',iter = 200, warmup = 100, chains = 3, thin = 1, init.TF = FALSE, method = 'parallel');print('done')" > Rscript_temp/speciesjagsWood.density.R
## R CMD BATCH Rscript_temp/speciesjagsWood.density.R
## res1 <- run.jags.b(model.files.jags.Tf.1[1], trait = 'Wood.density',
## init.TF = FALSE, var.sample = 'wwf',
## sample.size = 20000, iter = 2000,
## warmup = 1000, chains = 3,
## thin = 2, method= 'parallel')
## res1 <- run.jags.b(model.files.jags.Tf.1[2], trait = 'Wood.density',
## init.TF = FALSE, var.sample = 'wwf',
## sample.size = 10000, iter = 2000,
## warmup = 1000, chains = 4,
## thin = 2, method = 'parallel', merge.biomes.TF = TRUE)
## ### PROCESS OUTPUT !! MESSY
res <- as.mcmc(output.jags[[1]])
## crosscorr.plot(res)
## rejectionRate(res)
## gelman.diag(res)
## res.gg <- ggs(res)
## # select variables
## select.vars <- names(table(res.gg$Parameter))[!grepl('param', names(table(res.gg$Parameter)))]
## library(dplyr)
## res.gg.sel <- filter(res.gg, Parameter %in% select.vars)
## res.gg.sel$Parameter <- factor(res.gg.sel$Parameter)
## attributes(res.gg.sel)$nParameters <- length(select.vars)
## ggs_crosscorrelation(res.gg.sel)
### COMPARE JAGS AND LMER
source('R/analysis/lmer.output-fun.R')
list.lmer.results.set.sample <-
readRDS('output/list.lmer.out.all.NA.simple.sample.rds')
res.df <- data.frame(do.call('rbind', res))
res.df.sel <- res.df[,select.vars]
library(IDPmisc)
panel.hist <- function(x, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(usr[1:2], 0, 1.5) )
h <- hist(x, plot = FALSE)
breaks <- h$breaks; nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col="blue4", ...)
}
panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y, method = "spearman"))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex * r)
}
betterPairs <- function(YourData){
return(pairs(YourData, lower.panel=function(...) {par(new=TRUE);ipanel.smooth(...)}, diag.panel=panel.hist, upper.panel=panel.cor))
}
# Example
mean.l <- list.lmer.results.set.sample[[2]]$lmer.summary$fixed.coeff.E
sd.l <- list.lmer.results.set.sample[[2]]$lmer.summary$fixed.coeff.Std.Error
l.l <- mean.l -1.96*sd.l
h.l <- mean.l +1.96*sd.l
mean.l[c(4,6,7)] <- -mean.l[c(4,6,7)]
l.l[c(4,6,7)] <- -l.l[c(4,6,7)]
h.l[c(4,6,7)] <- -h.l[c(4,6,7)]
names(l.l) <- names(mean.l)
names(h.l) <- names(mean.l)
betterPairs(as.data.frame(res[, 1:18]))
res2 <- run.jags.b(model.files.jags.Tf.1[2], trait = 'Wood.density',
init.TF = FALSE, var.sample = 'wwf',
sample.size = 10000, iter = 2000,
warmup = 200, chains = 2,
thin = 2, merge.biomes.TF = FALSE)
## run.multiple.model.f
## or.set.one.trait(c(model.files.jags.Tf.1, model.files.jags.Tf.1b), run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 200, warmup = 20, chains = 3, thin = 2,
## init.TF = TRUE)
## res1 <- run.jags(model.files.jags.Tf.1, trait = 'Wood.density',
## type.filling = 'species',
## init.TF = FALSE, cat.TF = FALSE,
## sample.size = 100000, iter = 1000,
## warmup = 200, chains = 2,
## thin = 10, biomes.TF = TRUE)
## res1
## res2 <- run.jags(model.files.jags.Tf.2, trait = 'Wood.density',
## type.filling = 'species',
## init.TF = FALSE, cat.TF = FALSE,
## sample.size = 100000, iter = 1000,
## warmup = 200, chains = 2,
## thin = 10, biomes.TF = TRUE)
## res2
## res1b <- run.jags(model.files.jags.Tf.1b, trait = 'Wood.density',
## type.filling = 'species',
## init.TF = FALSE, cat.TF = FALSE,
## sample.size = 100000, iter = 10000,
## warmup = 2000, chains = 2,
## thin = 10, biomes.TF = TRUE)
## res1b
## res2b <- run.jags(model.files.jags.Tf.2b, trait = 'Wood.density',
## type.filling = 'species',
## init.TF = FALSE, cat.TF = FALSE,
## sample.size = 100000, iter = 1000,
## warmup = 200, chains = 2,
## thin = 10, biomes.TF = TRUE)
## res2b
## ### estimate computing time
## t1000 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1b,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 5000,
## warmup = 200, chains = 2,
## thin = 5,
## init.TF = FALSE))
## t1000.4 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 10000, warmup = 1000,
## chains = 3, thin = 10,
## init.TF = FALSE))
## t1000.8 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 50000, warmup = 20,
## chains = 3, thin = 50,
## init.TF = FALSE))
## ## 50000 obs
## run.multiple.model.for.set.one.trait(model.files.jags.Tf.1, run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 200, warmup = 20, chains = 3,
## init.TF = TRUE)
## t10000 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 200,
## warmup = 10, chains = 2,
## thin = 5,
## init.TF = FALSE))
## t10000.4 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 10000, warmup = 1000,
## chains = 3, thin = 10,
## init.TF = FALSE))
## t10000.8 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.1,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 50000, warmup = 20,
## chains = 3, thin = 50,
## init.TF = FALSE))
## sample.vec <- c(5000, 10000, 50000)
## t <- c(t1000['elapsed'], t1000.4['elapsed'], t1000.8['elapsed'])
## t2 <- c(t10000['elapsed'], t10000.4['elapsed'], t10000.8['elapsed'])
## pdf('time.jags.pdf')
## plot(sample.vec, t, ylim = range(t, t2), type = 'b')
## lines(sample.vec, t2, type = 'b', col = 'green')
## dev.off()
## ###
## run.multiple.model.for.set.one.trait(model.files.jags.Tf.2, run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 200, warmup = 20, chains = 3,
## init.TF = TRUE)
## t1000 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 5000,
## warmup = 500, chains = 3,
## thin = 5,
## init.TF = FALSE))
## t1000.4 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 10000, warmup = 1000,
## chains = 3, thin = 10,
## init.TF = FALSE))
## t1000.8 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 50000, warmup = 20,
## chains = 3, thin = 50,
## init.TF = FALSE))
## ## 50000 obs
## run.multiple.model.for.set.one.trait(model.files.jags.Tf.2, run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 200, warmup = 20, chains = 3,
## init.TF = TRUE)
## t10000 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 5000,
## warmup = 500, chains = 3,
## thin = 5,
## init.TF = FALSE))
## t10000.4 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 10000,
## var.sample = 'ecocode.id',
## iter = 10000, warmup = 1000,
## chains = 3, thin = 10,
## init.TF = FALSE))
## t10000.8 <- system.time(
## res <- run.multiple.model.for.set.one.trait(model.files.jags.Tf.2,
## run.jags,
## trait = 'Wood.density',
## type.filling='species',
## sample.size = 100000,
## var.sample = 'ecocode.id',
## iter = 50000, warmup = 20,
## chains = 3, thin = 50,
## init.TF = FALSE))
## sample.vec <- c(5000, 10000, 50000)
## t <- c(t1000['elapsed'], t1000.4['elapsed'], t1000.8['elapsed'])
## t2 <- c(t10000['elapsed'], t10000.4['elapsed'], t10000.8['elapsed'])
## pdf('time.jags.r.pdf')
## plot(sample.vec, t, ylim = range(t, t2), type = 'b')
## lines(sample.vec, t2, type = 'b', col = 'green')
## dev.off()
## ###
list.jags.results.set.sample <-
readRDS('output/list.jags.out.all.NA.simple.set.sample.rds')
mean.j <- list.jags.results.set.sample[[2]]$list.summary$summary[, 'Mean']
l.j <- list.jags.results.set.sample[[2]]$list.summary$summary[, 'Lower95']
h.j <- list.jags.results.set.sample[[2]]$list.summary$summary[, 'Upper95']
mean.j <- mean.j[c(1,3,2,4,5,6,7)]
l.j <- l.j[c(1,3,2,4,5,6,7)]
h.j <- h.j[c(1,3,2,4,5,6,7)]
names(mean.j) <- names(mean.l)
names(l.j) <- names(mean.l)
names(h.j) <- names(mean.l)
mean.j[c(4,6,7)] <- -mean.j[c(4,6,7)]
l.j[c(4,6,7)] <- -l.j[c(4,6,7)]
h.j[c(4,6,7)] <- -h.j[c(4,6,7)]
param.vec <- c("sumTnTfBn.abs", "sumTfBn","sumTnBn",
"sumBn", "Tf")
col.names <- fun.col.param()
param.names <- c(expression('Trait sim '(alpha['s'])),
expression('Tolerance '(alpha['t'])),
expression('Effect '(alpha['e'])),
expression('Trait indep'(alpha[0])),
expression("Direct trait "(m[1])))
par(mai=c(1.2, 2.8,