# as.matrix: Coerce a BAS list object into a matrix In BAS: Bayesian Model Averaging using Bayesian Adaptive Sampling

### 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

 ```1 2 3 4 5 6 7``` ```## S3 method for class 'bas' list2matrix(x, what, which.models=NULL) ## S3 method for class 'which' list2matrix(x, which.models=NULL) which.matrix(which, n.vars) ```

### Arguments

 `x` a 'bas' object `what` name of bas 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.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@stat.duke.edu

`bas`

### Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```## 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 ## End(Not run) ```

BAS documentation built on May 19, 2017, 9:36 p.m.

Search within the BAS package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.