MuGen
Multitrait genetics
Public Member Functions | Friends | List of all members
MuGrp Class Reference

Hierarchical mean. More...

#include <MuGen.h>

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

Public Member Functions

 MuGrp ()
 Default constructor.
 
 MuGrp (RanIndex &low, const size_t &d)
 Deterministic zero-value constructor. More...
 
 MuGrp (const string &datFlNam, RanIndex &low, RanIndex &up, const size_t &d)
 Constructor with data from file. More...
 
 MuGrp (const string &datFlNam, RanIndex &up, const size_t &d)
 Constructor with data from file and no lower level. More...
 
 MuGrp (const vector< MVnorm * > &dat, RanIndex &low, RanIndex &up)
 Constructor with a vector of MVnorm pointers. More...
 
 MuGrp (const Grp &dat, RanIndex &low, RanIndex &up)
 Constructor with a Grp object. More...
 
 MuGrp (const vector< MVnorm * > &dat, RanIndex &low, RanIndex &up, const string &outFlNam)
 Constructor with a vector of MVnorm pointers and output file name. More...
 
 MuGrp (const Grp &dat, RanIndex &low, RanIndex &up, const string &outFlNam)
 Constructor with a Grp object and output file name. More...
 
 MuGrp (const Grp &dat, RanIndex &low)
 Deterministic mean constructor. More...
 
 MuGrp (const Grp &dat, const Qgrp &q, RanIndex &low)
 Deterministic weighted mean constructor. More...
 
 MuGrp (const gsl_matrix *dat)
 Deterministic constructor with a GSL matrix. More...
 
 MuGrp (const gsl_matrix *dat, RanIndex &low)
 Deterministic GSL matrix mean constructor. More...
 
 MuGrp (const gsl_matrix *dat, const Qgrp &q, RanIndex &low)
 Deterministic GSL matrix weighted mean constructor. More...
 
virtual ~MuGrp ()
 Destructor.
 
 MuGrp (const MuGrp &mG)
 Copy constructor. More...
 
 MuGrp (const Grp &g)
 Copy constructor. More...
 
MuGrpoperator= (const MuGrp &mG)
 Assignemnt operator. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm)
 Gaussian likelihood, improper prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm)
 Student- \(t\) likelihood, improper prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp)
 Student- \(t\) likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
 Student- \(t\) likelihood, 0-mean Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
 Gaussian likelihood, non-zero mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
 Student- \(t\) likelihood, non-zero mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp)
 Gaussian likelihood, non-zero mean Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp)
 Student- \(t\) likelihood, non-zero mean Student- \(t\) prior. More...
 
- Public Member Functions inherited from Grp
virtual ~Grp ()
 Destructor.
 
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...
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from Grp
 Grp ()
 
- Protected Attributes inherited from Grp
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.
 

Detailed Description

Hierarchical mean.

Standard hierarchical mean parameter of Bayesian hierarchical models [gelman04] [gelman07] . Can also be used to store raw data (i.e., the lowest level in the hierarchy or the repsonse in a mixed model; in which case it is not updated), and to implement a Bayesian analog of a frequentist random effect (in which case the prior is zero).

Constructor & Destructor Documentation

◆ MuGrp() [1/14]

MuGrp::MuGrp ( RanIndex low,
const size_t &  d 
)

Deterministic zero-value constructor.

Sets all elements of the value matrix to zero. Can be used to construct a 0-mean prior. No upper level is set and thus this is not typically updated.

Parameters
[in]RanIndex&index to the lower level
[in]size_t&number of traits

◆ MuGrp() [2/14]

MuGrp::MuGrp ( const string &  datFlNam,
RanIndex low,
RanIndex up,
const size_t &  d 
)

Constructor with data from file.

Reading in data from a file. The resulting value matrix has the number of rows equal to the number of groups in the low index and the number of elements in the upper index.
Index consistency is required, otherwise an error is issued and the program aborted. The constructor is deterministic.

Parameters
[in]string&data file name
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level
[in]size_t&number of traits

◆ MuGrp() [3/14]

MuGrp::MuGrp ( const string &  datFlNam,
RanIndex up,
const size_t &  d 
)

Constructor with data from file and no lower level.

Reading in data from a file. The resulting value matrix has the number of rows equal to the number of elements in the upper index. This constructor is deterministic and can be used to set up the lowest (i.e. data) level of the hierarchy, and not update it.

Parameters
[in]string&data file name
[in]RanIndex&index to the upper (prior) level
[in]size_t&number of traits

◆ MuGrp() [4/14]

MuGrp::MuGrp ( const vector< MVnorm * > &  dat,
RanIndex low,
RanIndex up 
)

Constructor with a vector of MVnorm pointers.

Initializes a value matrix with means among the elements of the vector of MVnorm pointers, according to the low index (i.e., the given vector contains the data). Values for the matrix are sampled around the mean values. The number returned by low.getNgrp() has to be equal to the number returned by up.getNtot(), and is equal to the number of rows in the value matrix. Violation of any of these conditions results in an error.

Parameters
[in]vector<MVnorm*>& vector of pointers to rows of the value matrix
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level

◆ MuGrp() [5/14]

MuGrp::MuGrp ( const Grp dat,
RanIndex low,
RanIndex up 
)

Constructor with a Grp object.

Initializes a value matrix with means among the rows of the matrix in Grp addressed by the dMat() member, according to the low index (i.e., the Grp object contains the data). Values for the matrix are sampled around the mean values. The number returned by low.getNgrp() has to be equal to the number returned by up.getNtot(), and is equal to the number of rows in the value matrix. Violation of any of these conditions results in an error.

Parameters
[in]Grp&vector of pointers to rows of the value matrix
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level

◆ MuGrp() [6/14]

MuGrp::MuGrp ( const vector< MVnorm * > &  dat,
RanIndex low,
RanIndex up,
const string &  outFlNam 
)

Constructor with a vector of MVnorm pointers and output file name.

Initializes a value matrix with means among the elements of the vector of MVnorm pointers, according to the low index (i.e., the given vector contains the data). Values for the matrix are sampled around the mean values. The number returned by low.getNgrp() has to be equal to the number returned by up.getNtot(), and is equal to the number of rows in the value matrix. Violation of any of these conditions results in an error.

Parameters
[in]vector<MVnorm*>& vector of pointers to rows of the value matrix
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level
[in]string&name of the output file

◆ MuGrp() [7/14]

MuGrp::MuGrp ( const Grp dat,
RanIndex low,
RanIndex up,
const string &  outFlNam 
)

Constructor with a Grp object and output file name.

Initializes a value matrix with means among the rows of the matrix in Grp addressed by the dMat() member, according to the low index (i.e., the Grp object contains the data). Values for the matrix are sampled around the mean values. The number returned by low.getNgrp() has to be equal to the number returned by up.getNtot(), and is equal to the number of rows in the value matrix. Violation of any of these conditions results in an error.

Parameters
[in]Grp&vector of pointers to rows of the value matrix
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level
[in]string&name of the output file

◆ MuGrp() [8/14]

MuGrp::MuGrp ( const Grp dat,
RanIndex low 
)

Deterministic mean constructor.

The value matrix of the resulting object has low.getNgrp() rows and is deterministically set to within-group means.

Parameters
[in]Grp&data object
[in]RanIndex&index that defines groups

◆ MuGrp() [9/14]

MuGrp::MuGrp ( const Grp dat,
const Qgrp q,
RanIndex low 
)

Deterministic weighted mean constructor.

The value matrix of the resulting object has low.getNgrp() rows and is deterministically set to within-group weighted means. Weghts are in the Qgrp object. They are typically Student- \(t\) model weights.

Parameters
[in]Grp&data object
[in]Qgrp&weights
[in]RanIndex&index that defines groups

◆ MuGrp() [10/14]

MuGrp::MuGrp ( const gsl_matrix *  dat)

Deterministic constructor with a GSL matrix.

Indexes not set. The given matrix is copied to the value matrix.

Parameters
[in]gsl_matrix*data matrix

◆ MuGrp() [11/14]

MuGrp::MuGrp ( const gsl_matrix *  dat,
RanIndex low 
)

Deterministic GSL matrix mean constructor.

The value matrix of the resulting object has low.getNgrp() rows and is deterministically set to within-group means. Mostly used internally in other derived classes.

Parameters
[in]gsl_matrix*data matrix
[in]RanIndex&index that defines groups

◆ MuGrp() [12/14]

MuGrp::MuGrp ( const gsl_matrix *  dat,
const Qgrp q,
RanIndex low 
)

Deterministic GSL matrix weighted mean constructor.

The value matrix of the resulting object has low.getNgrp() rows and is deterministically set to within-group weighted means. Mostly used internally in other derived classes.

Parameters
[in]gsl_matrix*data matrix
[in]Qgrp&weights
[in]RanIndex&index that defines groups

◆ MuGrp() [13/14]

MuGrp::MuGrp ( const MuGrp mG)

Copy constructor.

Parameters
[in]MuGrp&object to be copied
Returns
MuGrp& copy of the object

◆ MuGrp() [14/14]

MuGrp::MuGrp ( const Grp g)

Copy constructor.

Parameters
[in]Grp&object to be copied
Returns
MuGrp& copy of the object

Member Function Documentation

◆ operator=()

MuGrp & MuGrp::operator= ( const MuGrp mG)

Assignemnt operator.

Parameters
[in]MuGrp&object to be copied
Returns
MuGrp& target object

◆ update() [1/10]

void MuGrp::update ( const Grp ,
const Qgrp ,
const SigmaI  
)
virtual

Student- \(t\) likelihood, improper prior.

Parameters
[in]Grp&data
[in]Qgrp&Student- \(t\) weight parameter for data
[in]SigmaI&data inverse-covariance

Implements Grp.

Reimplemented in MuGrpEEmiss, MuGrpEE, and MuBlk.

◆ update() [2/10]

void MuGrp::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const Grp ,
const Qgrp ,
const SigmaI  
)
virtual

Student- \(t\) likelihood, non-zero mean Student- \(t\) prior.

For the relationship to work properly, the _upLevel index of the focal object has to point to the rows of the prior mean matrix. This is the matrix addressed by dMat(). The relationship to the data is dependent on the derived class.

Parameters
[in]Grp&data
[in]Qgrp&Student- \(t\) weight parameter for the data
[in]SigmaI&data inverse-covariance
[in]Grp&prior mean
[in]Qgrp&Student- \(t\) weight parameter for the prior
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [3/10]

void MuGrp::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const Grp ,
const SigmaI  
)
virtual

Student- \(t\) likelihood, non-zero mean Gaussian prior.

For the relationship to work properly, the _upLevel index of the focal object has to point to the rows of the prior mean matrix. This is the matrix addressed by dMat(). The relationship to the data is dependent on the derived class.

Parameters
[in]Grp&data
[in]Qgrp&Student- \(t\) weight parameter for the data
[in]SigmaI&data inverse-covariance
[in]Grp&prior mean
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [4/10]

void MuGrp::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const Qgrp ,
const SigmaI  
)
virtual

Student- \(t\) likelihood, 0-mean Student- \(t\) prior.

Parameters
[in]Grp&data
[in]Qgrp&Student- \(t\) weight parameter for the data
[in]SigmaI&data inverse-covariance
[in]Qgrp&Student- \(t\) weight parameter for the prior
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [5/10]

void MuGrp::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const SigmaI  
)
virtual

Student- \(t\) likelihood, 0-mean Gaussian prior.

Parameters
[in]Grp&data
[in]Qgrp&Student- \(t\) weight parameter for data
[in]SigmaI&data inverse-covariance
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [6/10]

void MuGrp::update ( const Grp ,
const SigmaI  
)
virtual

Gaussian likelihood, improper prior.

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

Implements Grp.

Reimplemented in MuGrpEEmiss, MuGrpEE, MuGrpMiss, MuBlk, BetaGrpSnpMiss, and BetaGrpSnp.

◆ update() [7/10]

void MuGrp::update ( const Grp ,
const SigmaI ,
const Grp ,
const Qgrp ,
const SigmaI  
)
virtual

Gaussian likelihood, non-zero mean Student- \(t\) prior.

For the relationship to work properly, the _upLevel index of the focal object has to point to the rows of the prior mean matrix. This is the matrix addressed by dMat(). The relationship to the data is dependent on the derived class.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]Grp&prior mean
[in]Qgrp&Student- \(t\) weight parameter for the prior
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [8/10]

void MuGrp::update ( const Grp ,
const SigmaI ,
const Grp ,
const SigmaI  
)
virtual

Gaussian likelihood, non-zero mean Gaussian prior.

For the relationship to work properly, the _upLevel index of the focal object has to point to the rows of the prior mean matrix. This is the matrix addressed by dMat(). The relationship to the data is dependent on the derived class.

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

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [9/10]

void MuGrp::update ( const Grp ,
const SigmaI ,
const Qgrp ,
const SigmaI  
)
virtual

Gaussian likelihood, 0-mean Student- \(t\) prior.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]Qgrp&Student- \(t\) weight parameter for the prior
[in]SigmaI&prior inverse-covariance

Implements Grp.

Reimplemented in MuBlk, and MuGrpPEX.

◆ update() [10/10]

void MuGrp::update ( const Grp ,
const SigmaI ,
const SigmaI  
)
virtual

Gaussian likelihood, 0-mean Gaussian prior.

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

Implements Grp.

Reimplemented in MuGrpMiss, MuBlk, and MuGrpPEX.

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

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