list2matrix.bma {BAS}R Documentation

Coerce a BMA list object into a matrix

Description

Models, coefficients, and standard errors in objects of class 'bma' are represented as a list of lists to reduce storage by omitting the zero entries. These functions coerce the list object to a matrix and fill in the zeros to facilitate other computations.

Usage

## S3 method for class 'bma':
list2matrix(x, what,  which.models=NULL)

## S3 method for class 'which':
list2matrix(x, which.models=NULL)

which.matrix(which, n.vars)

Arguments

x a 'bma' object
what name of bma list to coerce
which.models a vector of indices use to extract a subset
which x$which a list of lists of model indicators
n.vars the total number of predictors, x$n.vars

Details

list2matrix.bma(x, which) is equivalent to list2matrix.which(x), however, the latter uses sapply rather than a loop. list2matrix.which and which.matrix both coerce x$which into a matrix.

Value

a matrix representation of x$what, with number of rows equal to the length of which.models or total number of models and number of columns x$n.vars

Author(s)

Merlise Clyde clyde@stat.duke.edu

See Also

bas

Examples

## Not run: 
library(MASS)
data(UScrime)
UScrime[,-2] = log(UScrime[,-2])
crime.bic =  bas.lm(y ~ ., data=UScrime, n.models=2^15, prior="BIC",
                    initprobs= "eplogp") 
coef = list2matrix.bma(crime.bic, "ols")  # extract all ols coefficients
se = list2matrix.bma(crime.bic, "ols.se")
models = list2matrix.which(crime.bic)     #matrix of model indicators
models = which.matrix(crime.bic$which, crime.bic$n.vars)     #matrix of model indicators
## End(Not run)

[Package BAS version 0.1 Index]