Skip to contents

This function modifies the Hmsc:::predict.Hmsc function.

Usage

Predict_Hmsc(
  Path_Model,
  Loff = NULL,
  XData = NULL,
  X = NULL,
  XRRRData = NULL,
  XRRR = NULL,
  Gradient = NULL,
  Yc = NULL,
  mcmcStep = 1L,
  expected = TRUE,
  NCores = 8L,
  Model_Name = "Train",
  Temp_Dir = "TEMP_Pred",
  Temp_Cleanup = TRUE,
  RC = NULL,
  UseTF = TRUE,
  TF_Environ = NULL,
  TF_use_single = FALSE,
  LF_OutFile = NULL,
  LF_Return = FALSE,
  LF_InputFile = NULL,
  LF_Only = FALSE,
  LF_NCores = NCores,
  LF_Check = FALSE,
  LF_Temp_Cleanup = TRUE,
  LF_Commands_Only = FALSE,
  Pred_Dir = NULL,
  Pred_PA = NULL,
  Pred_XY = NULL,
  Evaluate = FALSE,
  Eval_Name = NULL,
  Eval_Dir = "Evaluation",
  Verbose = TRUE
)

Arguments

Path_Model

character string specifying a file name where the model object is saved.

XData

a dataframe specifying the unpreprocessed covariates for the predictions to be made. Works only if the XFormula argument was specified in the Hmsc::Hmsc model constructor call. Requirements are similar to those in the Hmsc model constructor.

X

a matrix specifying the covariates for the predictions to be made. Only one of XData and X arguments may be provided.

XRRRData

a dataframe of covariates for reduced-rank regression.

XRRR

a matrix of covariates for reduced-rank regression.

Gradient

an object returned by Hmsc::constructGradient. Providing Gradient is an alternative for providing XData, studyDesign and ranLevels. Cannot be used together with Yc.

Yc

a matrix of the outcomes that are assumed to be known for conditional predictions. Cannot be used together with Gradient.

mcmcStep

the number of extra mcmc steps used for updating the random effects

expected

boolean flag indicating whether to return the location parameter of the observation models or sample the values from those.

NCores

Integer specifying the number of cores to use for parallel processing. Defaults to 8.

Model_Name

Character string used as a prefix for temporary file names. Defaults to NULL, in which case no prefix is used.

Temp_Dir

Character string specifying the path for temporary storage of intermediate files.

Temp_Cleanup

logical, indicating whether to clean up temporary files. Defaults to TRUE.

RC

a character string specifying the type of predictions to be made. If NULL (default), predictions are made for the latent factors. If c, predictions are made for response curves at mean coordinates. If i, predictions are made for response curves at infinite coordinates.

UseTF

Logical indicating whether to use TensorFlow for calculations. Defaults to TRUE.

TF_Environ

Character string specifying the path to the Python environment. Defaults to NULL. This argument is required if UseTF is TRUE.

TF_use_single

Logical indicating whether to use single precision for the TF calculations. Defaults to FALSE.

LF_OutFile

Character string specifying the path to save the outputs. If NULL (default), the predicted latent factors are not saved to a file. This should end with either *.qs2 or *.RData.

LF_Return

Logical. Indicates if the output should be returned. Defaults to FALSE. If LF_OutFile is NULL, this parameter cannot be set to FALSE because the function needs to return the result if it is not saved to a file.

LF_InputFile

a character string specifying the file name where the latent factor predictions are saved. If NULL (default), latent factor predictions will be made. If specified, the latent factor predictions are read from the file. This allows to predicting the latent factors for new sites only once.

LF_Only

a logical flag indicating whether to return the latent factor predictions only. Defaults to FALSE. This helps in predicting to new sites, allowing to predicting the latent factors only once, then the output can be loaded in other predictions when needed.

LF_NCores

Integer specifying the number of cores to use for parallel processing. Defaults to 8.

LF_Check

Logical. If TRUE, the function checks if the output files are already created and valid. If FALSE, the function will only check if the files exist without checking their integrity. Default is FALSE.

LF_Temp_Cleanup

Logical indicating whether to delete temporary files in the Temp_Dir after finishing the LF predictions.

LF_Commands_Only

logical. If TRUE, returns the command to run the Python script. Default is FALSE.

Pred_Dir

a character string specifying the directory where the predictions will be saved. Defaults to NULL, which saves model predictions to "Model_Prediction" folder of the current working directory.

Pred_PA

a matrix of presence-absence data for evaluation. If NULL (default), the presence-absence data from the model object is used. This argument is used only when Evaluate is TRUE.

Pred_XY

a matrix of coordinates to be added to predicted values. If NULL (default), the coordinates from the model object is used.

Evaluate

a logical flag indicating whether to evaluate the model predictions. Defaults to FALSE.

Eval_Name

a character string specifying the name of the evaluation results. If NULL, the default name is used (Eval_[Model_Name].qs2).

Eval_Dir

a character string specifying the directory where the evaluation results will be saved. Defaults to Evaluation.

Verbose

Logical. If TRUE, detailed output is printed. Default is FALSE.