MuGen
Multitrait genetics
|
Generic index class. More...
#include <MuGen.h>
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... | |
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.
RanIndex::RanIndex | ( | ) |
Default constructor.
The PNG is initialized, _idx is set to length 0, and _vecInd has only one element set to 0.
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).
[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::RanIndex | ( | const size_t & | Ntot | ) |
Constructor with one upper level.
For cases where all the lower-level elemants have the same prior.
[in] | size_t& | number of lower-level elements |
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::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.
[in] | size_t& | number of lower-level elements |
[in] | size_t& | number of upper-level elements |
[in] | string& | file name |
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.
[in] | size_t& | number of lower-level elements |
[in] | size_t& | number of upper-level elements |
[in] | FILE* | file stream name |
|
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.
|
inline |
Retrieve the index vector.
Provides access to the vector of indexes into the upper level.
|
inline |
Retrieve the index vector.
Provides access to the vector of indexes into the upper level. This is the const version.
|
inline |
Number of upper-level elements.
Returns the number of rows in the upper-level (prior) matrix.
|
inline |
Number of upper-level elements.
Returns the number of rows in the upper-level (prior) matrix. This is the const version.
|
inline |
Number of lower-level elements.
Returns the number of rows in the lower-level location matrix.
|
inline |
Number of lower-level elements.
Returns the number of rows in the lower-level location matrix. This is the const version.
|
virtual |
Initialization function.
Deterministically re-initializes the index with a new vector of vectors. Used for some mixture models.
[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.
|
inline |
Subscript operator.
Returns a vector of lower-level indexes for a given upper-level index.
[in] | size_t | upper-level index value |
|
inline |
Subscript operator.
Returns a vector of lower-level indexes for a given upper-level index. This is the const version.
[in] | size_t | upper-level index value |
|
inline |
Upper-level index.
Returns the upper-level index that corresponds to the given lower-level index.
[in] | size_t | lower-level index |
|
inline |
Upper-level index.
Returns the upper-level index that corresponds to the given lower-level index. This is the const version.
[in] | size_t | lower-level index |
|
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.
|
inlinevirtual |
Variable selection save.
Saves probablities of belonging to a group. For now, only implemented in the derived class.
[in] | Grp& | data |
[in] | BetaGrpBVSR* | location parameters |
[in] | SigmaI& | inverse-covariance matrix |
Reimplemented in RanIndexVS.
|
inlinevirtual |
Probability save.
Saves probablities of belonging to a group. For now, only implemented in the derived class.
[in] | Grp& | data |
[in] | Grp& | location parameters |
[in] | SigmaI& | inverse-covariance matrix |
Reimplemented in RanIndexVS.
|
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).
|
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.
|
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*.