Learn R Programming

BMS (version 0.3.4)

topmod-class: Class "topmod"

Description

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

Arguments

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

Slots

.S3Class:
Object of class "list", elements are:
addmodel:
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
lik:
the function lik() returns a numeric vector of the best models (log) likelihoods, in decreasing order
bool:
the function bool() returns a character vector of hexmode expressions for the model binaries (cf. bin2hex), sorted by lik()
ncount:
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)
nbmodels:
the function nbmodels() returns the argument nbmodel to function topmod
nregs:
the function nregs() returns the argument nmaxregressors to bms
betas_raw:
the function betas_raw() returns a vector containing the coefficients in betas (see below) without the zero entries
betas2_raw:
the function betas2_raw() returns a vector containing the coefficient second moments in betas2 (see below) without the zero entries
kvec_raw:
the function kvec_raw() returns a vector with model sizes (integers) for the models denoted in bool
bool_binary:
the function bool_binary() returns a matrix whose columns present the models conforming to lik() in binary form
betas:
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
betas2:
the function betas2() returns a matrix similar to betas(), but with the coeffficents second moments (Note: can be empty)
fixed_vector:
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

References

http://bms.zeugner.eu

See Also

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

Examples

Run this code
  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
  tm$lik()
  tm$ncount()
  tm$bool_binary()
  tm$betas()

Run the code above in your browser using DataLab