partition: partition vector for cross-validation created by createPartition
partition.sp: species partitioning vector for conditional cross-validation
start: index of first MCMC sample included
thin: thinning interval of posterior distribution
Yc: response matrix on which the predictions are to be conditioned
mcmcStep: number of MCMC steps used to make conditional predictions
expected: whether expected values (TRUE) or realizations (FALSE) are to be predicted
initPar: a named list of parameter values used for initialization of MCMC states
nParallel: number of parallel processes by which the chains are executed
nChains: number of independent MCMC chains to be run
updater: a named list, specifying which conditional updaters should be omitted
verbose: the interval between MCMC steps printed to the console
alignPost: boolean flag indicating whether the posterior of each chains should be aligned
useSocket: (logical) use socket clusters in parallel processing; these can be used in all operating systems, but they are usually slower than forking which can only be used in non-Windows operating systems (macOS, Linux, unix-like systems).
Returns
an array of model predictions, made for each posterior sample
Details
There are two alternative functions computePredictedValues
and pcomputePredictedValues. Function pcomputePredictedValues uses more aggressive parallelization and can be much faster when partition is used. Function computePredictedValues can run chains of each sampleMcmc partition in parallel, but pcomputePredictedValues can run each partition fold times chain in parallel (if hardware and operating systems permit). Function pcomputePredictedValues is still experimental, and therefore we provide both the old and new functions, but the old functions is scheduled to be removed in the future. Species partitions are not yet parallelized, and they can be very slow, especially with many mcmcSteps.
If the option partition is not used, the posterior predictive distribution is based on the model fitted to the full data. If the option partition is used but partition.sp is not used, the posterior predictive distribution is based on cross-validation over the sampling units. If partition.sp is additionally used, then, when predictions are made for each fold of the sampling units, the predictions are done separately for each fold of species. When making the predictions for one fold of species, the predictions are conditional on known occurrences (those observed in the data) of the species belonging to the other folds. If partition.sp is used, the parameter mcmcStep should be set high enough to obtain appropriate conditional predictions. The option Yc can be used alternatively to partition.sp if the conditioning is to be done based on a fixed set of data (independently of which sampling unit and species the predictions are made for).
Examples
# Compute predicted values using a previously fitted HMSC modelpreds = computePredictedValues(TD$m)## Not run:# Compute predicted values for a previously fitted HMSC model using 2 foldspartition = createPartition(TD$m, nfolds =2)predsCV1 = computePredictedValues(TD$m,partition=partition)# Compute conditional predictions for a previously fitted HMSC model using 2 foldspartition = createPartition(TD$m, nfolds =2)predsCV2 = computePredictedValues(TD$m, partition = partition,partition.sp =1:TD$m$ns, mcmcStep =100)## End(Not run)