predict.regional_mix: Predicts RCP probabilities at a series of sites. Confidence...

predict.regional_mixR Documentation

Predicts RCP probabilities at a series of sites. Confidence intervals are available too.

Description

Predicts RCP probabilities at a series of sites. Confidence intervals are available too.

Usage

## S3 method for class 'regional_mix'
predict(
  object,
  object2 = NULL,
  ...,
  newdata = NULL,
  nboot = 0,
  alpha = 0.95,
  mc.cores = 1
)

Arguments

object

an object obtained from fitting a RCP mixture model. Such as that generated from a call to regional_mix(qv).

object2

a regional_mix object obtained from bootstrapping the regional_mix object. Such as that generated from a call to regional_mix.bootstrap(qv). If not supplied, then predict.regional_mix will do parametric bootstrapping (otherwise non-parametric bootstrap).

newdata

a data.frame (or something that can be coerced) containing the values of the covariates where predictions are to be made. If NULL (the default) then predictions are made at the locations of the original data.

nboot

the number of parametric bootstrap samples to take for the bootstrap predictions, standard errors and confidence intervals. The default is 0, that is no bootstrapping is to be done and point predictions only are given. If object2 is not NULL, then the number of bootstrap samples is taken from that object (this argument is then ignored).

alpha

a numeric within [0,1] (well [0.5,1] really) indicating the specified confidence for the confidence interval. Argument is redundant if nboot == 0.

mc.cores

the number of cores to spread the computations over. Ignored if running on a Windows machine.

\dots

additional predict calls ignorned

Details

This function implements two separate, and quite different, bootstrapping routines. The first, attributable to Foster et al (2013), which implements a parametric bootstrap, whereby parameters are drawn from their sampling distribution (defined by the ML estimates and their asymptotic vcov matrix). Yes, the vcov function needs to be run first and stored in the the regional_mix object as $vcov. Typically, the vcov matrix is obtained using numerical derivatives, which can be slow to calculate and somewhat unstable/erratic. This was the original suggestion and has been superceeded by the non-parametric bootstrap routine. This is described in Foster et al (in prep) and bootstraps the sampling site data repeatedly, and for each bootstrap sample the model is re-estimated. Variation in the bootstrap samples is carried forward to the prediction step to guage the uncertainty. The parametric bootsrap implementation of this function can take a while to run ??? it is a bootstrap function. nboot samples of the parameters are taken and then used to predict at each set of covariates defined in newdata. Quantiles of the resulting sets of bootstrap predictions are then taken. It is the last step that really takes a while. The non-parametric version of this function should not take as long as the grunt work of bootstrapping is carried out in the regional_mix.bootstrap(qv) function. Note that this function is not implemented. It could be, using the parallel package, but it is currently not. The bulk of the bootstrap calculations are done in C++, which reduces the waiting time but parallelising it would be even better.

Value

If nboot==0 then a n x H matrix of prior predictions (n=nrow(newdata), H=number of RCPs). Each row should sum to one.

if nboot!=0 then a list is returned. It has elements:
ptPreds

the n x H matrix of point predictions

bootPreds

the n x H matrix of bootstrap point predictions (mean of bootstrap samples)

bootSEs

the n x H matrix of bootstrap standard errors for predictions

bootCIs

the n x H x 2 array of bootstrap confidence intervals. Note that bootCIs[,,1] gives the lower CIs and bootCIs[,,2] gives the upper CIs.


skiptoniam/ecomix documentation built on Sept. 14, 2023, 6:04 a.m.