Commit b85582e8 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

fixe issue in resampling per species

parent d4a35297
......@@ -108,7 +108,8 @@ add.sampling.prob.by.var.sample <- function(df, var.sample){
vec.prob <- 1/table(df[[var.sample]])
df1 <- data.frame(ecocode = names(vec.prob),
prob.sample = as.numeric(vec.prob))
df2 <- merge(df, df1, by = 'ecocode')
names(df1) <- c(var.sample, 'prob.sample')
df2 <- merge(df, df1, by = var.sample)
return(df2)
}
......@@ -141,6 +142,7 @@ load.data.for.lmer <- function(trait, cat.TF,
df <- readRDS(file = file.path(base.dir,paste('data', trait, type,'rds',
sep = '.')))
df$sp.name[is.na(df$sp.name)] <- 'missing.sp'
if(!is.na(select.biome.)) {
df <- df[df$biomes == select.biome., ]
}
......
......@@ -17,7 +17,7 @@ source('R/analysis/stan.run.R')
fname = 'data.all.no.log.rds',
cat.TF = FALSE,
sample.size = 500,
var.sample = 'ecocode',
var.sample = 'sp.name',
sample.vec.TF. = FALSE)
stan.list <- fun.turn.in.list.for.jags.stan(df.lmer,
......@@ -97,7 +97,7 @@ ggs_caterpillar(S)
source("R/analysis/stan.output-fun.R")
stan.out.clust <- fun.merge.chain(
path.out = "output/stan/all.no.log/SLA/species/LOGLIN.ER.AD.Tf.fixed.biomes/",
path.out = "output/stan/all.no.log/SLA/species/LOGLIN.ER.AD.Tf.fixed/",
var.sample = 'ecocode', chains.vec = 1:3)
stan.out.clust
......
......@@ -9,10 +9,9 @@ pwd
for trait in "SLA" "Leaf.N" "Wood.density" "Max.height" "Seed.mass"; do
Rscript -e "print(getwd()); source('R/analysis/lmer.run.R')"
# ; load.and.save.data.for.lmer('$trait')
Rscript -e "source('R/analysis/lmer.run.R'); load.and.save.data.for.lmer('$trait')"
# Rscript -e "source('R/analysis/lmer.run.R'); load.and.save.data.for.lmer('$trait', fname = 'data.all.log.rds')"
Rscript -e "source('R/analysis/lmer.run.R'); load.and.save.data.for.lmer('$trait', fname = 'data.all.log.rds')"
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment