Commit 204db846 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

new report

parent 93f19645
......@@ -8,11 +8,11 @@ traits <- c("SLA", "Wood.density","Max.height","Leaf.N","Seed.mass")
type.filling <- 'species'
files <- c()
for (trait in traits){
for(model in c(model.files.lmer.Tf.1, model.files.lmer.Tf.2,
model.files.lmer.Tf.3, model.files.lmer.Tf.4)){
for(model in c(model.files.glmer.Tf.1, model.files.glmer.Tf.2,
model.files.glmer.Tf.3[-3], model.files.glmer.Tf.4)){
source(model, local = TRUE)
model.obj <- load.model()
pathout <- output.dir.glmer(model.obj$name, trait, 'all',
pathout <- output.dir.glmer(model.obj$name, trait,
type.filling=type.filling)
files <- c(files,file.path(pathout,"glmer.results.global.rds"))
......
......@@ -9,7 +9,6 @@ read.glmer.output <- function(file.name){
}
summarise.glmer.output <- function(x){
list( nobs = nobs(x),
R2m =Rsquared.glmm.lmer(x)$Marginal,
......@@ -23,6 +22,20 @@ summarise.glmer.output <- function(x){
fixed.var=variance.fixed.glmm.lmer(x))
}
summarise.glmer.all.output <- function(x){
list( nobs = nobs(x),
R2m =Rsquared.glmm.lmer(x)$Marginal,
R2c =Rsquared.glmm.lmer(x)$Conditional,
AIC = AIC(x),
deviance = deviance(x),
conv=x@optinfo$conv,
effect.response.var=variance.fixed.glmm.lmer.effect.and.response(x),
fixed.coeff.E=fixef(x),
fixed.coeff.Std.Error=sqrt(diag(vcov(x))),
fixed.var=variance.fixed.glmm.lmer(x),
set.BLUP=coef(x)$set.id)
}
summarise.glmer.output.list <- function(f ){
output.glmer <- read.glmer.output(f)
......@@ -35,6 +48,17 @@ summarise.glmer.output.list <- function(f ){
return(res)
}
summarise.glmer.output.list <- function(f ){
output.glmer <- read.glmer.output(f)
if(!is.null(output.glmer)){
res <- list(files.details=files.details.all(f),
glmer.summary=summarise.glmer.all.output( output.glmer))
}else{
res <- NULL
}
return(res)
}
files.details <- function(x){
......@@ -43,6 +67,12 @@ files.details <- function(x){
s[-(1:2)]
}
files.details.all <- function(x){
s <- data.frame(t(strsplit(x, "/", fixed=TRUE)[[1]]), stringsAsFactors= FALSE)
names(s) <- c("d1", "d2", "set", "trait", "filling", "model", "file" )
s[-(1:2)]
}
#### R squred functions
......
......@@ -142,7 +142,7 @@ return((x-mean(x))/sd(x))
}
### get variables for lmer
fun.get.the.variables.for.glmer.tree.id <- function(data.tree,BATOT,CWM.tn,
fun.get.the.variables.for.glmer.no.tree.id <- function(data.tree,BATOT,CWM.tn,
abs.CWM.tntf,tf,min.BA.G=50){
dead <- data.tree[["dead"]]
logD <- fun.center.and.standardized.var(log(data.tree[["D"]]))
......
......@@ -9,7 +9,7 @@ type.filling <- 'species'
files <- c()
for (trait in traits){
for(model in c(model.files.lmer.Tf.1, model.files.lmer.Tf.2,
model.files.lmer.Tf.3, model.files.lmer.Tf.4)){
model.files.lmer.Tf.3, model.files.lmer.Tf.4[-4])){
source(model, local = TRUE)
model.obj <- load.model()
pathout <- output.dir.lmer(model.obj$name, trait, 'all',
......@@ -19,6 +19,7 @@ for (trait in traits){
}
}
out <- lapply(files, summarise.lmer.output.all.list)
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ read.lmer.output <- function(file.name){
summarise.lmer.output <- function(x){
summarise.lmer.all.output <- function(x){
list( nobs = nobs(x),
R2m =Rsquared.glmm.lmer(x)$Marginal,
R2c =Rsquared.glmm.lmer(x)$Conditional,
......@@ -21,7 +21,7 @@ summarise.lmer.output <- function(x){
fixed.coeff.E=fixef(x),
fixed.coeff.Std.Error=sqrt(diag(vcov(x))),
fixed.var=variance.fixed.glmm.lmer(x),
ecocode.BLUP=coef(x)$set.id)
set.BLUP=coef(x)$set.id)
}
......@@ -108,3 +108,24 @@ return(var.vec)
## create a data base from the global data
fun.merge.results.global <- function(list.res,
names.param = c( "(Intercept)", "Tf",
"logD", "sumBn", "sumTnBn",
"sumTfBn", "sumTnTfBn.abs",
"sumTnTfBn.diff")){
df.details <- data.frame(list.res$files.details[1:4],
list.res$lmer.summary[1:6])
fun.rep.df <- function(x, df = df.details) df
n_rep <- nrow(list.res$lmer.summary$ecocode.BLUP)
dat.t <- data.frame(matrix(rep(NA,n_rep * length(names.param)), nrow = n_rep,
ncol = length(names.param)))
names(dat.t) <- c(names.param)
dat.t[, match(names(list.res$lmer.summary$ecocode.BLUP), names(dat.t))] <-
list.res$lmer.summary$ecocode.BLUP
df.res <- data.frame(ecocode = rownames(list.res$lmer.summary$ecocode.BLUP),
do.call( "rbind", lapply(1:n_rep, fun.rep.df)),
dat.t)
return(df.res)
}
load.model <- function () {
list(name="glmer.LOGLIN.AD.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+log+MAT+MAP+(1+logD|species.id)+(1|plot.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+log+MAT+MAP+(1+logD|species.id)+(1|plot.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.E.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.ER.AD.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+(1-logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+(1-logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.ER.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.HD.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.diff+sumTnTfBn.diff:MAT+sumTnTfBn.diff:MAP+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.diff-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.diff+sumTnTfBn.diff:MAT+sumTnTfBn.diff:MAP+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.diff-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.R.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTfBn-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTfBn-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.simplecomp.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+(1+logD|species.id)+(1|plot.id)+(1|set.id)+(Tf-1|set.id)"))
}
load.model <- function () {
list(name="glmer.LOGLIN.simplecomp.Tf.MAT.MAP",
glmer.formula=formula("dead~1+Tf+logD+MAT+MAP+(1+logD|species.id)+(1|set.id)+(1|plot.id)+sumBn+sumBn:MAT+sumBn:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)"))
glmer.formula=formula("dead~1+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+(1+logD|species.id)+(1|set.id)+(1|plot.id)+sumBn+sumBn:MAT+sumBn:MAP+(Tf-1|set.id)+(sumTfBn-1|set.id)"))
}
......
load.model <- function () {
list(name="lmer.LOGLIN.ER.Tf.MAT.MAP",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+MAT+MAP+logD+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumBn+sumBn:MAT+sumBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
......
load.model <- function () {
list(name="lmer.LOGLIN.AD.Tf.randomset",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sumBn+sumTnTfBn.abs+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
load.model <- function () {
list(name="lmer.LOGLIN.E.Tf.MAT.MAP",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)") )
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+logD+MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)") )
}
......
load.model <- function () {
list(name="lmer.LOGLIN.E.Tf.randomset",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sumBn+sumTnBn+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)") )
}
load.model <- function () {
list(name="lmer.LOGLIN.ER.AD.Tf.MAT.MAP",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+MAT+MAP+logD+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
......
load.model <- function () {
list(name="lmer.LOGLIN.ER.Tf.MAT.MAP",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+MAT+MAP+logD+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"))
}
......
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