predict.Hmsc: predict

View source: R/predict.R

predict.HmscR Documentation

predict

Description

Calculates predicted values from a fitted Hmsc model.

Usage

## S3 method for class 'Hmsc'
predict(
  object,
  post = poolMcmcChains(object$postList),
  XData = NULL,
  X = NULL,
  XRRRData = NULL,
  XRRR = NULL,
  studyDesign = object$studyDesign,
  ranLevels = object$ranLevels,
  Gradient = NULL,
  Yc = NULL,
  mcmcStep = 1,
  expected = FALSE,
  predictEtaMean = FALSE,
  predictEtaMeanField = FALSE,
  nParallel = 1,
  useSocket = TRUE,
  ...
)

Arguments

object

a fitted Hmsc model object

post

a list of posterior samples of the HMSC model. By default uses all samples from the pooled posterior of the hM object.

XData

a dataframe specifying the unpreprocessed covariates for the predictions to be made. Works only if the XFormula argument was specified in the 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

studyDesign

a matrix, specifying the structure of the study design for the prediction. Requirements are similar to those of the Hmsc constructor. By default this argument is assigned the study design of the training data in the fitted Hmsc model.

ranLevels

a list of HmscRandomLevel objects, futher specifying the structure of random levels. Requirements are similar to those of the Hmsc constructor. Each level must cover all units, specified in the correspondingly named column of studyDesign argument. By default this argument is assigned the list of HmscRandomLevel objects specified for fitting Hmsc model.

Gradient

an object returned by 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.

predictEtaMean

boolean flag indicating whether to use the estimated mean values of posterior predictive distribution for random effets corresponding for the new units.

predictEtaMeanField

boolean flag indicating whether to use draws from the mean-field of the posterior predictive distribution for random effets corresponding for the new units.

nParallel

Number of parallel processes. Parallel processing is only useful with new Yc data and extra mcmcStep.

useSocket

(logical) Use socket clusters in parallel proecessing; these are the only alternative in Windows, but in other systems this should be usually set FALSE for forking.

...

other arguments passed to functions.

Details

In mcmcStep,the number of extra mcmc steps used for updating the random effects for the Eta parameters, starting from the samples of the fitted Hmsc model in order to account for the conditional infromation provided in the Yc argument. The higher this number is, the more the obtained updated samples are unaffected by the posterior estimates of latent factors in the model fitted to the training data and more resembles the true conditional posterior. However, the elapsed time for conditional prediction grows approximately linearly as this parameter increases. The exact number for sufficient is problem-dependent and should be assessed by e.g. gradually increasing this parameter till the stationarity of the produced predictions.

Value

A list of length length(post), each element of which contains a sample from the posterior predictive distribution (given the sample of the Hmsc model parameters in the corresponding element of the post argument)

See Also

predictLatentFactor


Hmsc documentation built on Aug. 11, 2022, 5:11 p.m.