knitr::opts_chunk$set(echo = TRUE)
sections_to_be_loaded <- c()
source("vignettes/analysis_nonpublic.R")

Header

Aim : create diagnostic plots of the models and compare.

The respective input datasets are loaded just before plotting.

Model diagnostic plots

Some of the diagnostic plots of the GDMs look very crappy. Does the %deviance explained correspond to the crappyness of the GDM model fit?

EFdist

High % dev expl

efdist <- readRDS(paste(pathtodata, "/analysis/output_datasets/gdm_EFdistance_LUI_output.Rds", sep = ""))
# efdist$explained # 29.99
cairo_pdf(paste("vignettes/out/gdm_EFdistance_LUI_GDM_diagnostic_plot.pdf", sep = ""), width = 11.7, height = 8.3)
plot_diagn_gdm(efdist, title = "Efdistane")
dev.off()

EF turnover

Saving diagnostic plot of each model to a separate pdf file.

efto0.5 <- readRDS(paste(pathtodata, "/analysis/output_datasets/gdm_EFturnover_0.5_LUI_output.Rds", sep = ""))
efto0.5$explained # 12.19
plot_diagn_gdm(efto0.5)
# 9 plots
EFturnover_varexpl <- list()
for(i in seq(0.1, 0.9, 0.1)){
  print(i)
  mod <- readRDS(paste(pathtodata, "/analysis/output_datasets/gdm_EFturnover_", i, "_LUI_output.Rds", sep = ""))
  EFturnover_varexpl <- append(EFturnover_varexpl, mod$explained)
  cairo_pdf(paste("vignettes/out/gdm_EFturnover_",i ,"_LUI_diagnostic_plot.pdf", sep = ""), width = 11.7, height = 8.3)
  plot_diagn_gdm(mod, title = paste("EFturnover", i))
  dev.off()
}
# note : don't need to save variance explained as this is saved in script "summarise_GDM_results.Rmd"
# EFturnover_varexpl

EF nestedness

Saving diagnostic plot of each model to a separate pdf file.

# 9 plots
EFnestedness_varexpl <- list()
for(i in seq(0.1, 0.9, 0.1)){
  print(i)
  mod <- readRDS(paste(pathtodata, "/analysis/output_datasets/gdm_EFnestedness_", i, "_LUI_output.Rds", sep = ""))
  EFnestedness_varexpl <- append(EFnestedness_varexpl, mod$explained)
  # plot and save
  cairo_pdf(paste("vignettes/out/gdm_EFnestedness_",i ,"_LUI_diagnostic_plot.pdf", sep = ""), width = 11.7, height = 8.3)
  plot_diagn_gdm(mod, title = paste("EFnestedness", i))
  dev.off()
}
# note : don't need to save variance explained as this is saved in script "summarise_GDM_results.Rmd"
# EFnestedness_varexpl

single EF models

Saving all diagnostic plots of single function models to one pdf file

singleEF_varexpl <- list()
cairo_pdf(paste("vignettes/out/gdm_ALL_singleEFmodels_LUI_diagnostic_plot.pdf", sep = ""), width = 11.7, height = 8.3, onefile=T)
for(i in model_names[model_class == "singlefun", modelname]){
  print(i)
  mod <- readRDS(paste(pathtodata, "/analysis/output_datasets/", i, "_output.Rds", sep = ""))
  singleEF_varexpl <- append(singleEF_varexpl, mod$explained)
  plot_diagn_gdm(mod, title = i)
}
names(singleEF_varexpl) <- model_names[model_class == "singlefun", modelname]
dev.off()
# note : don't need to save variance explained as this is saved in script "summarise_GDM_results.Rmd"


allanecology/BetaDivMultifun documentation built on Nov. 9, 2023, 8:47 p.m.