Learn R Programming

bayesLife (version 5.3-1)

get.e0.prediction: Accessing a Prediction Object

Description

Function get.e0.prediction retrieves results of a prediction and creates an object of class bayesLife.prediction. Function has.e0.prediction checks an existence of such results. Analogously, functions get.e0.jmale.prediction and has.e0.jmale.prediction retrieve and check an existence of male predictions from a given female prediction object. Function available.e0.predictions lists predictions available in the given simulation directory.

Usage

get.e0.prediction(mcmc = NULL, sim.dir = NULL, joint.male = FALSE, 
    mcmc.dir = NULL, subdir = "predictions")

has.e0.prediction(mcmc = NULL, sim.dir = NULL, subdir = "predictions")

get.e0.jmale.prediction(e0.pred)

has.e0.jmale.prediction(e0.pred)

available.e0.predictions(mcmc = NULL, sim.dir = NULL, full.names = FALSE)

Value

Functions has.e0.prediction and has.e0.jmale.prediction return a logical indicating if a prediction exists.

Functions get.e0.prediction and get.e0.jmale.prediction return an object of class bayesLife.prediction.

Function available.e0.predictions returns a vector of directory names containing e0 predictions.

Arguments

mcmc

Object of class bayesLife.mcmc.set used to make the prediction. If it is NULL, the prediction is loaded from directory given by sim.dir.

sim.dir

Directory where the prediction is stored. It should correspond to the value of the output.dir argument used in the e0.predict function. Only relevant if mcmc is NULL.

joint.male

Logical. If TRUE, the function is applied to a male prediction that was generated using the joint female-male model implemented in the function e0.jmale.predict.

mcmc.dir

Optional argument to be used only in a special case when the mcmc object contained in the prediction object was estimated in different directory than in the one to which it points to (for example due to moving or renaming the original directory). The argument causes that the mcmc is redirected to the given directory.

subdir

Subdirectory of sim.dir for this particular prediction.

full.names

Logical. If TRUE, the directory names are given as full paths, otherwise (default) only the base names.

e0.pred

Object of class bayesLife.prediction.

Author

Hana Sevcikova

Details

If mcmc is not NULL, the search directory is set to mcmc$meta$output.dir. This approach assumes that the prediction was stored in the same directory as the MCMC simulation, i.e. the output.dir argument of the e0.predict function was set to NULL. If it is not the case, the argument mcmc.dir should be used.

Usually, all predictions are stored in the subdirectory “predictions” of the simulation directory. If the subdirectory has a different name, the argument subdir should be used. This allows to keep multiple predictions in one (MCMC) simulation directory. The function available.e0.predictions can be used to view all available predictions in the simulation directory.

Function get.e0.jmale.prediction extracts male projections from the e0.pred objects (which should be a female prediction object), if the male prediction was generated using the e0.jmale.predict function. has.e0.jmale.prediction checks if such male prediction was generated.

See Also

bayesLife.prediction, e0.predict, summary.bayesLife.prediction, e0.jmale.predict

Examples

Run this code
sim.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
pred <- get.e0.prediction(sim.dir = sim.dir)
# female prediction summary
summary(pred, country = "Canada")

if (FALSE) {
# male prediction summary
# (works only if a joint male prediction exists - not the case in this toy example)
summary(get.e0.jmale.prediction(pred), country = "Canada")}

Run the code above in your browser using DataLab