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

fixe bugs in new subsampling per plot

parent e92a6834
......@@ -116,7 +116,7 @@ resample.plot.by.var <- function(df, var.sample, sample.size){
df2 <- add.sampling.prob.by.var.sample(df, var.sample)
mean.prob.per.plot <- tapply(df2[['prob.sample']], df2[['plot']], mean,
na.rm =TRUE)
rm(df2,df1)
rm(df2)
df1 <- data.frame(plot = names(mean.prob.per.plot),
prob.sample = as.numeric(mean.prob.per.plot))
num.sample.plot <- sample(1:nrow(df1), size = sample.size,
......@@ -141,7 +141,6 @@ 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'
browser()
if(!is.na(select.biome.)) {
df <- df[df$biomes == select.biome., ]
}
......
......@@ -14,7 +14,7 @@ model.files.stan.Tf.1 <-
fun.generate.init <- function(init.fun, list, N_chains){
inits <- lapply(1:N_chains,init.fun,list)
inits <- lapply(1:N_chains, init.fun, list)
return(inits)
}
......@@ -131,7 +131,7 @@ run.stan <- function (model.file, trait, init.TF,
#========================================================================
fun.load.stan <- function(trait,fname , cat.TF, sample.size, var.sample,
sample.vec.TF, select.biome, select.set){
sample.vec.TF, select.biome = NA, select.set = NA){
df.lmer <- load.data.for.lmer(trait,fname = fname, cat.TF = cat.TF,
sample.size. = sample.size,
var.sample. = var.sample,
......
#!/bin/bash
# Georges Kunstler 14/05/2014
# read one variable
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
iter=50000
warmup=5000
thin=50
# test parameter
nbargs=$#
echo "number of arguments="$nbargs
if [ $nbargs -ne 1 ]
then
echo "need one and only one argument"
echo " usage :"
echo " ./launch_all_lmer.sh sample.size"
exit 100
fi
samplesize=$1
#
for trait in "'SLA'" "'Wood.density'" "'Max.height'" "'Seed.mass'" "'Leaf.N'"; do
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/jags.run.R'); run.multiple.model.for.set.one.trait(c(model.files.jags.Tf.1), run.jags,$trait,type.filling='species', sample.size = $samplesize, var.sample = 'ecocode.id',iter = $iter, warmup = $warmup, chains = 3, thin = $thin, init.TF = TRUE);print('done')\"" > trait.workshop/speciesjags${trait}.sh
qsub trait.workshop/speciesjags${trait}.sh -l nodes=1:ppn=1,mem=8gb -N "jags${trait}" -q opt32G -j oe
done
......@@ -23,7 +23,7 @@ samplesize=$1
# "'Wood.density'" "'Max.height'"
for trait in "'SLA'" ; do
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/stan.run.R'); run.multiple.model.for.set.one.trait(model.files.stan.Tf.1[3], run.stan,$trait,type.filling='species', sample.size = $samplesize, var.sample = 'ecocode.id',iter = $iter, warmup = $warmup, chains = 1, chain_id = 1, init.TF = TRUE);print('done')\"" > trait.workshop/speciesstanA1${trait}.sh
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/stan.run.R'); run.multiple.model.for.set.one.trait(model.files.stan.Tf.1, run.stan,$trait,type.filling='species', sample.size = $samplesize, var.sample = 'ecocode',iter = $iter, warmup = $warmup, chains = 1, chain_id = 1, init.TF = TRUE);print('done')\"" > trait.workshop/speciesstanA1${trait}.sh
qsub trait.workshop/speciesstanA1${trait}.sh -l nodes=1:ppn=1,mem=8gb -N "stanallA1${trait}" -q opt32G -j oe
......
#!/bin/bash
# Georges Kunstler 14/05/2014
# read one variable
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
# test parameter
nbargs=$#
echo "number of arguments="$nbargs
if [ $nbargs -ne 1 ]
then
echo "need one and only one argument"
echo " usage :"
echo " ./launch_all_lmer.sh sample.size"
exit 100
fi
samplesize=$1
for trait in "'Wood.density'"; do
Rscript -e "source('R/analysis/stan.run.R'); run.multiple.model.for.set.one.trait(model.files.stan.Tf.1[3], run.stan,$trait,type.filling='species', sample.size = $samplesize, var.sample = 'ecocode.id', init.TF = TRUE);print('done')"
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