MuGen
Multitrait genetics
|
Hierarchical mean. More...
#include <MuGen.h>
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... | |
MuGrp & | operator= (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 MVnorm * | operator[] (const size_t i) const |
Subscript operator. More... | |
MVnorm * | operator[] (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. | |
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).
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.
[in] | RanIndex& | index to the lower level |
[in] | size_t& | number of traits |
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.
[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::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.
[in] | string& | data file name |
[in] | RanIndex& | index to the upper (prior) level |
[in] | size_t& | number of traits |
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.
[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 |
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.
[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::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.
[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 |
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.
[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 |
Deterministic mean constructor.
The value matrix of the resulting object has low.getNgrp() rows and is deterministically set to within-group means.
[in] | Grp& | data object |
[in] | RanIndex& | index that defines groups |
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.
[in] | Grp& | data object |
[in] | Qgrp& | weights |
[in] | RanIndex& | index that defines groups |
MuGrp::MuGrp | ( | const gsl_matrix * | dat | ) |
Deterministic constructor with a GSL matrix.
Indexes not set. The given matrix is copied to the value matrix.
[in] | gsl_matrix* | data matrix |
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.
[in] | gsl_matrix* | data matrix |
[in] | RanIndex& | index that defines groups |
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.
[in] | gsl_matrix* | data matrix |
[in] | Qgrp& | weights |
[in] | RanIndex& | index that defines groups |
MuGrp::MuGrp | ( | const MuGrp & | mG | ) |
MuGrp::MuGrp | ( | const Grp & | g | ) |
Student- \(t\) likelihood, improper prior.
[in] | Grp& | data |
[in] | Qgrp& | Student- \(t\) weight parameter for data |
[in] | SigmaI& | data inverse-covariance |
Implements Grp.
Reimplemented in MuGrpEEmiss, MuGrpEE, and MuBlk.
|
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.
[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.
|
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.
[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.
|
virtual |
Student- \(t\) likelihood, 0-mean Student- \(t\) prior.
[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.
Gaussian likelihood, improper prior.
[in] | Grp& | data |
[in] | SigmaI& | data inverse-covariance |
Implements Grp.
Reimplemented in MuGrpEEmiss, MuGrpEE, MuGrpMiss, MuBlk, BetaGrpSnpMiss, and BetaGrpSnp.
|
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.
[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.
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.
[in] | Grp& | data |
[in] | SigmaI& | data inverse-covariance |
[in] | Grp& | prior mean |
[in] | SigmaI& | prior inverse-covariance |
Implements Grp.
Addition operator.
[in] | Grp& | first summand |
[in] | Grp& | second summand |
Addition operator.
[in] | Grp& | first summand |
[in] | MuGrp& | second summand |
Addition operator.
[in] | MuGrp& | first summand |
[in] | Grp& | second summand |
Subtraction operator.
[in] | Grp& | minuend |
[in] | Grp& | subtrahend |
Subtraction operator.
[in] | Grp& | minuend |
[in] | MuGrp& | subtrahend |
Subtraction operator.
[in] | MuGrp& | minuend |
[in] | Grp& | subtrahend |