| BmaSamples | R Documentation | 
Draw samples from the Bayesian model average over the models in
saved in a BayesMfp-object. 
BmaSamples(object, sampleSize = length(object) * 10, postProbs =
posteriors(object), gridList = list(), gridSize = 203, newdata=NULL,
verbose = TRUE, includeZeroSamples=FALSE)  
| object | valid  | 
| sampleSize | sample size (default is 10 times the number of models) | 
| postProbs | vector of posterior probabilites (will be normalized within the function, defaults to the normalized posterior probabilities) | 
| gridList | optional list of appropriately named grid vectors for FP evaluation,
default is a length ( | 
| gridSize | see above (default: 203) | 
| newdata | new covariate data.frame with exactly the names (and preferably ranges) as before (default: no new covariate data) | 
| verbose | should information on sampling progress be printed? (default) | 
| includeZeroSamples | should the function and coefficient samples
include zero samples, from models where these covariates are not
included at all? (default:  | 
Return an object of class BmaSamples, which is a list with
various elements that describe the BayesMfp object over which
was averaged, model frequencies in the samples, the samples themselves
etc:
| priorSpecs | the utilized prior specifications | 
| termNames | a list of character vectors containing the names of uncertain covariate groups, fractional polynomial terms and fixed variables | 
| shiftScaleMax | matrix with 4 columns containing preliminary transformation parameters, maximum degrees and cardinalities of the powersets of the fractional polynomial terms | 
| y | the response vector | 
| x | the shifted and scaled design matrix for the data | 
| randomSeed | if a seed existed at function call
( | 
| modelFreqs | The table of model frequencies in the BMA sample | 
| modelData | data frame containing the normalized posterior
probabilities of the models in the underlying  | 
| sampleSize | sample size | 
| sigma2 | BMA samples of the regression variance | 
| shrinkage | BMA samples of the shrinkage factor | 
| fixed | samples of the intercept | 
| bfp | named list of the FP function samples, where each element contains one FP covariate and is a matrix (samples x grid), with the following attributes: 
 | 
| uc | named list of the uncertain fixed form covariates, where each
element contains the coefficient samples of one group: in a matrix
with the attribute  | 
| fitted | fitted values of all models in  | 
| predictions | samples from the predictive distribution at the
covariates given in  | 
| predictMeans | means of the predictive distribution at the
covariates given in  | 
BmaSamples Methods, BayesMfp
## construct a BayesMfp object
set.seed(19)
x1 <- rnorm (n=15)
x2 <- rbinom (n=15, size=20, prob=0.5) 
x3 <- rexp (n=15)
y <- rt (n=15, df=2)
test <- BayesMfp (y ~ bfp (x2, max = 4) + uc (x1 + x3), nModels = 200, method="exhaustive")
## now draw samples from the Bayesian model average
testBma <- BmaSamples (test)
testBma
## We can also draw predictive samples for new data points, but then
## we need to supply the new data to BmaSamples:
newdata <- data.frame(x1 = rnorm(15),
                      x2 = rbinom(n=15, size=5, prob=0.2) + 1,
                      x3 = rexp(n=15))
testBma <- BmaSamples(test, newdata=newdata)
predict(testBma)
## test that inclusion of zero samples works
testBma <- BmaSamples (test, includeZeroSamples=TRUE)
testBma
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.