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

Basic inverse-covariance. More...

#include <MuGen.h>

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

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...
 
SigmaIoperator= (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SigmaI() [1/10]

SigmaI::SigmaI ( )

Default constructor.

Creates a \( 2\times2 \) identity matrix.

◆ SigmaI() [2/10]

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.

Parameters
[in]size_t&number of rows and columns
[in]double&inverse variance

◆ SigmaI() [3/10]

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.

Parameters
[in]size_t&number of rows and columns
[in]double&inverse variance
[in]double&degrees of freedom

◆ SigmaI() [4/10]

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.

Parameters
[in]size_t&number of rows and columns
[in]double&inverse variance
[in]double&degrees of freedom
[in]string&output file name

◆ SigmaI() [5/10]

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.

Parameters
[in]gsl_matrix*value matrix

◆ SigmaI() [6/10]

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.

Parameters
[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() [7/10]

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.

Parameters
[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() [8/10]

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.

Parameters
[in]Grp&data
[in]double&prior inverse-variance
[in]double&prior degrees of freedom

◆ SigmaI() [9/10]

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.

Parameters
[in]Grp&data
[in]string&output file name
[in]double&prior inverse-variance
[in]double&prior degrees of freedom

◆ SigmaI() [10/10]

SigmaI::SigmaI ( const SigmaI S)

Copy constructor.

Parameters
[in]SigmaI&oject to be copied

Member Function Documentation

◆ getMat()

const gsl_matrix* SigmaI::getMat ( ) const
inline

Access to the inverse-covariance matrix.

Returns
gsl_matrix* pointer to the inverse-covariance matrix

◆ getOutFile()

string SigmaI::getOutFile ( ) const
inline

Access the output file.

Returns
string file name

◆ getSrDet()

double SigmaI::getSrDet ( ) const
inline

Access the square-root of the determinant.

Returns
double square root of the determinant of the inverse-covariance

◆ operator=()

SigmaI & SigmaI::operator= ( const SigmaI S)

Assignment operator.

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

◆ save() [1/4]

void SigmaI::save ( const char *  how = "a")
virtual

Save to a stored file name.

Parameters
[in]char*saving mode, appending by default

Reimplemented in SigmaIpex.

◆ save() [2/4]

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.

Parameters
[in]string&output file name
[in]Apex&redundant parameter matrix
[in]char*saving mode, appending by default

◆ save() [3/4]

void SigmaI::save ( const string &  fileNam,
const char *  how = "a" 
)
virtual

Save to a given file name.

Parameters
[in]string&output file name
[in]char*saving mode, appending by default

Reimplemented in SigmaIpex.

◆ save() [4/4]

void SigmaI::save ( FILE *  fileStr)
inline

Save to file stream.

Parameters
[in]FILE*file stream name

Member Data Documentation

◆ _d

size_t SigmaI::_d
protected

Dimension of the matrix.

The number of rows and columns of _mat.

◆ _LamSc

gsl_matrix* SigmaI::_LamSc
protected

Prior inverse-covariance.

Diagonal matrix with zeros on the off-diagonal and inverse variance scaled by degrees of freedom on the diagonal.

◆ _mat

gsl_matrix* SigmaI::_mat
protected

Inverse-covariance matrix.

Square symmetric matrix.

◆ _r

gsl_rng* SigmaI::_r
protected

Pseudo-random number generator.

Initialized the same way as Grp type PNGs, with a sum of time and RTDSC.

◆ _srDet

double SigmaI::_srDet
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.


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