Learn R Programming

BAS (version 1.4.7)

list2matrix.bas: Coerce a BAS list object into a matrix.

Description

Models, coefficients, and standard errors in objects of class 'bas' 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

list2matrix.bas(x, what, which.models = NULL)

Arguments

x

a 'bas' object

what

name of bas list to coerce

which.models

a vector of indices use to extract a subset

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

Details

list2matrix.bas(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.

See Also

bas

Other as.matrix methods: list2matrix.which, which.matrix

Examples

Run this code
# NOT RUN {
# }
# 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.bas(crime.bic, "ols")  # extract all ols coefficients
se = list2matrix.bas(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
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab