predict.ecoNP: Out-of-Sample Posterior Prediction under the Nonparametric...

View source: R/predict.ecoNP.R

predict.ecoNPR Documentation

Out-of-Sample Posterior Prediction under the Nonparametric Bayesian Model for Ecological Inference in 2x2 Tables

Description

Obtains out-of-sample posterior predictions under the fitted nonparametric Bayesian model for ecological inference. predict method for class ecoNP and ecoNPX.

Usage

## S3 method for class 'ecoNP'
predict(
  object,
  newdraw = NULL,
  subset = NULL,
  obs = NULL,
  verbose = FALSE,
  ...
)

Arguments

object

An output object from ecoNP.

newdraw

An optional list containing two matrices (or three dimensional arrays for the nonparametric model) of MCMC draws of μ and Σ. Those elements should be named as mu and Sigma, respectively. The default is the original MCMC draws stored in object.

subset

A scalar or numerical vector specifying the row number(s) of mu and Sigma in the output object from eco. If specified, the posterior draws of parameters for those rows are used for posterior prediction. The default is NULL where all the posterior draws are used.

obs

An integer or vector of integers specifying the observation number(s) whose posterior draws will be used for predictions. The default is NULL where all the observations in the data set are selected.

verbose

logical. If TRUE, helpful messages along with a progress report on the Monte Carlo sampling from the posterior predictive distributions are printed on the screen. The default is FALSE.

...

further arguments passed to or from other methods.

Details

The posterior predictive values are computed using the Monte Carlo sample stored in the eco or ecoNP output (or other sample if newdraw is specified). Given each Monte Carlo sample of the parameters, we sample the vector-valued latent variable from the appropriate multivariate Normal distribution. Then, we apply the inverse logit transformation to obtain the predictive values of proportions, W. The computation may be slow (especially for the nonparametric model) if a large Monte Carlo sample of the model parameters is used. In either case, setting verbose = TRUE may be helpful in monitoring the progress of the code.

Value

predict.eco yields a matrix of class predict.eco containing the Monte Carlo sample from the posterior predictive distribution of inner cells of ecological tables. summary.predict.eco will summarize the output, and print.summary.predict.eco will print the summary.

See Also

eco, ecoNP, summary.eco, summary.ecoNP


eco documentation built on Nov. 4, 2022, 1:07 a.m.

Related to predict.ecoNP in eco...