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

Bayesian variable selection regression. More...

#include <MuGen.h>

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

Public Member Functions

 BetaGrpBVSR ()
 Default constructor.
 
 BetaGrpBVSR (const Grp &y, const SigmaI &SigI, const string &predFlNam, const double &Nmul, const double &rSqMax, RanIndex &up, const string &outFlNam, const int &nThr)
 Basic constructor. More...
 
 BetaGrpBVSR (const Grp &y, const SigmaI &SigI, const string &predFlNam, const double &Nmul, const double &rSqMax, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Basic constructor with replication. More...
 
 BetaGrpBVSR (const Grp &y, const SigmaI &SigI, const string &predFlNam, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr)
 Basic constructor with missing data. More...
 
 BetaGrpBVSR (const Grp &y, const SigmaI &SigI, const string &predFlNam, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Basic constructor with replication and missing data. More...
 
 ~BetaGrpBVSR ()
 Destructor.
 
void save (const SigmaI &SigI)
 Regression value store. More...
 
- Public Member Functions inherited from BetaGrpFt
 BetaGrpFt ()
 Default constructor.
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const int &nThr)
 Simple constructor. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &up, const int &nThr)
 Simple constructor with a prior index. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const int &nThr)
 Simple constructor with a prior index and replication. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const string &outFlNam, const int &nThr)
 Simple constructor with output file name. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &up, const string &outFlNam, const int &nThr)
 Simple constructor with a prior index and output file name. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Simple constructor with a prior index, replication and output file name. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, const int &nThr)
 Missing data constructor. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &up, const int &nThr)
 Missing data constructor with a prior index. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &low, RanIndex &up, const int &nThr)
 Missing data constructor with a prior index and replication. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, const string &outFlNam, const int &nThr)
 Missing data constructor with output file name. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr)
 Missing data constructor with a prior index and output file name. More...
 
 BetaGrpFt (const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Missing data constructor with a prior index, replication and output file name. More...
 
 BetaGrpFt (const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Nmul, const double &rSqMax, RanIndex &up, const string &outFlNam, const int &nThr)
 Selection constructor. More...
 
 BetaGrpFt (const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Nmul, const double &rSqMax, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Selection constructor with replication. More...
 
 BetaGrpFt (const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr)
 Selection constructor with missing predictor data. More...
 
 BetaGrpFt (const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
 Selection constructor with missing predictor data and replication. More...
 
virtual ~BetaGrpFt ()
 Destructor.
 
 BetaGrpFt (const BetaGrpFt &mG)
 Copy constructor. More...
 
BetaGrpFtoperator= (const BetaGrpFt &mG)
 Assignment operator. More...
 
virtual const gsl_matrix * fMat () const
 Access to the fitted value matrix. More...
 
void dump ()
 Dump to a file. More...
 
double lnOddsRat (const Grp &y, const SigmaI &SigI, const size_t i) const
 Log-odds ratio. More...
 
void update (const Grp &dat, const SigmaI &SigIm)
 Gaussian likelihood, improper prior. More...
 
void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm)
 Student- \(t\) likelihood, improper prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp)
 Student- \(t\) likelihood, 0-mean Gaussian prior. More...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
 Gaussian likelihood, 0-mean Student- \(t\) prior. More...
 
virtual 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...
 
virtual void update (const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
 Gaussian likelihood, non-zero mean Gaussian prior. More...
 
virtual 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...
 
virtual 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...
 
virtual 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 Grp
virtual ~Grp ()
 Destructor.
 
virtual void save ()
 Save to pre-specified file. More...
 
virtual void save (const string &outFlNam)
 Save to file. More...
 
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...
 
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...
 
const MVnormoperator[] (const size_t i) const
 Subscript operator. More...
 
MVnormoperator[] (const size_t i)
 Subscript operator. More...
 
virtual MuGrp mean (RanIndex &grp)
 Group mean. More...
 
virtual const MuGrp mean (RanIndex &grp) const
 Group mean. More...
 
virtual MuGrp mean (RanIndex &grp, const Qgrp &q)
 Group weighted mean. More...
 
virtual const MuGrp mean (RanIndex &grp, const Qgrp &q) const
 Group weighted mean. More...
 
void center ()
 Center the value matrix. More...
 

Protected Member Functions

void _updateFitted ()
 Update fitted values.
 
void _ldToss (const gsl_vector *var, const gsl_permutation *prm, const double &rSqMax, const size_t &Nsel, const size_t &Npck, vector< vector< size_t > > &idx, vector< vector< size_t > > &rLd, gsl_matrix *Xpck)
 Testing candidates for correlation. More...
 
double _MGkernel (const Grp &dat, const SigmaI &SigI) const
 Gaussian kernel. More...
 
double _MGkernel (const Grp &dat, const SigmaI &SigI, const size_t &prInd) const
 Gaussian kernel dropping one predictor. More...
 
double _MGkernel (const Grp &dat, const SigmaI &SigIe, const SigmaI &SigIpr, const size_t &prInd)
 Gaussian kernel adding one predictor. More...
 
- Protected Member Functions inherited from BetaGrpFt
void _rankPred (const gsl_matrix *y, const SigmaI &SigI, gsl_vector *XtX, gsl_permutation *prm)
 Rank predictors. More...
 
void _rankPred (const gsl_matrix *y, const SigmaI &SigI, const double &absLab, gsl_vector *XtX, gsl_permutation *prm)
 Rank predictors with missing data. More...
 
void _ldToss (const gsl_vector *var, const gsl_permutation *prm, const double &rSqMax, const size_t &Npck, vector< vector< size_t > > &idx, vector< vector< size_t > > &rLd, gsl_matrix *Xpck)
 Testing candidates for correlation. More...
 
- Protected Member Functions inherited from Grp
 Grp ()
 

Protected Attributes

gsl_matrix * _selB
 Matrix of selected predictors. More...
 
gsl_matrix * _tmpXb
 \( \boldsymbol{\mathrm{x}}_{\cdot l}\boldsymbol{\beta}_{l \cdot}\) matrix for the candidate dropped/added element

 
- Protected Attributes inherited from BetaGrpFt
vector< vector< double > > _fittedEach
 Partial fitted value matrices. More...
 
gsl_matrix * _fittedAll
 Matrix of fitted values. More...
 
gsl_matrix * _valueSum
 Sample storage matrix. More...
 
gsl_matrix * _Xmat
 Predictor matrix. More...
 
int _nThr
 Number of threads.
 
double _numSaves
 Number of saves. 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.
 

Friends

void RanIndexVS::update (const Grp &, const SigmaI &, BetaGrpBVSR *, const SigmaI &)
 

Detailed Description

Bayesian variable selection regression.

A multivariate implementation of Bayesian variable selection regression (BVSR), together with the RanIndexVS class. The model is similar to that described in [guan11] , but unlike their method a pre-selection of predictors based on a first-pass single-predictor regression is made. The user has control over the number of predictors to choose, and the cut-off for correlation among predictors (which arises as linkage disequilibrium in SNP regressions). This numebr is expressed as a multiple of genetic sample size. Once the pre-selected group of predictors is formed, variable selection is performed within the smaller group. Predictors discarded for correlation with picked variables are assigned the same probability of retention in the model as their corresponding picked predictors. Rao-Blackwellised values of regression coefficients are saved by the dump() function.

Warning
This class is experimental and has not been extensively tested

Constructor & Destructor Documentation

◆ BetaGrpBVSR() [1/4]

BetaGrpBVSR::BetaGrpBVSR ( const Grp y,
const SigmaI SigI,
const string &  predFlNam,
const double &  Nmul,
const double &  rSqMax,
RanIndex up,
const string &  outFlNam,
const int &  nThr 
)

Basic constructor.

Constructor with no missing data in predictors and no replication. Performs the initial pre-selection of predictors.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]string&preddictor file name
[in]double&number of predictors to keep, in multiples of sample size
[in]double&\( r^2 \) cut-off for predictor correlation
[in]RanIndex&prior index
[in]string&output file name
[in]int&number of threads

◆ BetaGrpBVSR() [2/4]

BetaGrpBVSR::BetaGrpBVSR ( const Grp y,
const SigmaI SigI,
const string &  predFlNam,
const double &  Nmul,
const double &  rSqMax,
RanIndex low,
RanIndex up,
const string &  outFlNam,
const int &  nThr 
)

Basic constructor with replication.

Constructor with no missing data in predictors and replication. A RanIndex index is used instead of a design matrix. Performs the initial pre-selection of predictors.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]string&preddictor file name
[in]double&number of predictors to keep, in multiples of sample size
[in]double&\( r^2 \) cut-off for predictor correlation
[in]RanIndex&replicate (data) index
[in]RanIndex&prior index
[in]string&output file name
[in]int&number of threads

◆ BetaGrpBVSR() [3/4]

BetaGrpBVSR::BetaGrpBVSR ( const Grp y,
const SigmaI SigI,
const string &  predFlNam,
const double &  Nmul,
const double &  rSqMax,
const double &  absLab,
RanIndex up,
const string &  outFlNam,
const int &  nThr 
)

Basic constructor with missing data.

Constructor with missing data in predictors and no replication. Missing data in the selected predictors are filled in using mean imputation. Performs the initial pre-selection of predictors.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]string&preddictor file name
[in]double&number of predictors to keep, in multiples of sample size
[in]double&\( r^2 \) cut-off for predictor correlation
[in]double&missing data label
[in]RanIndex&prior index
[in]string&output file name
[in]int&number of threads

◆ BetaGrpBVSR() [4/4]

BetaGrpBVSR::BetaGrpBVSR ( const Grp y,
const SigmaI SigI,
const string &  predFlNam,
const double &  Nmul,
const double &  rSqMax,
const double &  absLab,
RanIndex low,
RanIndex up,
const string &  outFlNam,
const int &  nThr 
)

Basic constructor with replication and missing data.

Constructor with missing data in predictors and replication. Missing data in the selected predictors are filled in using mean imputation. A RanIndex index is used instead of a design matrix. Performs the initial pre-selection of predictors.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]string&preddictor file name
[in]double&number of predictors to keep, in multiples of sample size
[in]double&\( r^2 \) cut-off for predictor correlation
[in]double&missing data label
[in]RanIndex&replicate (data) index
[in]RanIndex&prior index
[in]string&output file name
[in]int&number of threads

Member Function Documentation

◆ _ldToss()

void BetaGrpBVSR::_ldToss ( const gsl_vector *  var,
const gsl_permutation *  prm,
const double &  rSqMax,
const size_t &  Nsel,
const size_t &  Npck,
vector< vector< size_t > > &  idx,
vector< vector< size_t > > &  rLd,
gsl_matrix *  Xpck 
)
protected

Testing candidates for correlation.

Goes through the list of "top" predictors and eliminates lower-ranked candidates correlated with them. If any candidates are eliminated, the list of top predictors is augmented with predictors previously discarded. The identity of the predictors eliminated for correlation is saved. The correlation among predictors arises, for example, when estimating SNP effect in genetics (GWAS).

Warning
Tested only superficially
Parameters
[in]gsl_vector*\( \left( \boldsymbol{x}^T\boldsymbol{x} \right)^{-1} \)
[in]gsl_permutation*predictor ranks
[in]double&\( r^2 \) cut-off
[in]size_t&number of predictors to pick
[out]vector<vector<size_t> >& index of picked predictors
[out]vector<vector<size_t> >& index relating dropped correlated predictors to their group-defining predictor
[out]gsl_matrix*matrix of picked predictor values

◆ _MGkernel() [1/3]

double BetaGrpBVSR::_MGkernel ( const Grp dat,
const SigmaI SigI 
) const
protectedvirtual

Gaussian kernel.

Calculates the multivariate Gaussian kernel value for all regression coefficients in the model.

Parameters
[in]Grp&data
[in]SigmaI&inverse-covariance
Returns
double kernel value

Reimplemented from BetaGrpFt.

◆ _MGkernel() [2/3]

double BetaGrpBVSR::_MGkernel ( const Grp dat,
const SigmaI SigI,
const size_t &  prInd 
) const
protectedvirtual

Gaussian kernel dropping one predictor.

Calculates the multivariate Gaussian kernel value for all regression coefficients in the model, except for the one indicated.

Parameters
[in]Grp&data
[in]SigmaI&inverse-covariance
[in]size_t&index of the dropped predictor
Returns
double kernel value

Reimplemented from BetaGrpFt.

◆ _MGkernel() [3/3]

double BetaGrpBVSR::_MGkernel ( const Grp dat,
const SigmaI SigIe,
const SigmaI SigIpr,
const size_t &  prInd 
)
protected

Gaussian kernel adding one predictor.

Calculates the multivariate Gaussian kernel value for all regression coefficients in the model, plus the indicated extra predictor with a Gaussian zero-mean prior.

Parameters
[in]Grp&data
[in]SigmaI&data inverse-covariance
[in]SigmaI&prior inverse-covariance
[in]size_t&index of the dropped predictor
Returns
double kernel value

◆ save()

void BetaGrpBVSR::save ( const SigmaI SigI)
virtual

Regression value store.

Stores \(t\)-statistic values for each trait and pre-selected (i.e. whether or not currently in the model) regression coefficient in a variable to subsequently save to a file by dump().

Parameters
[in]SigmaI&data inverse-covariance

Reimplemented from BetaGrpFt.

Member Data Documentation

◆ _selB

gsl_matrix* BetaGrpBVSR::_selB
protected

Matrix of selected predictors.

Contains only the predictors currently in the model.


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