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

Individual vector of means. More...

#include <MuGen.h>

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

Public Member Functions

 MVnormMu ()
 Default constructor. More...
 
 MVnormMu (const size_t &d)
 Zero vector constructor. More...
 
 MVnormMu (const size_t &d, const vector< size_t > &low, const size_t &up)
 Zero vector with pointers. More...
 
 MVnormMu (gsl_vector *mn, const vector< size_t > &low, const size_t &up)
 Deterministic constructor. More...
 
 MVnormMu (gsl_vector *mn, const size_t &up)
 Deterministic constructor, prior index only. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw)
 Deterministic constructor with a matrix. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw, const vector< size_t > &low)
 Deterministic constructor with a matrix and an index to data. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw, const vector< size_t > &low, const size_t &up)
 Deterministic constructor with a matrix and indexes to data and a prior. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw, const size_t &up)
 Deterministic constructor with a matrix and an index to a prior. More...
 
 MVnormMu (gsl_vector *mn, const gsl_vector *sd, const gsl_rng *r, const vector< size_t > &low, const size_t &up)
 Univariate random constructor with a vector and indexes to data and a prior. More...
 
 MVnormMu (gsl_vector *mn, const gsl_matrix *Sig, const gsl_rng *r, const vector< size_t > &low, const size_t &up)
 Multivariate random constructor with a vector and indexes to data and a prior. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r, const vector< size_t > &low, const size_t &up)
 Univariate random constructor with a matrix and indexes to data and a prior. More...
 
 MVnormMu (gsl_matrix *mn, const size_t &iRw, const gsl_matrix *Sig, const gsl_rng *r, const vector< size_t > &low, const size_t &up)
 Multivariate random constructor with a matrix and indexes to data and a prior. More...
 
 MVnormMu (const MVnormMu &)
 Copy constructor. More...
 
MVnormMuoperator= (const MVnormMu &)
 Assignment operator. More...
 
virtual ~MVnormMu ()
 Destructor.
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const gsl_rng *r)
 Gaussian likelihood. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const gsl_rng *r)
 Sudent- \(t\) likelihood. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r)
 Gaussian likelihood, Gaussian prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r)
 Gaussian likelihood, Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r)
 Student- \(t\) likelihood, Gaussian prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r)
 Student- \(t\) likelihood, Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r)
 Gaussian likelihood, Gaussian prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r)
 Gaussian likelihood, Student- \(t\) prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r)
 Student- \(t\) likelihood, Gaussian prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r)
 Student- \(t\) likelihood, Student- \(t\) prior. More...
 
virtual size_t nMissP () const
 Number of missing values. More...
 
virtual const vector< size_t > getMisPhen () const
 Indexes of missing values. More...
 
const vector< size_t > * down () const
 Points to the corresponding data. More...
 
const size_t * up () const
 Points to the prior. More...
 
- Public Member Functions inherited from MVnorm
 MVnorm (const MVnorm &)
 Copy constructor. More...
 
MVnormoperator= (const MVnorm &)
 Assignement operator. More...
 
virtual ~MVnorm ()
 Virtual destructor. More...
 
virtual double mhl (const MVnorm *x, const SigmaI &SigI)
 Mahalanobis distance to a vector. More...
 
virtual double mhl (const MVnorm *x, const SigmaI &SigI) const
 Mahalanobis distance to a vector. More...
 
virtual double mhl (const gsl_vector *x, const SigmaI &SigI)
 Mahalanobis distance to a vector. More...
 
virtual double mhl (const gsl_vector *x, const SigmaI &SigI) const
 Mahalanobis distance to a vector. More...
 
virtual double mhl (const SigmaI &SigI)
 Mahalanobis distance to zero. More...
 
virtual double mhl (const SigmaI &SigI) const
 Mahalanobis distance to zero. More...
 
double density (const gsl_vector *theta, const SigmaI &SigI)
 Multivariate Gaussian density. More...
 
double density (const gsl_vector *theta, const SigmaI &SigI) const
 Multivariate Gaussian density. More...
 
double density (const MVnorm *theta, const SigmaI &SigI)
 Multivariate Gaussian density. More...
 
double density (const MVnorm *theta, const SigmaI &SigI) const
 Multivariate Gaussian density. More...
 
void save (const string &fileNam, const char *how="a")
 Save function. More...
 
void save (FILE *fileStr)
 Save function. More...
 
double operator[] (const size_t i) const
 Subscript operator. More...
 
void valSet (const size_t i, const double x)
 Setting an element to a value. More...
 
const gsl_vector * getVec () const
 Access the location vector. More...
 
size_t len () const
 Length of the location vector. More...
 
virtual double scalePar () const
 Scale parameter. More...
 

Protected Attributes

const vector< size_t > * _lowLevel
 Data indexes. More...
 
const size_t * _upLevel
 Prior index. More...
 
- Protected Attributes inherited from MVnorm
gsl_vector_view _vec
 Data vector. More...
 
size_t _d
 Length of the data vector.
 

Additional Inherited Members

- Protected Member Functions inherited from MVnorm
 MVnorm ()
 Default constructor. More...
 
 MVnorm (const size_t &d)
 Dimension-only constructor. More...
 
 MVnorm (gsl_vector *mn)
 Dimension and vector value constructor. More...
 
 MVnorm (gsl_vector *mn, const gsl_vector *sd, const gsl_rng *r)
 Univariate Gaussian constructor. More...
 
 MVnorm (gsl_vector *mn, const gsl_matrix *Sig, const gsl_rng *r)
 Multivariate Gaussian constructor. More...
 
 MVnorm (gsl_matrix *mn, const size_t &iRw)
 Dimension and vector value constructor. More...
 
 MVnorm (gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r)
 Univariate Gaussian constructor with a matrix. More...
 
 MVnorm (gsl_matrix *mn, const size_t &iRw, const gsl_matrix *Sig, const gsl_rng *r)
 Multivariate Gaussian constructor with a matrix. More...
 

Detailed Description

Individual vector of means.

Refers to a row of a matrix of location parameters that are updated with a likelihood that is an inverse-covariance weighted mean of the data. Variables of this class are typically imbedded in a model hierarchy, and in that case are updated with non-0-mean priors. This class allows us to keep track of which rows in data and prior matrices to use through pointers to index vectors (for data, where there may be more than one row) and to a single index (for the prior mean, since there is only one).
We use pointers because they allow us to modify the indexes in other parts of the model, thus allowing for things like mixture models and model selection schemes.

Constructor & Destructor Documentation

◆ MVnormMu() [1/14]

MVnormMu::MVnormMu ( )

Default constructor.

The _vec member is unassigned and the low-level and upper-level pointers are set to zero.

◆ MVnormMu() [2/14]

MVnormMu::MVnormMu ( const size_t &  d)
inline

Zero vector constructor.

Sets _vec to point to a vector of zeros, of length d.

Parameters
[in]size_t&size of the vector

◆ MVnormMu() [3/14]

MVnormMu::MVnormMu ( const size_t &  d,
const vector< size_t > &  low,
const size_t &  up 
)

Zero vector with pointers.

Sets _vec to point to a vector of zeros, of length d. Pointers to the lower and upper level of the model hierarchy are set.

Parameters
[in]size_t&size of the vector
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [4/14]

MVnormMu::MVnormMu ( gsl_vector *  mn,
const vector< size_t > &  low,
const size_t &  up 
)

Deterministic constructor.

Sets _vec to point to a GSL vector of values, without modifying the target during the invocation of the constructor. The pointers to the data and the prior indexes are set.

Parameters
[in]gsl_vector*vector of values
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [5/14]

MVnormMu::MVnormMu ( gsl_vector *  mn,
const size_t &  up 
)

Deterministic constructor, prior index only.

Sets _vec to point to a GSL vector of values, without modifying the target during the invocation of the constructor. Only the pointer to the prior index is set. This constructor can be used for the lowest hierarchy level.

Parameters
[in]gsl_vector*vector of values
[in]size_t&index in the matrix of priors

◆ MVnormMu() [6/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw 
)

Deterministic constructor with a matrix.

Sets _vec to point to a row of the GSL matrix of values, without modifying the target during the invocation of the constructor.

Parameters
[in]gsl_matrix*matrix of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn

◆ MVnormMu() [7/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw,
const vector< size_t > &  low 
)

Deterministic constructor with a matrix and an index to data.

Sets _vec to point to a row of the GSL matrix of values, without modifying the target during the invocation of the constructor. None of the index pointers are set.

Parameters
[in]gsl_matrix*matrix of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn
[in]vector<size_t>&vector of indexes of rows in the data matrix

◆ MVnormMu() [8/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw,
const vector< size_t > &  low,
const size_t &  up 
)

Deterministic constructor with a matrix and indexes to data and a prior.

Sets _vec to point to a row of the GSL matrix of values, without modifying the target during the invocation of the constructor.

Parameters
[in]gsl_matrix*vector of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [9/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw,
const size_t &  up 
)

Deterministic constructor with a matrix and an index to a prior.

Sets _vec to point to a row of the GSL matrix of values, without modifying the target during the invocation of the constructor.

Parameters
[in]gsl_matrix*vector of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn
[in]size_t&index in the matrix of priors

◆ MVnormMu() [10/14]

MVnormMu::MVnormMu ( gsl_vector *  mn,
const gsl_vector *  sd,
const gsl_rng *  r,
const vector< size_t > &  low,
const size_t &  up 
)

Univariate random constructor with a vector and indexes to data and a prior.

Sets _vec to point to a GSL vector of values, modifying the target during the invocation of the constructor. Modification is by adding independent samples from a univariate normal distribution with the provided standard deviations.

Parameters
[in]gsl_vector*vector of values
[in]gsl_vector*vector of standard deviations
[in]gsl_rng*pointer to a PNG
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn

◆ MVnormMu() [11/14]

MVnormMu::MVnormMu ( gsl_vector *  mn,
const gsl_matrix *  Sig,
const gsl_rng *  r,
const vector< size_t > &  low,
const size_t &  up 
)

Multivariate random constructor with a vector and indexes to data and a prior.

Sets _vec to point to a GSL vector of values, modifying the target during the invocation of the constructor. Modification is by adding samples from a multivariate normal distribution with the provided covariance matrix.

Parameters
[in]gsl_vector*vector of values
[in]gsl_matrix*covariance matrix
[in]gsl_rng*pointer to a PNG
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [12/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw,
const gsl_vector *  sd,
const gsl_rng *  r,
const vector< size_t > &  low,
const size_t &  up 
)

Univariate random constructor with a matrix and indexes to data and a prior.

Sets _vec to point to a row of the GSL matrix of values, modifying the target during the invocation of the constructor. Modification is by adding independent samples from a univariate normal distribution with the provided standard deviations.

Parameters
[in]gsl_matrix*matrix of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn
[in]gsl_vector*vector of standard deviations
[in]gsl_rng*pointer to a PNG
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [13/14]

MVnormMu::MVnormMu ( gsl_matrix *  mn,
const size_t &  iRw,
const gsl_matrix *  Sig,
const gsl_rng *  r,
const vector< size_t > &  low,
const size_t &  up 
)

Multivariate random constructor with a matrix and indexes to data and a prior.

Sets _vec to point to a row of the GSL matrix of values, modifying the target during the invocation of the constructor. Modification is by adding samples from a multivariate normal distribution with the provided covariance matrix.

Parameters
[in]gsl_matrix*matrix of values
[in]size_t&row index of the matrix of values, has to be no smaller than 0 and strictly smaller than the number of rows in mn
[in]gsl_matrix*covariance matrix
[in]gsl_rng*pointer to a PNG
[in]vector<size_t>&vector of indexes of rows in the data matrix
[in]size_t&index in the matrix of priors

◆ MVnormMu() [14/14]

MVnormMu::MVnormMu ( const MVnormMu mu)

Copy constructor.

Deterministic copy constructor

Parameters
[in]MVnormMu&object of type MVnormMu

Member Function Documentation

◆ down()

const vector<size_t>* MVnormMu::down ( ) const
inlinevirtual

Points to the corresponding data.

Access to the pointer to a vector that indexes the data used to update an instance of the class. Is implemented for this class.

Returns
Pointer to a vector of size_t.

Reimplemented from MVnorm.

◆ getMisPhen()

virtual const vector<size_t> MVnormMu::getMisPhen ( ) const
inlinevirtual

Indexes of missing values.

Accesses a vector with indexes of missing phenotypes.

Returns
Vector of size_t that contains indexes that correspond to missing values. For classes that do not allow missing values it is empty.

Reimplemented from MVnorm.

Reimplemented in MVnormMuMiss.

◆ nMissP()

virtual size_t MVnormMu::nMissP ( ) const
inlinevirtual

Number of missing values.

Accesses the number of missing phenotype values. Non-zero only for classes that implement treatment of missing values.

Returns
Number of missing phenotypes, of type size_t.

Reimplemented from MVnorm.

Reimplemented in MVnormMuMiss.

◆ operator=()

MVnormMu & MVnormMu::operator= ( const MVnormMu mu)

Assignment operator.

Deterministic assignement operator

Parameters
[in]MVnormMu&object of type MVnormMu
Returns
A reference to an object of type MVnormMu

◆ up()

const size_t* MVnormMu::up ( ) const
inlinevirtual

Points to the prior.

Access to the pointer to the correspoding vector of priors. Is implemented for this class.

Returns
Pointer to size_t.

Reimplemented from MVnorm.

◆ update() [1/10]

void MVnormMu::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const double &  ,
const SigmaI ,
const gsl_rng *   
)
virtual

Student- \(t\) likelihood, Student- \(t\) prior.

Parameters
[in]Grp&data for the likelihood
[in]Qgrp&vector Student- \(t\) covariance scale parameter for the likelihood covariance
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]double&Student- \(t\) scale parameter for the prior covariance
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [2/10]

void MVnormMu::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const Grp ,
const double &  ,
const SigmaI ,
const gsl_rng *   
)
virtual

Student- \(t\) likelihood, Student- \(t\) prior.

Parameters
[in]Grp&data for the likelihood
[in]Qgrp&vector Student- \(t\) covariance scale parameter for the likelihood covariance
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]Grp&prior mean
[in]double&Student- \(t\) scale parameter for the prior covariance
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [3/10]

void MVnormMu::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const Grp ,
const SigmaI ,
const gsl_rng *   
)
virtual

Student- \(t\) likelihood, Gaussian prior.

Parameters
[in]Grp&data for the likelihood
[in]Qgrp&vector Student- \(t\) covariance scale parameter for the likelihood covariance
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]Grp&prior mean
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [4/10]

void MVnormMu::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const gsl_rng *   
)
virtual

Sudent- \(t\) likelihood.

Parameters
[in]Grp&data
[in]Qgrp&vector of Student- \(t\) covariance scale parameters for the likelihood covariance
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

◆ update() [5/10]

void MVnormMu::update ( const Grp ,
const Qgrp ,
const SigmaI ,
const SigmaI ,
const gsl_rng *   
)
virtual

Student- \(t\) likelihood, Gaussian prior.

Parameters
[in]Grp&data for the likelihood
[in]Qgrp&vector of Student- \(t\) covariance scale parameters for the likelihood covariance
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [6/10]

void MVnormMu::update ( const Grp ,
const SigmaI ,
const double &  ,
const SigmaI ,
const gsl_rng *   
)
virtual

Gaussian likelihood, Student- \(t\) prior.

Parameters
[in]Grp&data for the likelihood
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]double&Student- \(t\) scale parameter for the prior covariance
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [7/10]

void MVnormMu::update ( const Grp ,
const SigmaI ,
const Grp ,
const double &  ,
const SigmaI ,
const gsl_rng *   
)
virtual

Gaussian likelihood, Student- \(t\) prior.

Parameters
[in]Grp&data for the likelihood
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]Grp&prior mean
[in]double&Student- \(t\) scale parameter for the prior covariance
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [8/10]

void MVnormMu::update ( const Grp ,
const SigmaI ,
const Grp ,
const SigmaI ,
const gsl_rng *   
)
virtual

Gaussian likelihood, Gaussian prior.

Parameters
[in]Grp&data for the likelihood
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]Grp&prior mean
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormBetaPEX, and MVnormMuPEX.

◆ update() [9/10]

void MVnormMu::update ( const Grp ,
const SigmaI ,
const gsl_rng *   
)
virtual

Gaussian likelihood.

Parameters
[in]Grp&data
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormMuMiss.

◆ update() [10/10]

void MVnormMu::update ( const Grp ,
const SigmaI ,
const SigmaI ,
const gsl_rng *   
)
virtual

Gaussian likelihood, Gaussian prior.

Parameters
[in]Grp&data for the likelihood
[in]SigmaI&inverse-covariance matrix for the likelihood
[in]SigmaI&prior inverse-covariance matrix
[in]gsl_rng*pointer to a PNG

Implements MVnorm.

Reimplemented in MVnormMuMiss, MVnormBetaPEX, and MVnormMuPEX.

Member Data Documentation

◆ _lowLevel

const vector<size_t>* MVnormMu::_lowLevel
protected

Data indexes.

A pointer to a vector of size_t. The elements are row indexes of the data matrix. Means among these rows are used in the likelihood of the udpate functions. The pointer is const to make sure we are not modifying it from this class.

◆ _upLevel

const size_t* MVnormMu::_upLevel
protected

Prior index.

Pointer to a value of type size_t that is a row index of the prior location matrix. The pointer is const to make sure we are not modifying it from this class.


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