predict.Bvs {BayesVarSel} | R Documentation |
Samples of the model averaged objective predictive distribution
## S3 method for class 'Bvs' predict(object, newdata, n.sim = 10000, ...)
object |
An object of class |
newdata |
A data frame in which to look for variables with which to predict |
n.sim |
Number of simulations to be produced |
... |
Further arguments to be passed (currently none implemented). |
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(β | data, M) is
taken from Bernardo and Smith (1994) page 442.
predict
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
.
Gonzalo Garcia-Donato and Anabel Forte
Maintainer: <anabel.forte@uv.es>
Bernardo, J. M. and Smith, A. F. M. (1994)<DOI:10.1002/9780470316870> Bayesian Theory. Chichester: Wiley.
See Bvs
and GibbsBvs
for creating objects of the class
Bvs
.
## 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<- predict(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% interval for the prediction: #lower bound: quantile(crime.Bvs.predict[,1], probs=0.025) #upper bound: quantile(crime.Bvs.predict[,1], probs=0.975) ## End(Not run)