Learn R Programming

BAS (version 1.4.7)

which.matrix: Coerce a BAS list object of models into a matrix.

Description

This function coerces the list object of models to a matrix and fill in the zeros to facilitate other computations.

Usage

which.matrix(which, n.vars)

Arguments

which

a 'bas' model object x$which

n.vars

the total number of predictors, x$n.vars

Value

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

Details

which.matrix coerces x$which into a matrix.

See Also

bas

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

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") 
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