Skip to contents

The variance_partitioning_compute() function computes variance components with respect to given grouping of fixed effects and levels of random effects. This function inherits the main functionality from the Hmsc::computeVariancePartitioning function, but with the added functionality of parallel computation and using TensorFlow.
The variance_partitioning_plot() function generates plots for variance partitioning as JPEG files. It allows for sorting the predictors and species; e.g., by the mean value per predictor; and by original species order. It also plots the raw variance partitioning (relative variance partitioning multiplied by the Tjur-R2 value).

Usage

variance_partitioning_compute(
  path_model,
  group = NULL,
  group_names = NULL,
  start = 1L,
  na.ignore = FALSE,
  n_cores = 8L,
  use_TF = TRUE,
  TF_environ = NULL,
  TF_use_single = FALSE,
  temp_cleanup = TRUE,
  chunk_size = 50L,
  verbose = TRUE,
  VP_file = "VarPar",
  VP_commands_only = FALSE
)

variance_partitioning_plot(
  path_model,
  env_file = ".env",
  VP_file = "VarPar",
  use_TF = TRUE,
  TF_environ = NULL,
  n_cores = 1L,
  strategy = "multisession",
  width = 30,
  height = 15,
  Axis_text = 4
)

Arguments

path_model

Character. Path to fitted Hmsc model object.

group

vector of numeric values corresponding to group identifiers in groupnames. If the model was defined with XData and XFormula, the default is to use model terms.

group_names

vector of names for each group of fixed effect. Should match group. If the model was defined with XData and XFormula, the default is to use the labels of model terms.

start

index of first MCMC sample included. Default: 1L.

na.ignore

Logical. If TRUE, covariates are ignored for sites where the focal species is NA when computing variance-covariance matrices for each species.

n_cores

Integer. Number of CPU cores to use for computing variance partitioning using TensorFlow. This is only effective when use_TF is TRUE. Default: 1.

use_TF

Logical. Whether to use TensorFlow for calculations. Defaults to TRUE.

TF_environ

Character. Path to the Python environment. This argument is required if use_TF is TRUE under Windows. Defaults to NULL.

TF_use_single

Logical. Whether to use single precision for the TensorFlow calculations. Defaults to FALSE.

temp_cleanup

Logical. Whether to delete temporary files after processing. Default: TRUE.

chunk_size

Integer. Size of each chunk of samples to process in parallel. Only relevant for TensorFlow. Default: 50.

verbose

Logical. Whether to print progress messages. Default: TRUE.

VP_file

Character. Name of the output file to save the results. Default: VarPar.

VP_commands_only

Logical. If TRUE, returns the commands to run the Python script. Default is FALSE. Only relevant when use_TF is TRUE.

env_file

Character. Path to the environment file containing paths to data sources. Defaults to .env.

strategy

Character. The parallel processing strategy to use. Valid options are "sequential", "multisession" (default), "multicore", and "cluster". See future::plan() and ecokit::set_parallel() for details.

width, height

Numeric. Width and height of the output plot in centimetres. Default: 30 and 15, respectively.

Axis_text

Numeric. Size of the axis text. Default: 4.

Author

Ahmed El-Gabbas