topmod-class {BMS}R Documentation

Class "topmod"


An updateable list keeping the best x models it encounters in any kind of model iteration

Objects from the Class

Objects can be created by calls to topmod, or indirectly by calls to bms.

A 'topmod' object (as created by topmod) holds three basic vectors: lik (for the (log) likelihood of models or similar), bool() for a hexcode presentation of the model binaries (cf. bin2hex) and ncount() for the times the models have been drawn.
All these vectors are sorted descendantly by lik, and are of the same length. The maximum length is limited by the argument nbmodels.

If tmo is a topmod object, then a call to tmo$addmodel (e.g. tmo$addmodel(mylik=4,vec01=c(T,F,F,T)) updates the object tmo by a model represented by vec01 (here the one including the first and fourth regressor) and the marginal (log) likelihood lik (here: 4).
If this model is already part of tmo, then its respective ncount entry is incremented by one; else it is inserted into a position according to the ranking of lik.
In addition, there is the possibility to save (the first moments of) coefficients of a model (betas) and their second moments (betas2), as well as an arbitrary vector of statistics per model (fixed_vector).



Object of class "list", elements are:


function that adjusts the list of models in the 'topmod' object (see Details). mylik is the basic selection criterion (usually log likelihood), vec01 is the model binary (logical or numeric) indicating which regressors are included - cf. topmod


the function lik() returns a numeric vector of the best models (log) likelihoods, in decreasing order


the function bool() returns a character vector of hexmode expressions for the model binaries (cf. bin2hex), sorted by lik()


the function ncount() returns a numeric vector of MCMC frequencies for the best models (i.e. how often the respective model was introduced by addmodel)


the function nbmodels() returns the argument nbmodel to function topmod


the function nregs() returns the argument nmaxregressors to bms


the function betas_raw() returns a vector containing the coefficients in betas (see below) without the zero entries


the function betas2_raw() returns a vector containing the coefficient second moments in betas2 (see below) without the zero entries


the function kvec_raw() returns a vector with model sizes (integers) for the models denoted in bool


the function bool_binary() returns a matrix whose columns present the models conforming to lik() in binary form


the function betas() returns a matrix whose columns are the cofficents conforming to bool_binary() (Note that these include zero coefficents due to non-inclusion of covariates); Note: may be an empty matrix


the function betas2() returns a matrix similar to betas(), but with the coeffficents second moments (Note: can be empty)


the function fixed_vector() returns a matrix whose columns bear the fixed_vector statistics conforming to lik() (see Details); Note: if lengthfixedvec=0 in topmod this returns an empty matrix




Martin Feldkircher and Stefan Zeugner


See Also

topmod to create topmod objects and a more detailed description,
[.topmod for subselections, is.topmod to test for this class


  tm= topmod(2,4,TRUE,0) #should keep a  maximum two models
  tm$addmodel(-2.3,c(1,1,1,1),1:4,5:8) #update with some model
  tm$addmodel(-2.2,c(0,1,1,1),1:3,5:7) #add another model
  tm$addmodel(-2.2,c(0,1,1,1),1:3,5:7) #add it again -> adjust ncount
  tm$addmodel(-2.5,c(1,0,0,1),1:2,5:6) #add another model
  #read out

[Package BMS version 0.3.4 Index]