Learn R Programming

BayesVarSel (version 1.7.0)

predictBvs: Bayesian Model Averaged predictions

Description

Samples of the model averaged objective predictive distribution

Usage

predictBvs(x, newdata, n.sim=10000)

Arguments

x
An object of class Bvs
newdata
A data frame in which to look for variables with which to predict
n.sim
Number of simulations to be produced

Value

returns a matrix with n.sim rows with the simulations. Each column of the matrix corresponds to each of the configurations for the covariates defined in newdata.

Details

The distribution that is sampled from is the discrete mixture of the (objective) predictive distribution with weights proportional to the posterior probabilities of each model. That is, from

$ sum_M f(y^* | data, newdata, M) Pr(M | data)$

The models used in the mixture above are the retained best models (see the argument n.keep in Bvs) if x was generated with Bvs and the sampled models with the associated frequencies if x was generated with GibbsBvs. The formula for the objective predictive distribution within each model $f(\beta | data, M)$ is taken from Bernardo and Smith (1994) page 442.

References

Bernardo, J. M. and Smith, A. F. M. (1994) Bayesian Theory. Chichester: Wiley.

See Also

See Bvs, PBvs and GibbsBvs for creating objects of the class Bvs.

Examples

Run this code
## Not run: 
# 	
# #Analysis of Crime Data
# #load data
# data(UScrime)
# 
# crime.Bvs<- Bvs(formula="y~.", data=UScrime, n.keep=1000)
# #predict a future observation associated with the first two sets of covariates
# crime.Bvs.predict<- predictBvs(crime.Bvs, newdata=UScrime[1:2,], n.sim=10000)
# #(Notice the best 1000 models are used in the mixture)
# 
# #Here you can use standard summaries to describe the underlying predictive distribution
# #summary(crime.Bvs.predict)
# #
# #To study more in deep the first set:
# #plot(density(crime.Bvs.predict[,1]))
# #Point prediction
# #median(crime.Bvs.predict[,1])
# #A credible 95
# #lower bound:
# #quantile(crime.Bvs.predict[,1], probs=0.025)
# #upper bound:
# #quantile(crime.Bvs.predict[,1], probs=0.975)
# 
# ## End(Not run)

Run the code above in your browser using DataLab