Skip to contents

This function prepares cross-validated Hmsc models for fitting using HPC. It handles data preparation, model initialization, and generation of SLURM commands.

Usage

Mod_CV_Fit(
  Model = NULL,
  ModelData = NULL,
  CVName = c("CV_Dist", "CV_Large"),
  partitions = NULL,
  Path_CV = NULL,
  EnvFile = ".env",
  initPar = NULL,
  JobName = "CV_Models",
  updater = list(Gamma2 = FALSE, GammaEta = FALSE),
  alignPost = TRUE,
  ToJSON = FALSE,
  FromHPC = TRUE,
  PrepSLURM = TRUE,
  MemPerCpu = NULL,
  Time = NULL,
  Path_Hmsc = NULL,
  Precision = 64,
  ...
)

Arguments

Model

Either a path to a saved model file (character) or an Hmsc model object. If a path is provided, the model is loaded from the file.

ModelData

Character. Path to input data used to fit the model.

CVName

Character vector specifying the name of the column(s) in the model input data (see Mod_PrepData and GetCV) to be used to cross-validate the models. The function allows the possibility of using more than one way of assigning grid cells into cross-validation folders. If multiple names are provided, separate cross-validation models will be fitted for each column. Currently, there are three cross-validation strategies, created using the Mod_PrepData: CV_SAC, CV_Dist, and CV_Large (see GetCV).

partitions

A vector for cross-validation created by Hmsc::createPartition or similar. Defaults to NULL, which means to use column name(s) provided in the CVName argument. If the partitions vector is provided, the label used in the output files will be CV_Custom.

Path_CV

The directory path where cross-validation models and outputs will be stored. If Model argument is a character vector, it will be estimated from the model path. If Model is an Hmsc model object, it has to be provided by the user, otherwise the function will give an error.

EnvFile

String. Path to read the environment variables. Default value: .env.

initPar

a named list of parameter values used for initialization of MCMC states. See Hmsc::computePredictedValues for more information. Default: NULL.

JobName

String specifying the name of the submitted job(s) for SLURM. Default: CV_Models.

updater

a named list, specifying which conditional updaters should be omitted. See Hmsc::computePredictedValues for more information. Defaults to list(Gamma2 = FALSE, GammaEta = FALSE) to disable the following warnings: setting updater$Gamma2=FALSE due to specified phylogeny matrix and setting updater$GammaEta=FALSE: not implemented for spatial methods 'GPP' and 'NNGP'.

alignPost

boolean flag indicating whether the posterior of each chains should be aligned. See Hmsc::computePredictedValues for more information. Default: TRUE.

ToJSON

Logical indicating whether to convert unfitted models to JSON before saving to RDS file. Default: FALSE.

FromHPC

Logical. Indicates if the operation is being performed from an HPC environment. This adjusts file paths accordingly. Default: TRUE.

PrepSLURM

Logical indicating whether to prepare SLURM command files. If TRUE (default), the SLURM commands will be saved to disk using the Mod_SLURM function.

MemPerCpu

String. Memory per CPU allocation for the SLURM job. Example: 32G for 32 gigabytes. Defaults to NULL. If not provided, the function will throw an error.

Time

String. Duration for which the job should run. Example: 01:00:00 for one hour. If not provided, the function will throw an error.

Path_Hmsc

String. Path for the Hmsc-HPC.

Precision

Integer, either of 32 (default; --fp 32) or 64 for the precision mode used for sampling while fitting Hmsc-HPC models (--fp 64 argument). In Hmsc-HPC, the default value is 64. This is still under testing.

...

Additional arguments passed to the Mod_SLURM function.

Details

The function copies part of the Hmsc::computePredictedValues function, which currently does not support performing cross-validation using Hmsc-HPC. Although it is possible to make some changes to the Hmsc::computePredictedValues to make it possible to use Hmsc-HPC, this does not help as our intention is to use the Hmsc-HPC using GPU.

Author

Ahmed El-Gabbas