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

Hierarchical mean with independent blocks of traits. More...

#include <MuGen.h>

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

Public Member Functions

 MuBlk ()
 Default constructor.
 
 MuBlk (const Grp &dat, const string &lowIndFlName, const size_t &Nval, RanIndex &up, const string &blkIndFileNam)
 Basic constructor. More...
 
 MuBlk (const Grp &dat, const string &lowIndFlName, const size_t &Nval, RanIndex &up, const string &outFlNam, const string &blkIndFileNam)
 Constructor with output file name. More...
 
 ~MuBlk ()
 Destructor.
 
const gsl_matrix * fMat () const
 Access to the expanded value matrix.
 
void update (const Grp &dat, const SigmaI &SigIm)
 Gaussian likelihood, improper prior. More...
 
void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm)
 Student- \(t\) likelihood, improper prior. More...
 
void update (const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Gaussian prior. More...
 
void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp)
 Student- \(t\) likelihood, 0-mean Gaussian prior. More...
 
void update (const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Student- \(t\) prior. More...
 
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...
 
void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
 Gaussian likelihood, non-zero mean Gaussian prior. More...
 
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...
 
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...
 
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 MuGrp
 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...
 
- 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...
 
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

void _updateExp ()
 Update the _expandedVM matrix.
 
void _fillIn ()
 Fill in blocks with few levels. More...
 
void _fillInUp ()
 Fill in blocks with few levels and a prior grouping. More...
 
- Protected Member Functions inherited from Grp
 Grp ()
 

Protected Attributes

vector< size_t > _blkStart
 Block start indexes. More...
 
vector< vector< vector< size_t > > > _blkLow
 Vector of low level indexes. More...
 
gsl_matrix * _expandedVM
 Expanded _valueMat. More...
 
vector< size_t > _shortLevels
 Blocks with few levels. More...
 
- 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 with independent blocks of traits.

Blocks of inter-correlated traits with correlations among blocks set to exactly zero. These models arise, for example, when traits measured in different environments are modeled together as different traits. Replication structure and the number of replicates and levels (rows in the would-be _valueMat) can be different among blocks. The only limitation is that the traits belonging to the same block have to be in adjacent columns.

Constructor & Destructor Documentation

◆ MuBlk() [1/2]

MuBlk::MuBlk ( const Grp dat,
const string &  lowIndFlName,
const size_t &  Nval,
RanIndex up,
const string &  blkIndFileNam 
)

Basic constructor.

The provided number of values is the number of rows in the value matrix, i.e. the maximum number of levels of the lower level (data) index. The file that has the lower level index information should have a matrix of int with the number of rows the same as the number of rows in the data, and the number of columns equal to the number of blocks.

Parameters
[in]Grp&data for initialization
[in]string&name of the file with the low-level index
[in]size_t&maximum number of levels
[in]RanIndex&prior index
[in]string&name of the file with the block indexes

◆ MuBlk() [2/2]

MuBlk::MuBlk ( const Grp dat,
const string &  lowIndFlName,
const size_t &  Nval,
RanIndex up,
const string &  outFlNam,
const string &  blkIndFileNam 
)

Constructor with output file name.

The provided number of values is the number of rows in the value matrix, i.e. the maximum number of levels of the lower level (data) index. The file that has the lower level index information should have a matrix of int with the number of rows the same as the number of rows in the data, and the number of columns equal to the number of blocks.

Parameters
[in]Grp&data for initialization
[in]string&name of the file with the low-level index
[in]size_t&maximum number of levels
[in]RanIndex&prior index
[in]string&output file name
[in]string&name of the file with the block indexes

Member Function Documentation

◆ _fillIn()

void MuBlk::_fillIn ( )
protected

Fill in blocks with few levels.

For blocks with the number of levels smaller than the maximum, fill in the value matrix with the overall mean among levels. This insures that the overall mean is equal to what it would be if only the available rows were used.

◆ _fillInUp()

void MuBlk::_fillInUp ( )
protected

Fill in blocks with few levels and a prior grouping.

The same as _fillIn(), but the means are calculated according to the grouping in the prior (upper) level in the hierarchy.

◆ update() [1/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [2/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [3/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [4/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [5/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [6/10]

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

Gaussian likelihood, improper prior.

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

Reimplemented from MuGrp.

◆ update() [7/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [8/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [9/10]

void MuBlk::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

Reimplemented from MuGrp.

◆ update() [10/10]

void MuBlk::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

Reimplemented from MuGrp.

Member Data Documentation

◆ _blkLow

vector< vector< vector<size_t> > > MuBlk::_blkLow
protected

Vector of low level indexes.

Indexes to data, similar to _lowLevel. These are separate for each block, not necessarily the same number of levels or replicates in each.

◆ _blkStart

vector< size_t > MuBlk::_blkStart
protected

Block start indexes.

Vector of indexes that indicate the column that starts each block.

◆ _expandedVM

gsl_matrix* MuBlk::_expandedVM
protected

Expanded _valueMat.

Expanded value matrix, with the rows repeated according to _blkLow, separately for each block. To be used for arithmetic operators.

◆ _shortLevels

vector<size_t> MuBlk::_shortLevels
protected

Blocks with few levels.

For cases where the number of levels of _blkLow differ among blocks, this vector stores the index of the first element past the available one.
For blocks that have the same number of levels as the largest among blocks, the value is zero. Each object has to have at least one zero in this vector, which is for the block with the largest number of levels.


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