MuGen
Multitrait genetics
|
"Random effect" with parameter expansion More...
#include <MuGen.h>
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... | |
MuGrpPEX & | operator= (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... | |
Apex & | getA () |
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... | |
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... | |
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 MVnorm * | operator[] (const size_t i) const |
Subscript operator. More... | |
MVnorm * | operator[] (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. | |
"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} \).
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.
[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::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.
[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::MuGrpPEX | ( | const MuGrpPEX & | mGp | ) |
|
inlinevirtual |
Access the adjusted value matrix.
Reimplemented from Grp.
|
inline |
Access the redundant parameter.
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.
[in] | RanIndex& | grouping index |
Reimplemented from Grp.
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.
[in] | RanIndex& | grouping index |
Reimplemented from Grp.
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.
[in] | RanIndex& | grouping index |
[in] | Qgrp& | weights |
Reimplemented from Grp.
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.
[in] | RanIndex& | grouping index |
[in] | Qgrp& | weights |
Reimplemented from Grp.
|
virtual |
Save the adjusted values.
Appends the current adjusted mean values to the file whose name was set during construction.
Reimplemented from Grp.
|
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.
|
virtual |
Save adjusted values to named file.
Appends the current adjusted mean values to the named file.
[in] | string& | file name |
Reimplemented from Grp.
|
inline |
Set the inverse-prior for the redundant parameter matrix.
[in] | double& | inverse-prior value |
|
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 |
Reimplemented from MuGrp.
|
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 |
Reimplemented from MuGrp.
|
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 |
Reimplemented from MuGrp.
Student- \(t\) likelihood, 0-mean Gaussian prior.
[in] | Grp& | data |
[in] | Qgrp& | Student- \(t\) weight parameter for data |
[in] | SigmaI& | data inverse-covariance |
[in] | SigmaI& | prior inverse-covariance |
Reimplemented from MuGrp.
|
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 |
Reimplemented from MuGrp.
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 |
Reimplemented from MuGrp.
Gaussian likelihood, 0-mean Student- \(t\) prior.
[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.
Gaussian likelihood, 0-mean Gaussian prior.
[in] | Grp& | data |
[in] | SigmaI& | data inverse-covariance |
[in] | SigmaI& | prior inverse-covariance |
Reimplemented from MuGrp.
|
protected |
Adjusted value matrix.
The location paramter of interest, i.e. \( \boldsymbol{\Xi A} \).
|
protected |
Fitted values.
Vector of vectorized individual fitted matrices \( \boldsymbol{\Xi}_{\cdot -m}\boldsymbol{A}_{-m\cdot} \).
|
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.
|
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.