Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kunstler Georges
traitcompet
Commits
a4806faa
Commit
a4806faa
authored
Sep 03, 2014
by
Georges Kunstler
Browse files
fixe bugs in new subsampling per plot
parent
e92a6834
Changes
5
Hide whitespace changes
Inline
Side-by-side
R/analysis/lmer.run.R
View file @
a4806faa
...
...
@@ -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.
,
]
}
...
...
R/analysis/stan.run.R
View file @
a4806faa
...
...
@@ -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
,
...
...
launch.cluster/launch_all_jags_init.bash
deleted
100644 → 0
View file @
e92a6834
#!/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
launch.cluster/launch_all_stan.init.bash
View file @
a4806faa
...
...
@@ -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
...
...
launch.cluster/launch_all_stan_init_local.bash
deleted
100644 → 0
View file @
e92a6834
#!/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment