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

"Random effect" with parameter expansion More...

#include <MuGen.h>

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

Public Member Functions

 MuGrpPEX ()
 Default constructor.
 
 MuGrpPEX (const Grp &dat, RanIndex &low, RanIndex &up, const double &Spr, const int &nThr)
 Full constructor. More...
 
 MuGrpPEX (const Grp &dat, RanIndex &low, RanIndex &up, const string outMuFlNam, const double &Spr, const int &nThr)
 Full constructor with location parameter file name. More...
 
 ~MuGrpPEX ()
 Destructor.
 
 MuGrpPEX (const MuGrpPEX &mGp)
 Copy constructor. More...
 
MuGrpPEXoperator= (const MuGrpPEX &mGp)
 Assignment operator. More...
 
const gsl_matrix * fMat () const
 Access the adjusted value matrix. More...
 
void save ()
 Save the adjusted values. More...
 
void save (const string &outFlNam)
 Save adjusted values to named file. More...
 
void save (const SigmaI &SigI)
 Save with the covariance matrix. More...
 
ApexgetA ()
 Access the redundant parameter. More...
 
void setApr (const double &pr)
 Set the inverse-prior for the redundant parameter matrix. More...
 
MuGrp mean (RanIndex &grp)
 Group mean. More...
 
const MuGrp mean (RanIndex &grp) const
 Group mean. More...
 
MuGrp mean (RanIndex &grp, const Qgrp &q)
 Group weighted mean. More...
 
const MuGrp mean (RanIndex &grp, const Qgrp &q) const
 Group weighted mean. 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...
 
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...
 
- Public Member Functions inherited from Grp
virtual ~Grp ()
 Destructor.
 
virtual void save (const string &outMuFlNam, const string &outSigFlNam, const SigmaI &SigI)
 Joint save. 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...
 
void center ()
 Center the value matrix. More...
 

Protected Member Functions

void _updateFitted ()
 Update adjusted values. More...
 
- Protected Member Functions inherited from Grp
 Grp ()
 

Protected Attributes

gsl_matrix * _adjValMat
 Adjusted value matrix. More...
 
gsl_matrix * _tSigIAt
 Scaled inverse-covariance. More...
 
Apex _A
 Redundant parameter matrix.
 
vector< vector< double > > _ftA
 Fitted values. More...
 
int _nThr
 number of threads
 
string _outSigFlNam
 Covariance output file name. 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

"Random effect" with parameter expansion

An implementation of a multivariate extension (Greenberg, unpublished) of the multiplicative PEX scheme for "random effects" model [gelman07] [gelman08] . This object has to be outside the model hierarchy, i.e. have the same prior for all rows. Variables are divided into "raw" and "adjusted" as in [gelman07] . "Adjusted" variables are on the correct scale for interpretation. The "raw" value matrix is denoted \( \boldsymbol{\Xi} \) and the redundant parameter matrix (implemented in the Apex class) is \( \boldsymbol{A} \).

Constructor & Destructor Documentation

◆ MuGrpPEX() [1/3]

MuGrpPEX::MuGrpPEX ( const Grp dat,
RanIndex low,
RanIndex up,
const double &  Spr,
const int &  nThr 
)

Full constructor.

Initializing constructor that provides starting values for the location parameter and redundant parameter matrices.

Parameters
[in]Grp&data
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level
[in]double&inverse-prior for the redundant parameter matrix
[in]int&number of threads

◆ MuGrpPEX() [2/3]

MuGrpPEX::MuGrpPEX ( const Grp dat,
RanIndex low,
RanIndex up,
const string  outMuFlNam,
const double &  Spr,
const int &  nThr 
)

Full constructor with location parameter file name.

Initializing constructor that provides starting values for the location parameter and redundant parameter matrices. Sets the name of the file where the adjusted location parameter chains will be saved.

Parameters
[in]Grp&data
[in]RanIndex&index to the lower (data) level
[in]RanIndex&index to the upper (prior) level
[in]string&output file name
[in]double&inverse-prior for the redundant parameter matrix
[in]int&number of threads

◆ MuGrpPEX() [3/3]

MuGrpPEX::MuGrpPEX ( const MuGrpPEX mGp)

Copy constructor.

Parameters
[in]MuGrpPEX&object to be copied
Returns
MuGrpPEX object

Member Function Documentation

◆ fMat()

const gsl_matrix* MuGrpPEX::fMat ( ) const
inlinevirtual

Access the adjusted value matrix.

Returns
gsl_matrix* pointer to the adjusted value matrix

Reimplemented from Grp.

◆ getA()

Apex& MuGrpPEX::getA ( )
inline

Access the redundant parameter.

Returns
Apex& the redundant parameter matrix

◆ mean() [1/4]

MuGrp MuGrpPEX::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 from Grp.

◆ mean() [2/4]

const MuGrp MuGrpPEX::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 from Grp.

◆ mean() [3/4]

MuGrp MuGrpPEX::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 from Grp.

◆ mean() [4/4]

const MuGrp MuGrpPEX::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 from Grp.

◆ operator=()

MuGrpPEX & MuGrpPEX::operator= ( const MuGrpPEX mGp)

Assignment operator.

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

◆ save() [1/3]

void MuGrpPEX::save ( )
virtual

Save the adjusted values.

Appends the current adjusted mean values to the file whose name was set during construction.

Reimplemented from Grp.

◆ save() [2/3]

void MuGrpPEX::save ( const SigmaI SigI)
virtual

Save with the covariance matrix.

Appends the current adjusted mean values and prior covariance matrix to the files whose names were set during construction.

Reimplemented from Grp.

◆ save() [3/3]

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

Save adjusted values to named file.

Appends the current adjusted mean values to the named file.

Parameters
[in]string&file name

Reimplemented from Grp.

◆ setApr()

void MuGrpPEX::setApr ( const double &  pr)
inline

Set the inverse-prior for the redundant parameter matrix.

Parameters
[in]double&inverse-prior value

◆ update() [1/8]

void MuGrpPEX::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() [2/8]

void MuGrpPEX::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() [3/8]

void MuGrpPEX::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() [4/8]

void MuGrpPEX::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() [5/8]

void MuGrpPEX::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() [6/8]

void MuGrpPEX::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() [7/8]

void MuGrpPEX::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() [8/8]

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

◆ _adjValMat

gsl_matrix* MuGrpPEX::_adjValMat
protected

Adjusted value matrix.

The location paramter of interest, i.e. \( \boldsymbol{\Xi A} \).

◆ _ftA

vector<vector<double> > MuGrpPEX::_ftA
protected

Fitted values.

Vector of vectorized individual fitted matrices \( \boldsymbol{\Xi}_{\cdot -m}\boldsymbol{A}_{-m\cdot} \).

◆ _outSigFlNam

string MuGrpPEX::_outSigFlNam
protected

Covariance output file name.

This is to save the adjusted prior covariance matrix associated with this object. Saving from the SigmaI object gives the raw matrix.

◆ _tSigIAt

gsl_matrix* MuGrpPEX::_tSigIAt
protected

Scaled inverse-covariance.

The matrix \( \left( \boldsymbol{\Sigma}^{-1}\boldsymbol{A}^T \right)^T \) that is common for sampling each row of the value matrix.


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