Commit 6335662d authored by matbuoro's avatar matbuoro
Browse files

multiple chains and inits added

parent b168dcd7
......@@ -44,7 +44,8 @@ if(!file.exists(paste("inits/init-",site,"-",stade,year,".txt",sep=""))){
#load(paste('inits/inits_',stade,'.Rdata',sep="")) # chargement des inits
#if(site == "Bresle" && stade == "adult") {inits <- list(read.bugsdata(paste("inits/init-",site,"-",stade,year,".txt",sep="")))}
#if(site == "Nivelle") {inits <- list(read.bugsdata(paste("inits/init-",site,"-",stade,year,".txt",sep="")))}
inits <- list(read.bugsdata(paste("inits/init-",site,"-",stade,year,".txt",sep="")))
inits.tmp <- read.bugsdata(paste("inits/init-",site,"-",stade,year,".txt",sep=""))
inits <- rep(list(inits.tmp),CHAINS)
#------------------------MODEL----------------------------------##
model <- paste("model/model_",stade,"-",site,".R",sep="") # path of the model
......@@ -56,7 +57,7 @@ filename <- file.path(work.dir, model)
#---------------------------ANALYSIS-----------------------------##
nChains = length(inits) # Number of chains to run.
nChains = CHAINS #length(inits) # Number of chains to run.
adaptSteps = 1000 # Number of steps to "tune" the samplers.
nburnin=BURNIN # Number of steps to "burn-in" the samplers.
nstore=ITER # Total number of steps in chains to save.
......@@ -139,7 +140,7 @@ cat("=============================\n")
if (nChains > 1) {
cat("Convergence: gelman-Rubin R test\n")
gelman.diag(fit.mcmc[,which(varnames(fit.mcmc)%in%parameterstotest)])
gelman.diag(fit.mcmc[,which(varnames(fit.mcmc)%in%parameterstotest)],multivariate=TRUE)
}
......@@ -177,6 +178,7 @@ pdf(paste('results/Results_',stade,"_",year,'.pdf',sep=""))
traplot(fit.mcmc[,which(varnames(fit.mcmc)%in%parameterstotest)])
# caterplot(fit.mcmc,parameters[i])
#}
gelman.plot(fit.mcmc[,which(varnames(fit.mcmc)%in%parameterstotest)])
dev.off()
......
......@@ -3,15 +3,16 @@
#SITE=Scorff # Nivelle Oir Bresle
YEAR=2016
CHAINS=3
BURNIN=5000 # Number of steps to "burn-in" the samplers.
ITER=25000 # Total number of steps in chains to save.
THIN=4 # Number of steps to "thin" (1=keep every step).
THIN=2 # Number of steps to "thin" (1=keep every step).
REPbase="/home/basp-meco88/Documents/RESEARCH/PROJECTS/ORE/Abundance"
#"/media/ORE/Abundance"
for SITE in Bresle Nivelle Oir Scorff
for SITE in Bresle #Nivelle Oir Scorff
do
cd $REPbase/$SITE
......@@ -28,15 +29,16 @@ cd $REPbase/$SITE
sed 's|SITE|'"$SITE"'|g' -i $STADE/analyse_"$STADE".R
sed 's|STADE|'"$STADE"'|g' -i $STADE/analyse_"$STADE".R
sed 's|YEAR|'"$YEAR"'|g' -i $STADE/analyse_"$STADE".R
sed 's|CHAINS|'"$CHAINS"'|g' -i $STADE/analyse_"$STADE".R
sed 's|BURNIN|'"$BURNIN"'|g' -i $STADE/analyse_"$STADE".R
sed 's|ITER|'"$ITER"'|g' -i $STADE/analyse_"$STADE".R
sed 's|THIN|'"$THIN"'|g' -i $STADE/analyse_"$STADE".R
# R CMD BATCH --no-save --no-restore $STADE/analyse_"$STADE".R #& # analyse dans R
R CMD BATCH --no-save --no-restore $STADE/analyse_"$STADE".R #& # analyse dans R
#rm -f $STADE/CODAindex.txt
#rm -f analyse_"$STADE".R
rm -f analyse_"$STADE".Rout
#rm -f analyse_"$STADE".Rout
fi
done
done
......
Supports Markdown
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