MuGen
Multitrait genetics
|
Basic inverse-covariance. More...
#include <MuGen.h>
Public Member Functions | |
SigmaI () | |
Default constructor. More... | |
SigmaI (const size_t &d, const double &invVar) | |
Deterministic diagonal matrix constructor. More... | |
SigmaI (const size_t &d, const double &invVar, const double &df) | |
Deterministic diagonal matrix constructor. More... | |
SigmaI (const size_t &d, const double &invVar, const double &df, const string &outFlNam) | |
Deterministic diagonal matrix constructor with output file name. More... | |
SigmaI (const gsl_matrix *mat) | |
Deterministic matrix constructor. More... | |
SigmaI (const gsl_matrix *S, const size_t &d, const size_t &df, const gsl_matrix *LamPr, const double &nu0) | |
Constructor with a matrix prior. More... | |
SigmaI (const gsl_matrix *S, const size_t &d, const size_t &df, const double &diagPr, const double &nu0) | |
Constructor with a diagonal prior. More... | |
SigmaI (const Grp &dat, const double &prDiag, const double &nu0) | |
Location data-based constructor. More... | |
SigmaI (const Grp &dat, const string &outFlNam, const double &prDiag, const double &nu0) | |
Location data-based constructor with output file name. More... | |
SigmaI (const SigmaI &) | |
Copy constructor. More... | |
SigmaI & | operator= (const SigmaI &) |
Assignment operator. More... | |
virtual | ~SigmaI () |
Destructor. | |
virtual void | update (const Grp &dat) |
Basic Gaussian update. More... | |
virtual void | update (const Grp &dat, const Grp &mu) |
Gaussian update with a mean. More... | |
virtual void | update (const Grp &dat, const Qgrp &q) |
Basic Student- \(t\) update. More... | |
virtual void | update (const Grp &dat, const Grp &mu, const Qgrp &q) |
Student- \(t\) update with a mean. More... | |
virtual void | save (const char *how="a") |
Save to a stored file name. More... | |
virtual void | save (const string &fileNam, const char *how="a") |
Save to a given file name. More... | |
void | save (const string &fileNam, const Apex &A, const char *how="a") |
Save adjusted matrix. More... | |
void | save (FILE *fileStr) |
Save to file stream. More... | |
string | getOutFile () const |
Access the output file. More... | |
const gsl_matrix * | getMat () const |
Access to the inverse-covariance matrix. More... | |
void | srDetUpdate () |
Update square-root of the determinant. | |
double | getSrDet () const |
Access the square-root of the determinant. More... | |
Protected Attributes | |
gsl_matrix * | _mat |
Inverse-covariance matrix. More... | |
size_t | _d |
Dimension of the matrix. More... | |
double | _srDet |
Square root of the determinant. More... | |
gsl_matrix * | _LamSc |
Prior inverse-covariance. More... | |
double | _n0 |
Prior degrees of freedom. | |
string | _outFlNam |
Output file name. | |
gsl_rng * | _r |
Pseudo-random number generator. More... | |
Basic inverse-covariance.
Standard model for inverse-covariance matrices with a diagonal Wishart prior (i.e., pre-supposing no correlations among traits). The values on the diagonal of the prior matrix and the prior degrees of freedom can be varied to reflect the vagueness of prior information. These conjugate priors allow for Gibbs sampling even when the number of traits exceeds the number of data points. However, in the latter case the estimation of correlations will likely be inaccurate. Algorithms involving direct penalties on correlations should perform better and are inder development.
SigmaI::SigmaI | ( | ) |
Default constructor.
Creates a \( 2\times2 \) identity matrix.
SigmaI::SigmaI | ( | const size_t & | d, |
const double & | invVar | ||
) |
Deterministic diagonal matrix constructor.
Creates a diagonal matrix with the provided inverse-variance and the degrees of freedom parameter equal to one. Principally used to create vague large-variance Gaussian priors for location parameters.
[in] | size_t& | number of rows and columns |
[in] | double& | inverse variance |
SigmaI::SigmaI | ( | const size_t & | d, |
const double & | invVar, | ||
const double & | df | ||
) |
Deterministic diagonal matrix constructor.
Creates a diagonal matrix with the provided inverse-variance and degrees of freedom parameter.
[in] | size_t& | number of rows and columns |
[in] | double& | inverse variance |
[in] | double& | degrees of freedom |
SigmaI::SigmaI | ( | const size_t & | d, |
const double & | invVar, | ||
const double & | df, | ||
const string & | outFlNam | ||
) |
Deterministic diagonal matrix constructor with output file name.
Creates a diagonal matrix with the provided inverse-variance and degrees of freedom parameter.
[in] | size_t& | number of rows and columns |
[in] | double& | inverse variance |
[in] | double& | degrees of freedom |
[in] | string& | output file name |
SigmaI::SigmaI | ( | const gsl_matrix * | mat | ) |
Deterministic matrix constructor.
Used to initialize the inverse-covariance with a given matrix deterministically, i.e. the initial values are not sampled. Only the lower-triangular part of the matrix is used, so if it is not symmetric no error is produced.
[in] | gsl_matrix* | value matrix |
SigmaI::SigmaI | ( | const gsl_matrix * | S, |
const size_t & | d, | ||
const size_t & | df, | ||
const gsl_matrix * | LamPr, | ||
const double & | nu0 | ||
) |
Constructor with a matrix prior.
Initializes the matrix with a Wishart sample with the provided matrix as data and another matrix as a prior.
[in] | gsl_matrix* | data matrix |
[in] | size_t& | dimension parameter |
[in] | size_t& | Wishart sample degrees of freedom |
[in] | gsl_matrix* | prior matrix |
[in] | double& | prior degrees of freedom |
SigmaI::SigmaI | ( | const gsl_matrix * | S, |
const size_t & | d, | ||
const size_t & | df, | ||
const double & | diagPr, | ||
const double & | nu0 | ||
) |
Constructor with a diagonal prior.
Initializes the matrix with a Wishart sample with the provided matrix as data and a diagonal prior with all elements set to the provided value.
[in] | gsl_matrix* | data matrix |
[in] | size_t& | dimension parameter |
[in] | size_t& | Wishart sample degrees of freedom |
[in] | double* | prior inverse-variance |
[in] | double& | prior degrees of freedom |
SigmaI::SigmaI | ( | const Grp & | dat, |
const double & | prDiag, | ||
const double & | nu0 | ||
) |
Location data-based constructor.
Initializes the object with an inverse-covariance of the provided location data. The dimension of the object os equal to the number of columns in the data.
[in] | Grp& | data |
[in] | double& | prior inverse-variance |
[in] | double& | prior degrees of freedom |
SigmaI::SigmaI | ( | const Grp & | dat, |
const string & | outFlNam, | ||
const double & | prDiag, | ||
const double & | nu0 | ||
) |
Location data-based constructor with output file name.
Initializes the object with an inverse-covariance of the provided location data. The dimension of the object os equal to the number of columns in the data.
[in] | Grp& | data |
[in] | string& | output file name |
[in] | double& | prior inverse-variance |
[in] | double& | prior degrees of freedom |
SigmaI::SigmaI | ( | const SigmaI & | S | ) |
Copy constructor.
[in] | SigmaI& | oject to be copied |
|
inline |
Access to the inverse-covariance matrix.
|
inline |
Access the output file.
|
inline |
Access the square-root of the determinant.
|
virtual |
Save to a stored file name.
[in] | char* | saving mode, appending by default |
Reimplemented in SigmaIpex.
void SigmaI::save | ( | const string & | fileNam, |
const Apex & | A, | ||
const char * | how = "a" |
||
) |
Save adjusted matrix.
Saving the adjusted matrix for the multiplicative parameter expansion models.
[in] | string& | output file name |
[in] | Apex& | redundant parameter matrix |
[in] | char* | saving mode, appending by default |
|
virtual |
Save to a given file name.
[in] | string& | output file name |
[in] | char* | saving mode, appending by default |
Reimplemented in SigmaIpex.
|
inline |
Save to file stream.
[in] | FILE* | file stream name |
|
protected |
Dimension of the matrix.
The number of rows and columns of _mat.
|
protected |
Prior inverse-covariance.
Diagonal matrix with zeros on the off-diagonal and inverse variance scaled by degrees of freedom on the diagonal.
|
protected |
Inverse-covariance matrix.
Square symmetric matrix.
|
protected |
Pseudo-random number generator.
Initialized the same way as Grp type PNGs, with a sum of time and RTDSC.
|
protected |
Square root of the determinant.
Square root of the determinant of the corrent value of the inverse-covariance matrix. Is calculated only if necessary, otherwise is set to -1.0 to provide an easy way to find out if it had been calculated at least once.