MuGen
Multitrait genetics
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Grp Class Referenceabstract

Base location parameter group class. More...

#include <MuGen.h>

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

Public Member Functions

virtual ~Grp ()
 Destructor.
 
virtual void update (const Grp &, const SigmaI &)=0
 Gaussian likelihood, improper prior. More...
 
virtual void update (const Grp &, const Qgrp &, const SigmaI &)=0
 Student- \(t\) likelihood, improper prior. More...
 
virtual void update (const Grp &, const SigmaI &, const SigmaI &)=0
 Gaussian likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &, const Qgrp &, const SigmaI &, const SigmaI &)=0
 Student- \(t\) likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &, const SigmaI &, const Qgrp &, const SigmaI &)=0
 Gaussian likelihood, 0-mean Student- \(t\) prior. More...
 
virtual void update (const Grp &, const Qgrp &, const SigmaI &, const Qgrp &, const SigmaI &)=0
 Student- \(t\) likelihood, 0-mean Student- \(t\) prior. More...
 
virtual void update (const Grp &, const SigmaI &, const Grp &, const SigmaI &)=0
 Gaussian likelihood, non-zero mean Gaussian prior. More...
 
virtual void update (const Grp &, const Qgrp &, const SigmaI &, const Grp &, const SigmaI &)=0
 Student- \(t\) likelihood, non-zero mean Gaussian prior. More...
 
virtual void update (const Grp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &)=0
 Gaussian likelihood, non-zero mean Student- \(t\) prior. More...
 
virtual void update (const Grp &, const Qgrp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &)=0
 Student- \(t\) likelihood, non-zero mean Student- \(t\) prior. More...
 
virtual void save ()
 Save to pre-specified file. More...
 
virtual void save (const string &outFlNam)
 Save to file. More...
 
virtual void save (const string &outMuFlNam, const string &outSigFlNam, const SigmaI &SigI)
 Joint save. More...
 
virtual void save (const SigmaI &SigI)
 Save with inverse-covariance. More...
 
virtual void save (const Grp &y, const SigmaI &SigI)
 Save with data and inverse-covariance. More...
 
void mhlSave (const string &outFlNam, const SigmaI SigI)
 Save Mahalanobis distance. More...
 
virtual void dump ()
 Dump to a file. More...
 
const vector< MVnorm * > & dataVec () const
 Get vector of row pointers. More...
 
virtual const gsl_matrix * dMat () const
 Access the value matrix. More...
 
virtual const gsl_matrix * fMat () const
 Access the value matrix. More...
 
const size_t Ndata () const
 Get number of rows. More...
 
const size_t phenD () const
 Get number of traits. More...
 
virtual double lnOddsRat (const Grp &y, const SigmaI &SigI, const size_t i) const
 Log-odds ratio. More...
 
const MVnormoperator[] (const size_t i) const
 Subscript operator. More...
 
MVnormoperator[] (const size_t i)
 Subscript operator. More...
 
virtual MuGrp mean (RanIndex &grp)
 Group mean. More...
 
virtual const MuGrp mean (RanIndex &grp) const
 Group mean. More...
 
virtual MuGrp mean (RanIndex &grp, const Qgrp &q)
 Group weighted mean. More...
 
virtual const MuGrp mean (RanIndex &grp, const Qgrp &q) const
 Group weighted mean. More...
 
void center ()
 Center the value matrix. More...
 

Protected Member Functions

 Grp ()
 

Protected Attributes

vector< MVnorm * > _theta
 Vector of pointers to value rows. More...
 
gsl_matrix * _valueMat
 Value matrix. More...
 
RanIndex_lowLevel
 Lower level index. More...
 
RanIndex_upLevel
 Upper level index. More...
 
vector< gsl_rng * > _rV
 Vector of PNG pointers. More...
 
string _outFlNam
 Name of the output file.
 

Friends

class MuGrp
 
MuGrp operator+ (const Grp &m1, const Grp &m2)
 Addition operator. More...
 
MuGrp operator+ (const MuGrp &m1, const Grp &m2)
 Addition operator. More...
 
MuGrp operator+ (const Grp &m1, const MuGrp &m2)
 Addition operator. More...
 
MuGrp operator- (const Grp &m1, const Grp &m2)
 Subtraction operator. More...
 
MuGrp operator- (const MuGrp &m1, const Grp &m2)
 Subtraction operator. More...
 
MuGrp operator- (const Grp &m1, const MuGrp &m2)
 Subtraction operator. More...
 

Detailed Description

Base location parameter group class.

The abstract base location parameter group class. Cannot be initialized directly.

Constructor & Destructor Documentation

◆ Grp()

Grp::Grp ( )
protected

Default constructor

Member Function Documentation

◆ center()

void Grp::center ( )
inline

Center the value matrix.

Centering is performed by subtracting the mean for each column from each column in place.

◆ dataVec()

const vector<MVnorm *>& Grp::dataVec ( ) const
inline

Get vector of row pointers.

Returns
vector<MVnorm *> vector of objects addressing rows of the value matrix

◆ dMat()

virtual const gsl_matrix* Grp::dMat ( ) const
inlinevirtual

Access the value matrix.

Gives access to the value matrix. The internal structure this points to depends on the derived class.

Returns
gsl_matrix* pointer to a GSL matrix

◆ dump()

virtual void Grp::dump ( )
inlinevirtual

Dump to a file.

Dumps paramter values averaged over the MCMC run to a file in the end of the run. Has an effect only in derived classes where it is implemented. In these classes, the name of the file is pre-specified at initialization.

Reimplemented in BetaGrpPSRmiss, BetaGrpSnpMissCV, BetaGrpSnpMiss, BetaGrpPSR, BetaGrpSnpCV, BetaGrpSnp, and BetaGrpFt.

◆ fMat()

virtual const gsl_matrix* Grp::fMat ( ) const
inlinevirtual

Access the value matrix.

Gives access to the value matrix. The internal structure this points to depends on the derived class, and may be different from dMat().

Returns
gsl_matrix* pointer to a GSL matrix

Reimplemented in MuBlk, BetaGrpSnpMiss, BetaGrpSnp, BetaGrpPCpex, BetaGrpPEX, BetaGrpFt, and MuGrpPEX.

◆ lnOddsRat()

virtual double Grp::lnOddsRat ( const Grp y,
const SigmaI SigI,
const size_t  i 
) const
inlinevirtual

Log-odds ratio.

Log-odds ration between models with and without the i-th regression coefficient (row). Makes sense only in regression classes, everywhere else returns zero.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]size_tindex of the element (row)
Returns
double log-odds ratio

Reimplemented in BetaGrpFt.

◆ mean() [1/4]

MuGrp Grp::mean ( RanIndex grp)
virtual

Group mean.

Calculates within-group mean values of the value matrix (by row). The groups are defined by the upper-level of the given RanIndex variable. The lower-level number of elements of the index has to be the same as the number of rows in the current object's value matrix.

Parameters
[in]RanIndex&grouping index
Returns
MuGrp object with the matrix of means

Reimplemented in MuGrpPEX.

◆ mean() [2/4]

const MuGrp Grp::mean ( RanIndex grp) const
virtual

Group mean.

Calculates within-group mean values of the value matrix (by row). The groups are defined by the upper-level of the given RanIndex variable. The lower-level number of elements of the index has to be the same as the number of rows in the current object's value matrix.

Parameters
[in]RanIndex&grouping index
Returns
MuGrp object with the matrix of means

Reimplemented in MuGrpPEX.

◆ mean() [3/4]

MuGrp Grp::mean ( RanIndex grp,
const Qgrp q 
)
virtual

Group weighted mean.

Calculates within-group weighted mean values of the value matrix (by row). The groups are defined by the upper-level of the given RanIndex variable. The lower-level number of elements of the index has to be the same as the number of rows in the current object's value matrix. The weights are in the provided Qgrp object. Typically, they are from a Student- \(t\) model.

Parameters
[in]RanIndex&grouping index
[in]Qgrp&weights
Returns
MuGrp object with the matrix of means

Reimplemented in MuGrpPEX.

◆ mean() [4/4]

const MuGrp Grp::mean ( RanIndex grp,
const Qgrp q 
) const
virtual

Group weighted mean.

Calculates within-group weighted mean values of the value matrix (by row). The groups are defined by the upper-level of the given RanIndex variable. The lower-level number of elements of the index has to be the same as the number of rows in the current object's value matrix. The weights are in the provided Qgrp object. Typically, they are from a Student- \(t\) model.

Parameters
[in]RanIndex&grouping index
[in]Qgrp&weights
Returns
MuGrp object with the matrix of means

Reimplemented in MuGrpPEX.

◆ mhlSave()

void Grp::mhlSave ( const string &  outFlNam,
const SigmaI  SigI 
)

Save Mahalanobis distance.

Saves Mahalanobis distances of each row to a vector of zeros, given the provided inverse-covariance.

Parameters
[in]string&file name
[in]SigmaI&inverse-covariance

◆ Ndata()

const size_t Grp::Ndata ( ) const
inline

Get number of rows.

Returns
size_t number of rows in the value matrix, corresponds to the number of mean values or regression coefficients

◆ operator[]() [1/2]

MVnorm* Grp::operator[] ( const size_t  i)
inline

Subscript operator.

Get a MVnorm object pointer to a row of the value matrix.

Parameters
[in]size_trow index
Returns
MVnorm* pointer to an element in the value matrix

◆ operator[]() [2/2]

const MVnorm* Grp::operator[] ( const size_t  i) const
inline

Subscript operator.

Get a MVnorm object pointer to a row of the value matrix.

Parameters
[in]size_trow index
Returns
MVnorm* pointer to an element in the value matrix

◆ phenD()

const size_t Grp::phenD ( ) const
inline

Get number of traits.

Returns
size_t number of columns in the value matrix, corresponds to the number of traits

◆ save() [1/5]

void Grp::save ( )
virtual

Save to pre-specified file.

Saves a sample from the Markov chain for the object by appending to a file. Unless re-implemented, the current contents of _valueMat are saved. File name is either generic or pre-specified at construction.

Reimplemented in BetaGrpPCpex, BetaGrpPEX, and MuGrpPEX.

◆ save() [2/5]

virtual void Grp::save ( const Grp y,
const SigmaI SigI 
)
inlinevirtual

Save with data and inverse-covariance.

Reserved for saving to a variable rather than a file. Has an effect only in classes where it is re-implemented.

Parameters
[in]Grp&data
[in]SigmaI&inverse-covariance

◆ save() [3/5]

virtual void Grp::save ( const SigmaI SigI)
inlinevirtual

Save with inverse-covariance.

Reserved for saving to a variable rather than a file. Has an effect only in classes where it is re-implemented.

Parameters
[in]SigmaI&inverse-covariance

Reimplemented in BetaGrpBVSR, BetaGrpPCpex, BetaGrpPEX, BetaGrpFt, and MuGrpPEX.

◆ save() [4/5]

void Grp::save ( const string &  outFlNam)
virtual

Save to file.

Saves a sample from the Markov chain for the object by appending to the named file. Unless re-implemented, the current contents of _valueMat are saved.

Parameters
[in]string&file name

Reimplemented in BetaGrpPCpex, BetaGrpPEX, and MuGrpPEX.

◆ save() [5/5]

void Grp::save ( const string &  outMuFlNam,
const string &  outSigFlNam,
const SigmaI SigI 
)
virtual

Joint save.

Saves the current value of _valueMat to one file and the covariance matrix corresponding to the given inverse-covariance to the other. Both files are appended. Has more practical importance in some derived classes.

Parameters
[in]string&mean file name
[in]string&covariance file name
[in]SigmaI&inverse-covariance

Friends And Related Function Documentation

◆ operator+ [1/3]

MuGrp operator+ ( const Grp m1,
const Grp m2 
)
friend

Addition operator.

Parameters
[in]Grp&first summand
[in]Grp&second summand
Returns
MuGrp object that is the sum of the two input objects

◆ operator+ [2/3]

MuGrp operator+ ( const Grp m1,
const MuGrp m2 
)
friend

Addition operator.

Parameters
[in]Grp&first summand
[in]MuGrp&second summand
Returns
MuGrp object that is the sum of the two input objects

◆ operator+ [3/3]

MuGrp operator+ ( const MuGrp m1,
const Grp m2 
)
friend

Addition operator.

Parameters
[in]MuGrp&first summand
[in]Grp&second summand
Returns
MuGrp object that is the sum of the two input objects

◆ operator- [1/3]

MuGrp operator- ( const Grp m1,
const Grp m2 
)
friend

Subtraction operator.

Parameters
[in]Grp&minuend
[in]Grp&subtrahend
Returns
MuGrp object that is the difference between the two input objects

◆ operator- [2/3]

MuGrp operator- ( const Grp m1,
const MuGrp m2 
)
friend

Subtraction operator.

Parameters
[in]Grp&minuend
[in]MuGrp&subtrahend
Returns
MuGrp object that is the difference between the two input objects

◆ operator- [3/3]

MuGrp operator- ( const MuGrp m1,
const Grp m2 
)
friend

Subtraction operator.

Parameters
[in]MuGrp&minuend
[in]Grp&subtrahend
Returns
MuGrp object that is the difference between the two input objects

Member Data Documentation

◆ _lowLevel

RanIndex* Grp::_lowLevel
protected

Lower level index.

If initialized, points to the lower (i.e., data) level in the hierarchy. Otherwise, set to 0. For regressions, plays the role of the design matrix \( \boldsymbol{Z} \).

◆ _rV

vector<gsl_rng *> Grp::_rV
protected

Vector of PNG pointers.

Typically is of unit length. However, for derived classes that use multi-threading its length is equal to the number of threads, each thread having its own PNG. PNGS are seeded on construction with the sum of time(NULL) and RTDSC.

◆ _theta

vector<MVnorm *> Grp::_theta
protected

Vector of pointers to value rows.

Each individual MVnorm pointer corresponds to a row in _valueMat, which can be modified by invoking update functions that MVnorm class members.

◆ _upLevel

RanIndex* Grp::_upLevel
protected

Upper level index.

If initialized, points to the upper (i.e., prior) level in the hierarchy. Otherwise, set to 0.

◆ _valueMat

gsl_matrix* Grp::_valueMat
protected

Value matrix.

Matrix of location parameter values. The columns are traits, and rows are individual replicates or regression coefficients corresponding to a given predictor. Each row is addressed by an individual element of _theta for most classes. Exceptions are noted in descriptions of those derived classes.


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