Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

list2matrix

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

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.

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@duke.edu

See Also

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

Examples

data(Hald)
hald.bic <-  bas.lm(Y ~ ., data=Hald, prior="BIC",
                    initprobs= "eplogp")
coef <- list2matrix.bas(hald.bic, "mle")  # extract all coefficients
se <- list2matrix.bas(hald.bic, "mle.se")
models <- list2matrix.which(hald.bic)     #matrix of model indicators
models <- which.matrix(hald.bic$which, hald.bic$n.vars)     #matrix of model indicators

BAS

Bayesian Variable Selection and Model Averaging using Bayesian Adaptive Sampling

v1.5.5
GPL (>= 3)
Authors
Merlise Clyde [aut, cre, cph] (ORCID=0000-0002-3595-1872), Michael Littman [ctb], Quanli Wang [ctb], Joyee Ghosh [ctb], Yingbo Li [ctb], Don van de Bergh [ctb]
Initial release
2020-1-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.