MuGen
Multitrait genetics
Public Member Functions | Protected Attributes | List of all members
RanIndex Class Reference

Generic index class. More...

#include <MuGen.h>

Inheritance diagram for RanIndex:
[legend]
Collaboration diagram for RanIndex:
[legend]

Public Member Functions

 RanIndex ()
 Default constructor. More...
 
 RanIndex (const gsl_vector_int *lInd, const size_t &Ntot, const size_t &Nup)
 Vector-based constructor. More...
 
 RanIndex (const size_t &Ntot)
 Constructor with one upper level. More...
 
 RanIndex (const size_t &Ntot, const size_t &Nup)
 Constructor for single-element lower levels. More...
 
 RanIndex (const size_t &Ntot, const size_t &Nup, const string &fileNam)
 Constructor with file input. More...
 
 RanIndex (const size_t &Ntot, const size_t &Nup, FILE *fileStr)
 Constructor with file-stream input. More...
 
virtual ~RanIndex ()
 Destructor.
 
const vector< size_t > & operator[] (const size_t i) const
 Subscript operator. More...
 
vector< size_t > & operator[] (const size_t i)
 Subscript operator. More...
 
const vector< size_t > & getIndVec () const
 Retrieve the index vector. More...
 
vector< size_t > & getIndVec ()
 Retrieve the index vector. More...
 
const size_t & priorInd (const size_t i) const
 Upper-level index. More...
 
size_t & priorInd (const size_t i)
 Upper-level index. More...
 
size_t getNtot () const
 Number of lower-level elements. More...
 
size_t getNtot ()
 Number of lower-level elements. More...
 
size_t getNgrp () const
 Number of upper-level elements. More...
 
size_t getNgrp ()
 Number of upper-level elements. More...
 
virtual const vector< double > props () const
 Proportions of each group. More...
 
virtual void init (const vector< vector< size_t > > &idx, const vector< vector< size_t > > &rLD)
 Initialization function. More...
 
virtual void save (const Grp &y, const BetaGrpBVSR *theta, const SigmaI &SigIe)
 Variable selection save. More...
 
virtual void save (const Grp &y, const Grp &theta, const SigmaI &SigIe)
 Probability save. More...
 
virtual void dump ()
 Dump results to a file. More...
 
void update (const Grp &theta, const Grp &mu, const vector< SigmaI > &SigI, const MixP &p)
 Update mixture model with multiple covariances. More...
 
void update (const Grp &theta, const Grp &mu, const SigmaI &SigI, const MixP &p)
 Update mixture model with a single covariance. More...
 
virtual void update (const Grp &y, const SigmaI &SigIe, BetaGrpBVSR *theta, const SigmaI &SigIp)
 Variable selection update. More...
 

Protected Attributes

vector< vector< size_t > > _idx
 Indexes of lower levels. More...
 
vector< size_t > _vecInd
 Indexes of upper levels. More...
 
gsl_rng * _r
 Pointer to a PNG. More...
 

Detailed Description

Generic index class.

Establishes relationships of location parameter levels in a hierarchy. If the constructor is deterministic and there is no updating, this class is used simply to relate levels. Updating methods are provided that implement Gaussian mixture models.

Constructor & Destructor Documentation

◆ RanIndex() [1/6]

RanIndex::RanIndex ( )

Default constructor.

The PNG is initialized, _idx is set to length 0, and _vecInd has only one element set to 0.

◆ RanIndex() [2/6]

RanIndex::RanIndex ( const gsl_vector_int *  lInd,
const size_t &  Ntot,
const size_t &  Nup 
)

Vector-based constructor.

The GSL vector of integers has the indexes of the upper level (number of unique values is Nup), and is the same length as the number of rows in the lower-level location parameter matrix (Ntot).

Parameters
[in]gsl_vector_int*GSL vector of index information
[in]size_t&number of elements in the lower level
[in]size_t&number of elements in the upper level

◆ RanIndex() [3/6]

RanIndex::RanIndex ( const size_t &  Ntot)

Constructor with one upper level.

For cases where all the lower-level elemants have the same prior.

Parameters
[in]size_t&number of lower-level elements

◆ RanIndex() [4/6]

RanIndex::RanIndex ( const size_t &  Ntot,
const size_t &  Nup 
)

Constructor for single-element lower levels.

Each element of the lower level has a separate corresponding upper level (prior). Typically the two numbers passed will be the same, but the one-argument constructor is already used for setting up the single-prior index. If the number of elements in the upper level is bigger than that in the lower level, an error is issued. If the number of upper elements is smaller than the Ntot, only the first Nup elements of the lower level are used and the rest are ignored with a warning.

◆ RanIndex() [5/6]

RanIndex::RanIndex ( const size_t &  Ntot,
const size_t &  Nup,
const string &  fileNam 
)

Constructor with file input.

Reads the index information from a file. Base-0 indexing is generally assumed, but checks are attempted. Since there are cases when indexes that look non-base-0 are needed (such as when only a subset of lower-level rows are accessed), these generate warnings rather than errors, unless there are upper-level index values outside the set range.

Parameters
[in]size_t&number of lower-level elements
[in]size_t&number of upper-level elements
[in]string&file name

◆ RanIndex() [6/6]

RanIndex::RanIndex ( const size_t &  Ntot,
const size_t &  Nup,
FILE *  fileStr 
)

Constructor with file-stream input.

Reads the index information from a file. Base-0 indexing is generally assumed, but checks are attempted. Since there are cases when indexes that look non-base-0 are needed (such as when only a subset of lower-level rows are accessed), these generate warnings rather than errors, unless there are upper-level index values outside the set range.

Parameters
[in]size_t&number of lower-level elements
[in]size_t&number of upper-level elements
[in]FILE*file stream name

Member Function Documentation

◆ dump()

virtual void RanIndex::dump ( )
inlinevirtual

Dump results to a file.

Dumping the mean values for group probabilites to a file. For now, only implemented in the derived class.

Reimplemented in RanIndexVS.

◆ getIndVec() [1/2]

vector<size_t>& RanIndex::getIndVec ( )
inline

Retrieve the index vector.

Provides access to the vector of indexes into the upper level.

Returns
const vector<size_t> vector of upper-level indexes

◆ getIndVec() [2/2]

const vector<size_t>& RanIndex::getIndVec ( ) const
inline

Retrieve the index vector.

Provides access to the vector of indexes into the upper level. This is the const version.

Returns
const vector<size_t> vector of upper-level indexes

◆ getNgrp() [1/2]

size_t RanIndex::getNgrp ( )
inline

Number of upper-level elements.

Returns the number of rows in the upper-level (prior) matrix.

Returns
size_t number of upper-level elements

◆ getNgrp() [2/2]

size_t RanIndex::getNgrp ( ) const
inline

Number of upper-level elements.

Returns the number of rows in the upper-level (prior) matrix. This is the const version.

Returns
size_t number of upper-level elements

◆ getNtot() [1/2]

size_t RanIndex::getNtot ( )
inline

Number of lower-level elements.

Returns the number of rows in the lower-level location matrix.

Returns
size_t number of lower-level elements

◆ getNtot() [2/2]

size_t RanIndex::getNtot ( ) const
inline

Number of lower-level elements.

Returns the number of rows in the lower-level location matrix. This is the const version.

Returns
size_t number of lower-level elements

◆ init()

void RanIndex::init ( const vector< vector< size_t > > &  idx,
const vector< vector< size_t > > &  rLD 
)
virtual

Initialization function.

Deterministically re-initializes the index with a new vector of vectors. Used for some mixture models.

Parameters
[in]vector<vector<size_t> >& vector to replace the current _idx
[in]vector<vector<size_t> >& a relationship vector; ignored in this class

Reimplemented in RanIndexVS.

◆ operator[]() [1/2]

vector<size_t>& RanIndex::operator[] ( const size_t  i)
inline

Subscript operator.

Returns a vector of lower-level indexes for a given upper-level index.

Parameters
[in]size_tupper-level index value
Returns
vector<size_t>& vector of lower-level indexes

◆ operator[]() [2/2]

const vector<size_t>& RanIndex::operator[] ( const size_t  i) const
inline

Subscript operator.

Returns a vector of lower-level indexes for a given upper-level index. This is the const version.

Parameters
[in]size_tupper-level index value
Returns
const vector<size_t>& vector of lower-level indexes

◆ priorInd() [1/2]

size_t& RanIndex::priorInd ( const size_t  i)
inline

Upper-level index.

Returns the upper-level index that corresponds to the given lower-level index.

Parameters
[in]size_tlower-level index
Returns
const size_t upper-level index

◆ priorInd() [2/2]

const size_t& RanIndex::priorInd ( const size_t  i) const
inline

Upper-level index.

Returns the upper-level index that corresponds to the given lower-level index. This is the const version.

Parameters
[in]size_tlower-level index
Returns
const size_t upper-level index

◆ props()

const vector< double > RanIndex::props ( ) const
virtual

Proportions of each group.

Returns the fraction of the total number of lower-level elements that fall into each of the upper-level groups.

Returns
vector<double> a vector of proportions

◆ save() [1/2]

virtual void RanIndex::save ( const Grp y,
const BetaGrpBVSR theta,
const SigmaI SigIe 
)
inlinevirtual

Variable selection save.

Saves probablities of belonging to a group. For now, only implemented in the derived class.

Parameters
[in]Grp&data
[in]BetaGrpBVSR*location parameters
[in]SigmaI&inverse-covariance matrix

Reimplemented in RanIndexVS.

◆ save() [2/2]

virtual void RanIndex::save ( const Grp y,
const Grp theta,
const SigmaI SigIe 
)
inlinevirtual

Probability save.

Saves probablities of belonging to a group. For now, only implemented in the derived class.

Parameters
[in]Grp&data
[in]Grp&location parameters
[in]SigmaI&inverse-covariance matrix

Reimplemented in RanIndexVS.

Member Data Documentation

◆ _idx

vector< vector<size_t> > RanIndex::_idx
protected

Indexes of lower levels.

This vector of vectors relates a top level of a hierarchy to the corresponding lower level. The total number of elements is the number of elements in the top level. Each element is a vector of row indexes into the lower level location parameter matrix. Constituent vectors may not be of the same length (corresponding to an unbalanced design).

◆ _r

gsl_rng* RanIndex::_r
protected

Pointer to a PNG.

The PNG is initialized whether or not updating is going to be performed. We use the sum of time(NULL) and RTDSC for seeding.

◆ _vecInd

vector<size_t> RanIndex::_vecInd
protected

Indexes of upper levels.

Stores the row indexes of the upper-level location parameter matrix corresponding to each lower-level index. The length of this vector is the same as the sum of all the vectors in *_idx*, and the number of unique values is equal to the length of *_idx*.


The documentation for this class was generated from the following files: