Skip to contents

The VarPar_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 VarPar_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

VarPar_Compute(
  Path_Model,
  group = NULL,
  groupnames = NULL,
  start = 1L,
  na.ignore = FALSE,
  NCores = 8L,
  UseTF = TRUE,
  TF_Environ = NULL,
  TF_use_single = FALSE,
  Temp_Cleanup = TRUE,
  Chunk_size = 50L,
  Verbose = TRUE,
  VarParFile = "VarPar",
  VP_Commands_Only = FALSE
)

VarPar_Plot(
  Path_Model,
  EnvFile = ".env",
  VarParFile = "VarPar",
  UseTF = TRUE,
  TF_Environ = NULL,
  NCores = 1,
  Fig_width = 30,
  Fig_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.

groupnames

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

na.ignore

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

NCores

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

UseTF

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

TF_Environ

Character. Path to the Python environment. This argument is required if UseTF 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.

VarParFile

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 UseTF is TRUE.

EnvFile

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

Fig_width, Fig_height

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

Axis_text

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

Author

Ahmed El-Gabbas