MuGen
Multitrait genetics
MuGen.h
Go to the documentation of this file.
1 /*
2  * libMuGen.h
3  * libMuGen
4  *
5  * Copyright (c) 2015 Anthony J. Greenberg
6  *
7  * This file is part of the MuGen library.
8  *
9  * MuGen is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * MuGen is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with MuGen. If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23 
25 
34 #ifndef LIBMUGEN_H
35 #define LIBMUGEN_H
36 #include <gsl/gsl_matrix.h>
37 #include <gsl/gsl_vector.h>
38 #include <gsl/gsl_rng.h>
39 #include <gsl/gsl_permutation.h>
40 #include <vector>
41 #include <string>
42 #include <list>
43 
44 using std::vector;
45 using std::list;
46 using std::string;
47 
48 class MVnorm;
49 class MVnormMu;
50 class MVnormMuPEX;
51 class MVnormBetaPEX;
52 class MVnormMuMiss;
53 class MVnormBeta;
54 class MVnormBetaMiss;
55 class MVnormBetaFt;
56 class MVnormBetaSc;
57 class MVnormMuBlk;
58 class MVnormBetaBlk;
59 class MVnormBetaFtBlk;
60 class RanIndex;
61 class RanIndexVS;
62 class Apex;
63 class Grp;
64 class MuGrp;
65 class MuGrpPEX;
66 class BetaGrpPEX;
67 class MuGrpMiss;
68 class MuGrpEE;
69 class MuGrpEEmiss;
70 class BetaGrpSnp;
71 class BetaGrpSnpCV;
72 class BetaGrpPSR;
73 class BetaGrpSnpMiss;
74 class BetaGrpSnpMissCV;
75 class BetaGrpPSRmiss;
76 class BetaGrpFt;
77 class BetaGrpSc;
78 class BetaGrpPC;
79 class BetaGrpPCpex;
80 class BetaGrpBVSR;
81 class MuBlk;
82 class BetaBlk;
83 class SigmaI;
84 class SigmaIblk;
85 class SigmaIpex;
86 class Qgrp;
87 class QgrpPEX;
88 class MixP;
89 
110 void MVgauss(const gsl_vector*, const gsl_matrix*, const gsl_rng*, gsl_vector*);
111 
123 void Wishart(const gsl_matrix*, const int&, const gsl_rng*, gsl_matrix*);
124 void Wishart(const gsl_matrix*, const size_t&, const gsl_rng*, gsl_matrix*);
137 size_t rtgeom(const double&, const size_t&, const gsl_rng*);
155 double mhl(const gsl_vector *beta, const gsl_matrix *SigI);
167 void colCenter(gsl_matrix *inplace);
174 void colCenter(const gsl_matrix *source, gsl_matrix *res);
181 void colCenter(gsl_matrix *inplace, const double &absLab);
191 void colCenter(const gsl_matrix *source, gsl_matrix *res, const double &absLab);
198 void vecCenter(gsl_vector *inplace);
205 void vecCenter(const gsl_vector *source, gsl_vector *res);
212 void meanImpute(gsl_matrix *inplace, const double &absLab);
222 void printMat(const gsl_matrix *m);
231 unsigned long long rdtsc();
246 class MVnorm {
247 protected:
253  gsl_vector_view _vec;
254 
256  size_t _d;
257 
262  MVnorm() : _d(0) {};
269  MVnorm(const size_t &d) : _d(d) {};
276  MVnorm(gsl_vector *mn);
286  MVnorm(gsl_vector *mn, const gsl_vector *sd, const gsl_rng *r);
296  MVnorm(gsl_vector *mn, const gsl_matrix *Sig, const gsl_rng *r);
304  MVnorm(gsl_matrix *mn, const size_t &iRw);
315  MVnorm(gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r);
326  MVnorm(gsl_matrix *mn, const size_t &iRw, const gsl_matrix *Sig, const gsl_rng *r);
327 
328 public:
336  MVnorm(const MVnorm &);
344  MVnorm & operator=(const MVnorm &);
345 
350  virtual ~MVnorm() {};
351 
368  virtual void update(const Grp &, const SigmaI &, const gsl_rng *) = 0;
376  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const gsl_rng *) = 0;
389  virtual void update(const Grp &, const SigmaI &, const SigmaI &, const gsl_rng *) = 0;
398  virtual void update(const Grp &, const SigmaI &, const double &, const SigmaI &, const gsl_rng *) = 0;
407  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const SigmaI &, const gsl_rng *) = 0;
417  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const double &, const SigmaI &, const gsl_rng *) = 0;
431  virtual void update(const Grp &, const SigmaI &, const Grp &, const SigmaI &, const gsl_rng *) = 0;
441  virtual void update(const Grp &, const SigmaI &, const Grp &, const double &, const SigmaI &, const gsl_rng *) = 0;
451  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const SigmaI &, const gsl_rng *) = 0;
462  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const double &, const SigmaI &, const gsl_rng *) = 0;
465  // end of the update group
466 
482  virtual double mhl(const MVnorm *x, const SigmaI &SigI);
492  virtual double mhl(const MVnorm *x, const SigmaI &SigI) const;
502  virtual double mhl(const gsl_vector *x, const SigmaI &SigI);
512  virtual double mhl(const gsl_vector *x, const SigmaI &SigI) const;
521  virtual double mhl(const SigmaI &SigI); // distance from 0
530  virtual double mhl(const SigmaI &SigI) const; // distance from 0
545  double density(const gsl_vector *theta, const SigmaI &SigI);
555  double density(const gsl_vector *theta, const SigmaI &SigI) const;
563  double density(const MVnorm *theta, const SigmaI &SigI);
573  double density(const MVnorm *theta, const SigmaI &SigI) const;
584  void save(const string &fileNam, const char *how = "a");
592  void save(FILE *fileStr);
593 
602  double operator[](const size_t i) const{return gsl_vector_get(&_vec.vector, i); };
611  void valSet(const size_t i, const double x){gsl_vector_set(&_vec.vector, i, x); };
618  const gsl_vector *getVec() const{return &_vec.vector;};
624  size_t len() const{return _d; };
631  virtual size_t nMissP() const{return 0; };
639  virtual const vector<size_t> getMisPhen() const{ return vector<size_t>(0); };
647  virtual const vector<size_t> *down() const{return 0; };
655  virtual const size_t *up() const{return 0; };
663  virtual double scalePar() const {return 1.0; };
664 };
665 
673 class MVnormMu : public MVnorm {
674 protected:
681  const vector<size_t> *_lowLevel;
682 
688  const size_t *_upLevel;
689 
690 public:
696  MVnormMu();
703  MVnormMu(const size_t &d) : MVnorm(d) {};
713  MVnormMu(const size_t &d, const vector<size_t> &low, const size_t &up);
723  MVnormMu(gsl_vector *mn, const vector<size_t> &low, const size_t &up);
732  MVnormMu(gsl_vector *mn, const size_t &up);
741  MVnormMu(gsl_matrix *mn, const size_t &iRw);
751  MVnormMu(gsl_matrix *mn, const size_t &iRw, const vector<size_t> &low);
762  MVnormMu(gsl_matrix *mn, const size_t &iRw, const vector<size_t> &low, const size_t &up);
772  MVnormMu(gsl_matrix *mn, const size_t &iRw, const size_t &up);
784  MVnormMu(gsl_vector *mn, const gsl_vector *sd, const gsl_rng *r, const vector<size_t> &low, const size_t &up);
796  MVnormMu(gsl_vector *mn, const gsl_matrix *Sig, const gsl_rng *r, const vector<size_t> &low, const size_t &up);
809  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);
822  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);
823 
831  MVnormMu(const MVnormMu &);
841  MVnormMu & operator=(const MVnormMu &);
842 
846  virtual ~MVnormMu();
847 
848  // improper prior methods
849  virtual void update(const Grp &dat, const SigmaI &SigIm, const gsl_rng *r);
850  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const gsl_rng *r);
851  // 0-mean prior methods
852  virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
853  virtual void update(const Grp &dat, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
854  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
855  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
856  // non-zero mean prior methods
857  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
858  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
859  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
860  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);
861 
862  virtual size_t nMissP() const{return 0; };
863  virtual const vector<size_t> getMisPhen() const{ return vector<size_t>(0); };
871  const vector<size_t> *down() const{return _lowLevel; };
879  const size_t *up() const{return _upLevel; };
880 };
881 
887 class MVnormMuPEX : public MVnormMu {
888 protected:
900  gsl_matrix_view _tSAprod;
901 
902 public:
906  MVnormMuPEX() : MVnormMu() {_A = 0; };
917  MVnormMuPEX(gsl_matrix *mn, const size_t &iRw, const vector<size_t> &low, const size_t &up, Apex &A, gsl_matrix *tSigIAt);
930  MVnormMuPEX(gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r, const vector<size_t> &low, const size_t &up, Apex &A, gsl_matrix *tSigIAt);
931 
937  MVnormMuPEX(const MVnormMuPEX &mu);
947  MVnormMuPEX & operator=(const MVnormMuPEX &mu);
948 
950  virtual ~MVnormMuPEX() {};
951 
952  virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
953  virtual void update(const Grp &dat, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
954  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
955  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
956 
957  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
958  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
959  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
960  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);
961 };
962 
968 class MVnormBetaPEX : public MVnormMuPEX {
969 protected:
975  gsl_vector_view _X;
981  double _scale;
983  size_t _N;
989  gsl_matrix_view _fitted;
990 
991 public:
1011  MVnormBetaPEX(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw, Apex &A, gsl_matrix *tSigIAt);
1027  MVnormBetaPEX(const size_t &d, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const size_t &up, gsl_matrix *bet, const size_t &iRw, Apex &A, gsl_matrix *tSigIAt);
1028 
1034  MVnormBetaPEX(const MVnormBetaPEX &bet);
1044  MVnormBetaPEX & operator=(const MVnormBetaPEX &bet);
1045 
1048 
1049  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
1050  void update(const Grp &dat, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1051  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
1052  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1053 
1054  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1055  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1056  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1057  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1058 };
1059 
1065 class MVnormMuMiss : public MVnormMu {
1066 protected:
1072  vector<size_t> _misPhenInd;
1078  size_t _myInd;
1079 
1080 public:
1090  MVnormMuMiss(const size_t &d) : MVnormMu(d) {};
1099  MVnormMuMiss(const size_t &d, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1109  MVnormMuMiss(gsl_vector *mn, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1117  MVnormMuMiss(gsl_vector *mn, const size_t &up, const vector<size_t> &mis);
1129  MVnormMuMiss(gsl_vector *mn, const gsl_vector *sd, const gsl_rng *r, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1141  MVnormMuMiss(gsl_vector *mn, const gsl_matrix *Sig, const gsl_rng *r, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1151  MVnormMuMiss(gsl_matrix *mn, const size_t &iRw, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1160  MVnormMuMiss(gsl_matrix *mn, const size_t &iRw, const size_t &up, const vector<size_t> &mis);
1173  MVnormMuMiss(gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1186  MVnormMuMiss(gsl_matrix *mn, const size_t &iRw, const gsl_matrix *Sig, const gsl_rng *r, const vector<size_t> &low, const size_t &up, const vector<size_t> &mis);
1187 
1193  MVnormMuMiss(const MVnormMuMiss &); // copy constructor
1204 
1207 
1216  void update(const Grp &mu, const SigmaI &SigIm, const gsl_rng *r);
1226  void update(const Grp &mu, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
1227 
1234  size_t nMissP() const{return _misPhenInd.size(); };
1242  const vector<size_t> getMisPhen() const{ return _misPhenInd; };
1243 };
1244 
1250 class MVnormBeta : public MVnorm {
1251 protected:
1257  gsl_vector_view _X;
1263  double _scale;
1265  size_t _N;
1266 
1272  const size_t *_upLevel; // index into the vector of priors
1273 
1274 public:
1276  MVnormBeta();
1282  MVnormBeta(const size_t d);
1283 
1295  MVnormBeta(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, const gsl_rng *r);
1308  MVnormBeta(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, const gsl_rng *r, const size_t &up);
1309 
1321  MVnormBeta(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, const gsl_rng *r);
1334  MVnormBeta(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, const gsl_rng *r, const size_t &up);
1335 
1349  MVnormBeta(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw);
1365  MVnormBeta(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw);
1366 
1380  MVnormBeta(const Grp &resp, gsl_matrix *pred, const size_t &iCl, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw);
1396  MVnormBeta(const Grp &resp, gsl_matrix *pred, const size_t &iCl, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw);
1397 
1408  MVnormBeta(gsl_matrix *pred, const size_t &iCl, gsl_matrix *bet, const size_t &iRw);
1421  MVnormBeta(gsl_matrix *pred, const size_t &iCl, const size_t &up, gsl_matrix *bet, const size_t &iRw);
1422 
1428  MVnormBeta(const MVnormBeta &);
1436  MVnormBeta & operator=(const MVnormBeta &);
1437 
1439  virtual ~MVnormBeta(); // destructor
1440 
1441  // improper prior methods
1442  virtual void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r);
1443  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const gsl_rng *r);
1444  // 0-mean prior methods
1445  virtual void update(const Grp &dat, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r); // G data, G prior
1446  virtual void update(const Grp &dat, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r); // G data, t prior
1447  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r); // t data, G prior
1448  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r); // t data, t prior
1449  // non-zero mean prrior methods
1450  virtual void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r); // G data, G prior
1451  virtual void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r); // G data, t prior
1452  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r); // t data, G prior
1453  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r); // t data, t prior
1454 
1455  const size_t *up() const{return _upLevel; };
1456  double scalePar() const {return _scale; };
1457 };
1458 
1464 class MVnormBetaFt: public MVnormBeta {
1465 protected:
1471  gsl_matrix_view _fitted;
1472 
1473 public:
1476 
1491  MVnormBetaFt(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r) : MVnormBeta(b, sd, pred, iCl, r) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1507  MVnormBetaFt(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r, const size_t &up) : MVnormBeta(b, sd, pred, iCl, r, up) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1508 
1523  MVnormBetaFt(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r) : MVnormBeta(b, Sig, pred, iCl, r) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1539  MVnormBetaFt(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r, const size_t &up) : MVnormBeta(b, Sig, pred, iCl, r, up) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1540 
1557  MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, bet, iRw) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1575  MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, up, bet, iRw) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1576 
1592  MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1609  MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, up, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1610 
1627  MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, bet, iRw) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); }; // deprecated
1645  MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, up, bet, iRw) {_fitted = gsl_matrix_submatrix(allFt, begRw, 0, pred->size1, _d); };
1646 
1662  MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1679  MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(resp, pred, iCl, Sig, r, up, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1680 
1693  MVnormBetaFt(gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(pred, iCl, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1707  MVnormBetaFt(gsl_matrix *pred, const size_t &iCl, vector<double> &eaFt, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBeta(pred, iCl, up, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d); };
1708 
1714  MVnormBetaFt(const MVnormBetaFt &);
1722  MVnormBetaFt & operator=(const MVnormBetaFt &);
1723 
1725  virtual ~MVnormBetaFt() {};
1726 
1727  // update() methods
1728  // Gaussian model, improper prior (for "fixed effect" regression)
1729  void update(const Grp &resp, const SigmaI &SigIb, const gsl_rng *r);
1730  // Student-t model, improper prior (for "fixed effect" regression). To use for replicate-level covariate regression
1731  void update(const Grp &resp, const Qgrp &q, const SigmaI &SigIb, const gsl_rng *r);
1732 
1733  // Gaussian model, 0-mean Gaussian prior
1734  void update(const Grp &resp, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
1735  // Gaussian model, 0-mean Student-t prior
1736  void update(const Grp &resp, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1737  // Student-t model, 0-mean Gaussian prior
1738  void update(const Grp &resp, const Qgrp &q, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
1739  // Student-t model, 0-mean Student-t prior
1740  void update(const Grp &resp, const Qgrp &q, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1741 
1742  // Gaussian model, Gaussian prior
1743  void update(const Grp &resp, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1744  // Gaussian model, Student-t prior
1745  void update(const Grp &resp, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1746  // Student-t model, Gaussian prior
1747  void update(const Grp &resp, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1748  // Student-t model, Student-t prior
1749  void update(const Grp &resp, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1750 
1751 };
1757 class MVnormMuBlk : public MVnorm {
1758 protected:
1764  const size_t *_upLevel;
1770  const vector< size_t > *_blkStart;
1776  vector< gsl_vector_view > _eachVec;
1783  const vector< vector<size_t> > *_eachLL;
1784 
1785 public:
1798  MVnormMuBlk(gsl_matrix *mn, const size_t &iRw, const vector<size_t> &blkStart, const size_t &up);
1812  MVnormMuBlk(gsl_matrix *mn, const size_t &iRw, const gsl_vector *sd, const gsl_rng *r, const vector<size_t> &blkStart, const vector< vector<size_t> > &eachLL, const size_t &up);
1813 
1815  virtual ~MVnormMuBlk() {};
1816 
1817  const size_t *up() const{return _upLevel; };
1818 
1819  void update(const Grp &dat, const SigmaI &SigIm, const gsl_rng *r);
1820  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const gsl_rng *r);
1821  // 0-mean prior methods
1822  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
1823  void update(const Grp &dat, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1824  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r);
1825  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1826  // non-zero mean prior methods
1827  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1828  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1829  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1830  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1831 };
1832 
1838 class MVnormBetaBlk : public MVnorm {
1839 protected:
1845  const vector< size_t > *_blkStart;
1851  vector< gsl_vector_view > _eachVec;
1857  vector< gsl_vector_view > _X;
1863  vector<double> _scale;
1864 
1870  const size_t *_upLevel;
1871 
1872 
1873 public:
1894  MVnormBetaBlk(const Grp &resp, gsl_matrix *pred, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw);
1910  MVnormBetaBlk(const Grp &resp, gsl_matrix *pred, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw);
1925  MVnormBetaBlk(const gsl_matrix *resp, gsl_matrix *pred, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw);
1941  MVnormBetaBlk(const gsl_matrix *resp, gsl_matrix *pred, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw);
1942 
1944  virtual ~MVnormBetaBlk() {};
1945 
1946  const size_t *up() const{return _upLevel; };
1947 
1948  virtual void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r);
1949  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const gsl_rng *r);
1950  // 0-mean prior methods
1951  virtual void update(const Grp &dat, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
1952  virtual void update(const Grp &dat, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1953  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
1954  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1955  // non-zero mean prior methods
1956  virtual void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1957  virtual void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1958  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
1959  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
1960 };
1961 
1969 protected:
1975  gsl_matrix_view _fitted;
1976 
1977 public:
1999  MVnormBetaFtBlk(const Grp &resp, gsl_matrix *pred, vector<double> &eaFt, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBetaBlk(resp, pred, iCl, Sig, blkStart, r, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d);};
2016  MVnormBetaFtBlk(const Grp &resp, gsl_matrix *pred, vector<double> &eaFt, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBetaBlk(resp, pred, iCl, Sig, blkStart, r, up, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d);};
2032  MVnormBetaFtBlk(const gsl_matrix *resp, gsl_matrix *pred, vector<double> &eaFt, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw) : MVnormBetaBlk(resp, pred, iCl, Sig, blkStart, r, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d);};
2049  MVnormBetaFtBlk(const gsl_matrix *resp, gsl_matrix *pred, vector<double> &eaFt, const vector<size_t> &iCl, const gsl_matrix *Sig, const vector<size_t> &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw) : MVnormBetaBlk(resp, pred, iCl, Sig, blkStart, r, up, bet, iRw) {_fitted = gsl_matrix_view_array(eaFt.data(), pred->size1, _d);};
2050 
2053 
2054  void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r);
2055  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const gsl_rng *r);
2056  // 0-mean prior methods
2057  void update(const Grp &dat, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
2058  void update(const Grp &dat, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
2059  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const SigmaI &SigIp, const gsl_rng *r);
2060  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
2061  // non-zero mean prior methods
2062  void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
2063  void update(const Grp &dat, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
2064  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const SigmaI &SigIp, const gsl_rng *r);
2065  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIb, const Grp &muPr, const double &qPr, const SigmaI &SigIp, const gsl_rng *r);
2066 
2067 };
2069 // end of lineLoc group
2084 class RanIndex {
2085 
2086 protected:
2093  vector< vector<size_t> > _idx;
2099  vector<size_t> _vecInd; // vector that has the upper-level element IDs for each lower-level instance
2105  gsl_rng *_r;
2106 
2107 public:
2113  RanIndex();
2123  RanIndex(const gsl_vector_int *lInd, const size_t &Ntot, const size_t &Nup);
2131  RanIndex(const size_t &Ntot);
2138  RanIndex(const size_t &Ntot, const size_t &Nup);
2148  RanIndex(const size_t &Ntot, const size_t &Nup, const string &fileNam);
2158  RanIndex(const size_t &Ntot, const size_t &Nup, FILE *fileStr);
2159 
2161  virtual ~RanIndex() {gsl_rng_free(_r);};
2162 
2171  const vector<size_t> &operator[](const size_t i) const{return _idx[i];};
2180  vector<size_t> &operator[](const size_t i) {return _idx[i];};
2181 
2189  const vector<size_t> &getIndVec() const{return _vecInd; };
2197  vector<size_t> &getIndVec() {return _vecInd; };
2198 
2207  const size_t &priorInd(const size_t i) const{return _vecInd[i]; };
2216  size_t &priorInd(const size_t i) {return _vecInd[i]; };
2217 
2225  size_t getNtot() const{return _vecInd.size(); };
2233  size_t getNtot(){return _vecInd.size(); };
2234 
2242  size_t getNgrp() const{return _idx.size(); };
2250  size_t getNgrp(){return _idx.size(); };
2251 
2259  virtual const vector<double> props() const;
2260 
2269  virtual void init(const vector< vector<size_t> > &idx, const vector< vector<size_t> > &rLD);
2279  virtual void save(const Grp &y, const BetaGrpBVSR *theta, const SigmaI &SigIe) {};
2289  virtual void save(const Grp &y, const Grp &theta, const SigmaI &SigIe) {};
2295  virtual void dump(){};
2296 
2309  void update(const Grp &theta, const Grp &mu, const vector<SigmaI> &SigI, const MixP &p);
2322  void update(const Grp &theta, const Grp &mu, const SigmaI &SigI, const MixP &p);
2335  virtual void update(const Grp &y, const SigmaI &SigIe, BetaGrpBVSR *theta, const SigmaI &SigIp) {};
2336 
2337 };
2338 
2346 class RanIndexVS : public RanIndex {
2347 
2348 protected:
2355  vector<double> _pep;
2361  vector<bool> _mcmcTrack;
2367  vector< vector<size_t> > _relLD;
2369  size_t _Ntp;
2370 
2376 
2382  vector<bool> _acceptDrop;
2388  vector<bool> _rejectDrop;
2394  vector<bool> _acceptAdd;
2400  vector<bool> _rejectAdd;
2406  vector<bool> _acceptSwap;
2412  vector<bool> _rejectSwap;
2413 
2419  double _numSaves;
2427 
2434  size_t _proposal(const size_t &Ntot, const int &Nmn, const gsl_rng *r); // rank proposal-generating function for Metropolis updating; not clear if it is symmetric so don't use for now
2435 
2436 public:
2438  RanIndexVS();
2444  RanIndexVS(const size_t &Ntot, const string &outFlNam, MixP &pr);
2450  RanIndexVS(const size_t &Ntot, const string &outFlNam);
2451 
2454 
2455  void props(vector<double> &prp) const;
2456 
2466  void save(const Grp &y, const BetaGrpBVSR *theta, const SigmaI &SigIe);
2476  void save(const Grp &y, const Grp &theta, const SigmaI &SigIe);
2482  void dump();
2491  void init(const vector< vector<size_t> > &idx, const vector< vector<size_t> > &rLD); // idx is _idx, rLD is _relLD
2492 
2493  void update(const Grp &y, const SigmaI &SigIe, BetaGrpBVSR *theta, const SigmaI &SigIp);
2494 };
2495 
2505 class Apex {
2506 private:
2511  gsl_matrix *_Amat;
2516  gsl_matrix *_SigIpr;
2521  vector<vector<double> > *_fitEach;
2526  gsl_rng *_r;
2527 
2528 public:
2533  Apex();
2541  Apex(const size_t &d, vector<vector <double> > &fE);
2550  Apex(const double &dV, const size_t &d, vector<vector <double> > &fE);
2558  Apex(const SigmaI &SigI, vector<vector <double> > &fE);
2559 
2561  ~Apex();
2562 
2567  Apex(const Apex &A);
2573  Apex &operator=(const Apex &A);
2574 
2576  gsl_matrix *getMat(){return _Amat; };
2578  const gsl_matrix *getMat() const{return _Amat; };
2586  void setPr(const double &pr);
2587 
2599  void update(const Grp &y, const gsl_matrix *xi, const SigmaI &SigIm);
2612  void update(const Grp &y, const gsl_matrix *xi, const SigmaI &SigIm, const RanIndex &ind);
2626  void update(const Grp &y, const gsl_matrix *xi, const Qgrp &q, const SigmaI &SigIm, const RanIndex &ind);
2627 };
2628 
2649 MuGrp operator+(const Grp &m1, const Grp &m2);
2657 MuGrp operator+(const MuGrp &m1, const Grp &m2);
2665 MuGrp operator+(const Grp &m1, const MuGrp &m2);
2673 MuGrp operator-(const Grp &m1, const Grp &m2);
2681 MuGrp operator-(const MuGrp &m1, const Grp &m2);
2689 MuGrp operator-(const Grp &m1, const MuGrp &m2);
2690 
2705 class Grp {
2706  friend MuGrp operator+(const Grp &m1, const Grp &m2);
2707  friend MuGrp operator+(const MuGrp &m1, const Grp &m2);
2708  friend MuGrp operator+(const Grp &m1, const MuGrp &m2);
2709  friend MuGrp operator-(const Grp &m1, const Grp &m2);
2710  friend MuGrp operator-(const MuGrp &m1, const Grp &m2);
2711  friend MuGrp operator-(const Grp &m1, const MuGrp &m2);
2712  friend class MuGrp;
2713 
2714 protected:
2720  vector<MVnorm *> _theta;
2725  gsl_matrix *_valueMat;
2742  vector<gsl_rng *> _rV;
2743 
2745  string _outFlNam;
2746 
2748  Grp();
2749 
2750 public:
2752  virtual ~Grp();
2753 
2763  virtual void update(const Grp &, const SigmaI &) = 0;
2774  virtual void update(const Grp &, const Qgrp &, const SigmaI &) = 0;
2785  virtual void update(const Grp &, const SigmaI &, const SigmaI &) = 0;
2797  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const SigmaI &) = 0;
2809  virtual void update(const Grp &, const SigmaI &, const Qgrp &, const SigmaI &) = 0;
2822  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Qgrp &, const SigmaI &) = 0;
2836  virtual void update(const Grp &, const SigmaI &, const Grp &, const SigmaI &) = 0;
2851  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const SigmaI &) = 0;
2866  virtual void update(const Grp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &) = 0;
2882  virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &) = 0;
2883 
2888  virtual void save();
2895  virtual void save(const string &outFlNam);
2905  virtual void save(const string &outMuFlNam, const string &outSigFlNam, const SigmaI &SigI);
2913  virtual void save(const SigmaI &SigI) {};
2922  virtual void save(const Grp &y, const SigmaI &SigI) {};
2931  void mhlSave(const string &outFlNam, const SigmaI SigI);
2932 
2938  virtual void dump(){}; // dump to a file in cases where save() saves to a matrix
2939 
2944  const vector<MVnorm *> &dataVec() const{return _theta; };
2951  virtual const gsl_matrix *dMat() const{return _valueMat; };
2958  virtual const gsl_matrix *fMat() const{return _valueMat; };
2959 
2964  const size_t Ndata() const{return _valueMat->size1; };
2969  const size_t phenD() const{return _valueMat->size2; };
2970 
2981  virtual double lnOddsRat(const Grp &y, const SigmaI &SigI, const size_t i) const {return 0.0; };
2982 
2991  const MVnorm * operator[](const size_t i) const{return _theta[i]; };
3000  MVnorm * operator[](const size_t i) {return _theta[i]; };
3001 
3009  virtual MuGrp mean(RanIndex &grp);
3017  virtual const MuGrp mean(RanIndex &grp) const;
3018 
3028  virtual MuGrp mean(RanIndex &grp, const Qgrp &q);
3038  virtual const MuGrp mean(RanIndex &grp, const Qgrp &q) const;
3039 
3045 
3046 };
3047 
3053 class MuGrp : public Grp {
3054  friend MuGrp operator+(const Grp &m1, const Grp &m2);
3055  friend MuGrp operator+(const MuGrp &m1, const Grp &m2);
3056  friend MuGrp operator+(const Grp &m1, const MuGrp &m2);
3057  friend MuGrp operator-(const Grp &m1, const Grp &m2);
3058  friend MuGrp operator-(const MuGrp &m1, const Grp &m2);
3059  friend MuGrp operator-(const Grp &m1, const MuGrp &m2);
3060 protected:
3061 
3062 public:
3064  MuGrp() : Grp(){};
3072  MuGrp(RanIndex &low, const size_t &d);
3083  MuGrp(const string &datFlNam, RanIndex &low, RanIndex &up, const size_t &d); // RanIndex's are not const because I have a pointer to it as a member
3092  MuGrp(const string &datFlNam, RanIndex &up, const size_t &d);
3102  MuGrp(const vector<MVnorm *> &dat, RanIndex &low, RanIndex &up);
3112  MuGrp(const Grp &dat, RanIndex &low, RanIndex &up);
3123  MuGrp(const vector<MVnorm *> &dat, RanIndex &low, RanIndex &up, const string &outFlNam);
3134  MuGrp(const Grp &dat, RanIndex &low, RanIndex &up, const string &outFlNam);
3143  MuGrp(const Grp &dat, RanIndex &low);
3153  MuGrp(const Grp &dat, const Qgrp &q, RanIndex &low);
3160  MuGrp(const gsl_matrix *dat);
3168  MuGrp(const gsl_matrix *dat, RanIndex &low);
3177  MuGrp(const gsl_matrix *dat, const Qgrp &q, RanIndex &low);
3178 
3180  virtual ~MuGrp() {};
3181 
3187  MuGrp(const MuGrp &mG);
3193  MuGrp(const Grp &g);
3199  MuGrp & operator=(const MuGrp &mG);
3200 
3201  // improper prior
3202  virtual void update(const Grp &dat, const SigmaI &SigIm);
3203  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm);
3204  // 0-mean prior
3205  virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
3206  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp);
3207  virtual void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3208  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3209  // non-0-mean prior
3210  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3211  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3212  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3213  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3214 
3215 };
3216 
3223 class MuGrpPEX : public MuGrp {
3224 protected:
3229  gsl_matrix *_adjValMat;
3234  gsl_matrix *_tSigIAt;
3242  vector<vector<double> > _ftA;
3244  int _nThr;
3245 
3251 
3269  void _updateFitted();
3272 public:
3274  MuGrpPEX();
3286  MuGrpPEX(const Grp &dat, RanIndex &low, RanIndex &up, const double &Spr, const int &nThr);
3299  MuGrpPEX(const Grp &dat, RanIndex &low, RanIndex &up, const string outMuFlNam, const double &Spr, const int &nThr);
3300 
3302  ~MuGrpPEX();
3303 
3309  MuGrpPEX(const MuGrpPEX &mGp);
3315  MuGrpPEX &operator=(const MuGrpPEX &mGp);
3316 
3321  const gsl_matrix *fMat() const{return _adjValMat; };
3326  void save();
3333  void save(const string &outFlNam);
3338  void save(const SigmaI &SigI);
3343  Apex &getA(){return _A; };
3348  void setApr(const double &pr){_A.setPr(pr); };
3349 
3350  MuGrp mean(RanIndex &grp);
3351  const MuGrp mean(RanIndex &grp) const;
3352  MuGrp mean(RanIndex &grp, const Qgrp &q);
3353  const MuGrp mean(RanIndex &grp, const Qgrp &q) const;
3354 
3355  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
3356  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp);
3357  void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3358  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3359 
3360  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3361  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3362  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3363  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3364 };
3365 
3370 class MuGrpMiss : public MuGrp {
3371 protected:
3373  vector<size_t> _misInd;
3374 
3375 public:
3377  MuGrpMiss() : MuGrp() {};
3390  MuGrpMiss(const string &datFlNam, const string &misMatFlNam, const string &misVecFlNam, RanIndex &up, const size_t &d);
3391 
3394 
3400  MuGrpMiss(const MuGrpMiss &mG); // copy constructor
3406  MuGrpMiss & operator=(const MuGrpMiss &mG);
3407 
3418  virtual void update(const Grp &mu, const SigmaI &SigIm);
3432  virtual void update(const Grp &mu, const SigmaI &SigIm, const SigmaI &SigIp);
3433 
3434  size_t nMis() const{return _misInd.size();};
3435  size_t nMis(){return _misInd.size();};
3436 };
3437 
3444 class MuGrpEE : public MuGrp {
3445 protected:
3450  gsl_matrix *_errorInvVar;
3455  gsl_matrix *_meanVal;
3460  vector<size_t> _errInd;
3461 
3462 public:
3464  MuGrpEE();
3475  MuGrpEE(const string &datFlNam, const string &varFlNam, const string &indFlNam, RanIndex &up, const size_t &d);
3486  MuGrpEE(const string &datFlNam, const string &varFlNam, const vector<size_t> &varInd, RanIndex &up, const size_t &d);
3487 
3489  ~MuGrpEE();
3490 
3496  MuGrpEE(const MuGrpEE &mG); // copy constructor
3502  MuGrpEE & operator=(const MuGrpEE &mG);
3503 
3514  virtual void update(const Grp &muPr, const SigmaI &SigIm);
3526  virtual void update(const Grp &muPr, const Qgrp &q, const SigmaI &SigIm);
3527 
3528 };
3529 
3534 class MuGrpEEmiss : public MuGrpMiss {
3535 protected:
3540  vector< list<double> > _errorInvVar;
3545  vector< list<double> > _meanVal;
3550  vector< list<size_t> > _missErrMat;
3551 
3552 public:
3567  MuGrpEEmiss(const string &datFlNam, const string &varFlNam, const string &indFlNam, const string &misMatFlNam, const string &misVecFlNam, RanIndex &up, const size_t &d);
3580  MuGrpEEmiss(const string &datFlNam, const string &varFlNam, const vector<size_t> &varInd, const string &misMatFlNam, const string &misVecFlNam, RanIndex &up, const size_t &d);
3581 
3584 
3590  MuGrpEEmiss(const MuGrpEEmiss &mG); // copy constructor
3596  MuGrpEEmiss & operator=(const MuGrpEEmiss &mG);
3597 
3598  void update(const Grp &muPr, const SigmaI &SigIm);
3599  void update(const Grp &muPr, const Qgrp &q, const SigmaI &SigIm);
3600 
3601 };
3602 
3609 class BetaGrpFt : public Grp {
3610 protected:
3616  vector< vector<double> > _fittedEach;
3621  gsl_matrix *_fittedAll;
3626  gsl_matrix *_valueSum;
3631  gsl_matrix *_Xmat;
3633  int _nThr;
3634 
3639  double _numSaves;
3640 
3645  virtual void _updateFitted();
3655  void _rankPred(const gsl_matrix *y, const SigmaI &SigI, gsl_vector *XtX, gsl_permutation *prm);
3666  void _rankPred(const gsl_matrix *y, const SigmaI &SigI, const double &absLab, gsl_vector *XtX, gsl_permutation *prm);
3682  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);
3692  virtual double _MGkernel(const Grp &dat, const SigmaI &SigI) const;
3703  virtual double _MGkernel(const Grp &dat, const SigmaI &SigI, const size_t &prInd) const;
3704 public:
3706  BetaGrpFt();
3717  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const int &nThr);
3728  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &up, const int &nThr);
3741  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const int &nThr);
3753  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const string &outFlNam, const int &nThr);
3765  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &up, const string &outFlNam, const int &nThr);
3779  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr);
3780 
3792  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, const int &nThr);
3804  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &up, const int &nThr);
3818  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &low, RanIndex &up, const int &nThr);
3831  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, const string &outFlNam, const int &nThr);
3844  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr);
3859  BetaGrpFt(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr);
3860 
3880  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);
3901  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);
3922  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);
3944  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);
3945 
3947  virtual ~BetaGrpFt();
3948 
3954  BetaGrpFt(const BetaGrpFt &mG);
3960  BetaGrpFt & operator=(const BetaGrpFt &mG);
3961 
3969  virtual const gsl_matrix *fMat() const{return _fittedAll; };
3977  void save(const SigmaI &SigI);
3978  void dump();
3979 
3980  double lnOddsRat(const Grp &y, const SigmaI &SigI, const size_t i) const;
3981 
3982  // improper prior
3983  void update(const Grp &dat, const SigmaI &SigIm);
3984  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm);
3985  // 0-mean prior
3986  virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
3987  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp);
3988  virtual void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3989  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
3990  // non-0-mean prior
3991  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3992  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
3993  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3994  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
3995 
3996 };
4004 class BetaGrpPEX : virtual public BetaGrpFt {
4005 protected:
4010  gsl_matrix *_tSigIAt;
4018  vector<vector<double> > _ftA;
4024  gsl_matrix *_fittedAllAdj;
4025 
4033  void _finishConstruct(const double &Spr);
4039  void _finishFitted();
4046  void _updateAfitted();
4047 
4054  BetaGrpPEX(const double &Spr) {_finishConstruct(Spr); };
4055 public:
4069  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, up, nThr) {_finishConstruct(Spr); };
4083  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, low, up, nThr) {_finishConstruct(Spr); };
4096  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, up, outFlNam, nThr) {_finishConstruct(Spr); };
4111  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, low, up, outFlNam, nThr) {_finishConstruct(Spr); };
4112 
4125  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &up, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, absLab, up, nThr) {_finishConstruct(Spr); };
4140  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &low, RanIndex &up, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, absLab, low, up, nThr) {_finishConstruct(Spr); };
4154  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, absLab, up, outFlNam, nThr) {_finishConstruct(Spr); };
4170  BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, predFlNam, Npred, absLab, low, up, outFlNam, nThr) {_finishConstruct(Spr); };
4171 
4192  BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, SigI, predFlNam, Npred, Nmul, rSqMax, up, outFlNam, nThr) {_finishConstruct(Spr); };
4214  BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, SigI, predFlNam, Npred, Nmul, rSqMax, low, up, outFlNam, nThr) {_finishConstruct(Spr); };
4236  BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, SigI, predFlNam, Npred, Nmul, rSqMax, absLab, up, outFlNam, nThr) {_finishConstruct(Spr); };
4259  BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(rsp, SigI, predFlNam, Npred, Nmul, rSqMax, absLab, low, up, outFlNam, nThr) {_finishConstruct(Spr); };
4260 
4262  virtual ~BetaGrpPEX();
4263 
4268  virtual const gsl_matrix *fMat() const{return _fittedAllAdj; };
4273  virtual void save();
4280  virtual void save(const string &outFlNam);
4285  virtual void save(const SigmaI &SigI);
4286 
4287  virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
4288  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp);
4289  virtual void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
4290  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
4291 
4292  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
4293  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
4294  virtual void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
4295  virtual void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
4296 };
4297 
4304 class BetaGrpPC : virtual public BetaGrpFt {
4305 protected:
4306 
4307 public:
4321  BetaGrpPC(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, RanIndex &up, const int &nThr);
4335  BetaGrpPC(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const int &nThr);
4350  BetaGrpPC(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, RanIndex &up, const string &outFlNam, const int &nThr);
4365  BetaGrpPC(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr);
4366 
4368  virtual ~BetaGrpPC() {};
4369 
4374  BetaGrpPC(const BetaGrpPC &mG);
4380  BetaGrpPC & operator=(const BetaGrpPC &mG);
4381 
4382  //update methods taken care of by BetaGrpFt
4383 };
4384 
4390 class BetaGrpPCpex : public BetaGrpPC, public BetaGrpPEX {
4391 protected:
4392 
4393 public:
4408  BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const int &nThr) : BetaGrpFt(), BetaGrpPC(rsp, predFlNam, evFlNam, Npred, up, nThr), BetaGrpPEX(Spr) {};
4423  BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const int &nThr) : BetaGrpFt(), BetaGrpPC(rsp, predFlNam, evFlNam, Npred, low, up, nThr), BetaGrpPEX(Spr) {};
4439  BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(), BetaGrpPC(rsp, predFlNam, evFlNam, Npred, up, outFlNam, nThr), BetaGrpPEX(Spr) {};
4455  BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr) : BetaGrpFt(), BetaGrpPC(rsp, predFlNam, evFlNam, Npred, low, up, outFlNam, nThr), BetaGrpPEX(Spr) {};
4456 
4459 
4464  const gsl_matrix *fMat() const{return _fittedAllAdj; };
4465 
4466  void save(){ BetaGrpPEX::save(); };
4467  void save(const string &outFlNam){ BetaGrpPEX::save(outFlNam); };
4468  void save(const SigmaI &SigI){ BetaGrpPEX::save(SigI); };
4469 
4470  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp) { BetaGrpPEX::update(dat, SigIm, SigIp); };
4471  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp){ BetaGrpPEX::update(dat, q, SigIm, SigIp); };
4472  void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp) { BetaGrpPEX::update(dat, SigIm, qPr, SigIp); };
4473  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp){ BetaGrpPEX::update(dat, q, SigIm, qPr, SigIp); };
4474 
4475  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp) { BetaGrpPEX::update(dat, SigIm, muPr, SigIp); };
4476  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp){ BetaGrpPEX::update(dat, q, SigIm, muPr, SigIp); };
4477  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp) { BetaGrpPEX::update(dat, SigIm, muPr, qPr, SigIp); };
4478  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp){ BetaGrpPEX::update(dat, q, SigIm, muPr, qPr, SigIp); };
4479 };
4480 
4489 class BetaGrpSnp : public MuGrp {
4490 protected:
4495  gsl_matrix *_Xmat;
4500  gsl_matrix *_fakeFmat;
4501 
4506  gsl_matrix *_Ystore;
4507 
4509  size_t _Npred;
4511  int _nThr;
4516  double _numSaves;
4521  double _priorVar; // W in Wakefield's (2007) ABF paper
4522 
4524  string _inPredFl;
4525 
4526 public:
4528  BetaGrpSnp();
4541  BetaGrpSnp(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr);
4554  BetaGrpSnp(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr);
4568  BetaGrpSnp(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar);
4582  BetaGrpSnp(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar);
4583 
4585  ~BetaGrpSnp();
4586 
4591  virtual void dump();
4592 
4597  BetaGrpSnp(const BetaGrpSnp &mG);
4603  BetaGrpSnp & operator=(const BetaGrpSnp &mG);
4604 
4609  const gsl_matrix *fMat() const{return _fakeFmat; };
4610 
4621  void update(const Grp &dat, const SigmaI &SigIm);
4622 };
4623 
4632 class BetaGrpSnpCV : public BetaGrpSnp {
4633 protected:
4634 
4635 public:
4650  BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr) : BetaGrpSnp(predFlNam, outFlNam, Ndat, Npred, d, Nthr) {};
4663  BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr) : BetaGrpSnp(predFlNam, outFlNam, low, Npred, d, Nthr) {};
4677  BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar) : BetaGrpSnp(predFlNam, outFlNam, Ndat, Npred, d, Nthr, prVar) {};
4691  BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar) : BetaGrpSnp(predFlNam, outFlNam, low, Npred, d, Nthr, prVar) {};
4692 
4695 
4700  BetaGrpSnpCV(const BetaGrpSnpCV &mG);
4706  BetaGrpSnpCV & operator=(const BetaGrpSnpCV &mG);
4707 
4708  void dump();
4709 
4710 };
4711 
4719 class BetaGrpPSR : public BetaGrpSnp {
4720 protected:
4721 
4722 public:
4737  BetaGrpPSR(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr) : BetaGrpSnp(predFlNam, outFlNam, Ndat, Npred, d, Nthr) {};
4750  BetaGrpPSR(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr) : BetaGrpSnp(predFlNam, outFlNam, low, Npred, d, Nthr) {};
4764  BetaGrpPSR(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar) : BetaGrpSnp(predFlNam, outFlNam, Ndat, Npred, d, Nthr, prVar) {};
4778  BetaGrpPSR(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar) : BetaGrpSnp(predFlNam, outFlNam, low, Npred, d, Nthr, prVar) {};
4779 
4782 
4787  BetaGrpPSR(const BetaGrpPSR &mG);
4793  BetaGrpPSR & operator=(const BetaGrpPSR &mG);
4794 
4795  void dump();
4796 
4797 };
4798 
4807 class BetaGrpSnpMiss : public MuGrp {
4808 protected:
4813  vector< vector<double> > _Xmat;
4814 
4819  gsl_matrix *_fakeFmat;
4820 
4825  gsl_matrix *_Ystore;
4826 
4828  size_t _Npred;
4830  int _nThr;
4835  double _numSaves;
4840  double _absLab;
4845  double _priorVar;
4846 
4848  string _inPredFl;
4849 
4850 public:
4852  BetaGrpSnpMiss();
4866  BetaGrpSnpMiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab);
4880  BetaGrpSnpMiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab);
4895  BetaGrpSnpMiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab);
4910  BetaGrpSnpMiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab);
4911 
4913  ~BetaGrpSnpMiss();
4914 
4919  BetaGrpSnpMiss(const BetaGrpSnpMiss &mG); // copy constructor
4926 
4931  virtual void dump();
4932 
4937  const gsl_matrix *fMat() const{return _fakeFmat; };
4938 
4949  void update(const Grp &dat, const SigmaI &SigIm);
4950 
4951 };
4952 
4962 protected:
4963 
4964 public:
4980  BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, Ndat, Npred, d, Nthr, absLab) {};
4994  BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, low, Npred, d, Nthr, absLab) {};
5009  BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, Ndat, Npred, d, Nthr, prVar, absLab) {};
5024  BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, low, Npred, d, Nthr, prVar, absLab) {};
5025 
5028 
5040 
5041  void dump();
5042 
5043 };
5044 
5053 protected:
5054 
5055 public:
5071  BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, Ndat, Npred, d, Nthr, absLab) {};
5085  BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, low, Npred, d, Nthr, absLab) {};
5100  BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, Ndat, Npred, d, Nthr, prVar, absLab) {};
5115  BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab) : BetaGrpSnpMiss(predFlNam, outFlNam, low, Npred, d, Nthr, prVar, absLab) {};
5116 
5119 
5124  BetaGrpPSRmiss(const BetaGrpPSRmiss &mG);
5131 
5132  void dump();
5133 
5134 };
5135 
5145 class BetaGrpBVSR : public BetaGrpFt {
5146  friend void RanIndexVS::update(const Grp &, const SigmaI &, BetaGrpBVSR *, const SigmaI &);
5147 protected:
5152  gsl_matrix *_selB;
5154  gsl_matrix *_tmpXb;
5155 
5160  void _updateFitted();
5176  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);
5186  double _MGkernel(const Grp &dat, const SigmaI &SigI) const;
5197  double _MGkernel(const Grp &dat, const SigmaI &SigI, const size_t &prInd) const; // MV Gaussian kernel, dropping predictor prInd
5209  double _MGkernel(const Grp &dat, const SigmaI &SigIe, const SigmaI &SigIpr, const size_t &prInd);
5210 public:
5227  BetaGrpBVSR(const Grp &y, const SigmaI &SigI, const string &predFlNam, const double &Nmul, const double &rSqMax, RanIndex &up, const string &outFlNam, const int &nThr);
5243  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);
5259  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); // absLab is the token that signifies missing data
5276  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);
5277 
5279  ~BetaGrpBVSR();
5280 
5287  void save(const SigmaI &SigI);
5296  void save(const Grp &y, const SigmaI &SigI);
5297  void dump();
5299  const gsl_matrix *dMat() const{return _selB; };
5300 
5301  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
5302 };
5303 
5309 class MuBlk : public MuGrp {
5310 protected:
5315  vector< size_t > _blkStart;
5320  vector< vector< vector<size_t> > > _blkLow;
5325  gsl_matrix *_expandedVM;
5331  vector<size_t> _shortLevels;
5332 
5334  void _updateExp();
5335 
5340  void _fillIn();
5345  void _fillInUp();
5346 
5347 public:
5349  MuBlk() : MuGrp() {};
5361  MuBlk(const Grp &dat, const string &lowIndFlName, const size_t &Nval, RanIndex &up, const string &blkIndFileNam);
5374  MuBlk(const Grp &dat, const string &lowIndFlName, const size_t &Nval, RanIndex &up, const string &outFlNam, const string &blkIndFileNam);
5375 
5377  ~MuBlk() {gsl_matrix_free(_expandedVM); };
5378 
5380  const gsl_matrix *fMat() const{ return _expandedVM; };
5381 
5382  // improper prior
5383  void update(const Grp &dat, const SigmaI &SigIm);
5384  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm);
5385  // 0-mean prior
5386  void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp);
5387  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp);
5388  void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
5389  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp);
5390  // non-0-mean prior
5391  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
5392  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp);
5393  void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
5394  void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp);
5395 };
5396 
5397 
5403 class BetaBlk : public BetaGrpFt {
5404 
5405 protected:
5410  vector< size_t > _blkStart;
5415  vector< gsl_matrix_view > _eachX;
5420  vector< gsl_matrix_view > _eachB;
5421 
5426  void _updateFitted();
5427 public:
5429  BetaBlk() : BetaGrpFt() {};
5441  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const string &blkIndFileNam, const int &nThr);
5454  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const string &outFlNam, const string &blkIndFileNam, const int &nThr);
5467  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, RanIndex &up, const string &blkIndFileNam, const int &nThr);
5481  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, RanIndex &up, const string &outFlNam, const string &blkIndFileNam, const int &nThr);
5482 
5495  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const double &absLab, const string &blkIndFileNam, const int &nThr);
5509  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const double &absLab, const string &outFlNam, const string &blkIndFileNam, const int &nThr);
5523  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const double &absLab, RanIndex &up, const string &blkIndFileNam, const int &nThr);
5538  BetaBlk(const Grp &dat, const string &predFlName, const size_t &Npred, const double &absLab, RanIndex &up, const string &outFlNam, const string &blkIndFileNam, const int &nThr);
5539 
5541  ~BetaBlk() {};
5542 
5543  // updates handled by BetaGrpFt
5544 };
5545 
5546 // end of the locGrp group
5561 class SigmaI {
5562 protected:
5567  gsl_matrix *_mat;
5572  size_t _d;
5577  double _srDet;
5578 
5583  gsl_matrix *_LamSc;
5585  double _n0;
5586 
5588  string _outFlNam;
5589 
5594  gsl_rng *_r;
5595 
5596 public:
5601  SigmaI();
5609  SigmaI(const size_t &d, const double &invVar);
5618  SigmaI(const size_t &d, const double &invVar, const double &df);
5628  SigmaI(const size_t &d, const double &invVar, const double &df, const string &outFlNam);
5635  SigmaI(const gsl_matrix *mat);
5636 
5647  SigmaI(const gsl_matrix *S, const size_t &d, const size_t &df, const gsl_matrix *LamPr, const double &nu0);
5658  SigmaI(const gsl_matrix *S, const size_t &d, const size_t &df, const double &diagPr, const double &nu0);
5659 
5668  SigmaI(const Grp &dat, const double &prDiag, const double &nu0);
5678  SigmaI(const Grp &dat, const string &outFlNam, const double &prDiag, const double &nu0);
5679 
5684  SigmaI(const SigmaI &);
5690  SigmaI & operator=(const SigmaI &);
5691 
5693  virtual ~SigmaI();
5694 
5703  virtual void update(const Grp &dat);
5713  virtual void update(const Grp &dat, const Grp &mu);
5723  virtual void update(const Grp &dat, const Qgrp &q);
5734  virtual void update(const Grp &dat, const Grp &mu, const Qgrp &q);
5735 
5740  virtual void save(const char *how = "a");
5746  virtual void save(const string &fileNam, const char *how = "a");
5747 
5756  void save(const string &fileNam, const Apex &A, const char *how = "a");
5761  void save(FILE *fileStr) {gsl_matrix_fwrite(fileStr, _mat); };
5766  string getOutFile() const {return _outFlNam; };
5767 
5772  const gsl_matrix *getMat() const{return _mat; };
5773 
5775  void srDetUpdate();
5780  double getSrDet() const {return _srDet; };
5781 
5782 };
5783 
5788 class SigmaIblk : public SigmaI {
5789 protected:
5794  vector< size_t > _blkStart;
5799  vector< gsl_matrix_view > _eachBlk;
5804  vector< gsl_matrix_view > _eachLS; // matrix-view submatrices of the prior
5805 
5806 public:
5808  SigmaIblk();
5818  SigmaIblk(const size_t &d, const double &invVar, const double &df, const string &blkIndFileNam);
5829  SigmaIblk(const size_t &d, const double &invVar, const double &df, const string &blkIndFileNam, const string &outFlNam);
5839  SigmaIblk(const Grp &dat, const string &blkIndFileNam, const double &prDiag, const double &nu0);
5850  SigmaIblk(const Grp &dat, const string &blkIndFileNam, const string &outFlNam, const double &prDiag, const double &nu0);
5851 
5854 
5855  // Gaussian only
5856  void update(const Grp &dat);
5857  void update(const Grp &dat, const Grp &mu);
5858 
5859 };
5860 
5867 class SigmaIpex : public SigmaI {
5868 
5869 protected:
5871  double _alpha;
5872 
5873 public:
5875  SigmaIpex() : _alpha(1.0), SigmaI() {};
5884  SigmaIpex(const size_t &d, const double &invVar, const double &df) : _alpha(1.0), SigmaI(d, invVar, df) {};
5894  SigmaIpex(const size_t &d, const double &invVar, const double &df, const string &outFlNam) : _alpha(1.0), SigmaI(d, invVar, df, outFlNam) {};
5903  SigmaIpex(const Grp &dat, const double &prDiag, const double &nu0) : _alpha(1.0), SigmaI(dat, prDiag, nu0) {};
5913  SigmaIpex(const Grp &dat, const string &outFlNam, const double &prDiag, const double &nu0) : _alpha(1.0), SigmaI(dat, outFlNam, prDiag, nu0) {};
5914 
5917 
5924  void save(const char *how = "a");
5932  void save(const string &fileNam, const char *how = "a");
5933 
5934  void update(const Grp &dat, const Qgrp &q);
5935  void update(const Grp &dat, const Grp &mu, const Qgrp &q);
5936 };
5937 // end of the sigInv group
5956 class Qgrp {
5957 protected:
5959  vector<double> _qVec;
5964  vector<size_t> _presInd;
5966  double _nu;
5968  string _outFile;
5969 
5974  gsl_rng *_r;
5975 
5976 public:
5981  Qgrp() : _nu(3.0), _outFile("notSet") {};
5988  Qgrp(const size_t &N);
5996  Qgrp(const size_t &N, const double &nu);
6005  Qgrp(const size_t &N, const double &nu, const string &misVecFlNam);
6013  Qgrp(const size_t &N, const string &outFileNam);
6022  Qgrp(const size_t &N, const string &outFileNam, const double &nu);
6032  Qgrp(const size_t &N, const string &outFileNam, const double &nu, const string &misVecFlNam);
6033 
6035  virtual ~Qgrp() {};
6036 
6042  double operator[](const size_t i) const{return _qVec[i]; };
6048  double operator[](const size_t i) {return _qVec[i]; };
6049 
6056  virtual double alpha() const {return 1.0; };
6063  virtual double alpha() {return 1.0; };
6064 
6069  size_t size() const {return _qVec.size(); };
6074  size_t size() {return _qVec.size(); };
6075 
6080  void save(const char *how = "a");
6086  void save(const string &fileNam, const char *how = "a");
6087 
6098  virtual void update(const Grp &dat, const Grp &mu, const SigmaI &SigI);
6108  virtual void update(const Grp &dat, const SigmaI &SigI);
6109 
6110 };
6111 
6117 class QgrpPEX : public Qgrp {
6118 protected:
6120  double _alpha;
6121 
6122 public:
6124  QgrpPEX() : _alpha(1.0), Qgrp() {};
6131  QgrpPEX(const size_t &N) : _alpha(1.0), Qgrp(N) {};
6139  QgrpPEX(const size_t &N, const double &nu) : _alpha(1.0), Qgrp(N, nu) {};
6148  QgrpPEX(const size_t &N, const double &nu, const string &misVecFlNam) : _alpha(1.0), Qgrp(N, nu, misVecFlNam) {};
6156  QgrpPEX(const size_t &N, const string &outFileNam) : _alpha(1.0), Qgrp(N, outFileNam) {};
6165  QgrpPEX(const size_t &N, const string &outFileNam, const double &nu) : _alpha(1.0), Qgrp(N, outFileNam, nu) {};
6175  QgrpPEX(const size_t &N, const string &outFileNam, const double &nu, const string &misVecFlNam) : _alpha(1.0), Qgrp(N, outFileNam, nu, misVecFlNam) {};
6176 
6183  double alpha() const {return _alpha; };
6190  double alpha() {return _alpha; };
6191 
6192  void update(const Grp &dat, const Grp &mu, const SigmaI &SigI);
6193  void update(const Grp &dat, const SigmaI &SigI);
6194 };
6195 // end of qGrp
6204 class MixP {
6205 private:
6207  vector<double> _p;
6209  vector<double> _alpha;
6214  gsl_rng *_r;
6215 
6216 public:
6218  MixP();
6225  MixP(const vector<double> &initP) : _p(initP), _alpha(initP.size(), 1.0) {};
6232  MixP(const gsl_vector *initP);
6240  MixP(const vector<double> &initP, const double &a);
6248  MixP(const gsl_vector *initP, const double &a);
6257  MixP(const vector<double> &initP, const double *a, const size_t &len);
6265  MixP(const gsl_vector *initP, const double *a);
6273  MixP(const vector<double> &initP, const vector<double> &a);
6281  MixP(const gsl_vector *initP, const vector<double> &a);
6289  MixP(const RanIndex &ind, const double &a);
6290 
6292  ~MixP() {};
6293 
6298  MixP(const MixP &);
6304  MixP & operator=(const MixP &);
6310  const double &operator[](const size_t i) const{return _p[i]; };
6311 
6320  void update(const RanIndex &Nvec);
6321 
6322 };
6323 
6324 
6325 
6326 
6327 
6328 #endif
RanIndex::update
void update(const Grp &theta, const Grp &mu, const vector< SigmaI > &SigI, const MixP &p)
Update mixture model with multiple covariances.
Definition: MuGen.cpp:4185
MuGrpPEX::MuGrpPEX
MuGrpPEX()
Default constructor.
Definition: MuGen.cpp:6112
Grp::update
virtual void update(const Grp &, const SigmaI &, const Grp &, const SigmaI &)=0
Gaussian likelihood, non-zero mean Gaussian prior.
BetaBlk
Regression with independent blocks of traits.
Definition: MuGen.h:5403
BetaBlk::_eachX
vector< gsl_matrix_view > _eachX
Predictor submatrices.
Definition: MuGen.h:5415
MuGrpPEX::setApr
void setApr(const double &pr)
Set the inverse-prior for the redundant parameter matrix.
Definition: MuGen.h:3348
BetaGrpFt::_rankPred
void _rankPred(const gsl_matrix *y, const SigmaI &SigI, gsl_vector *XtX, gsl_permutation *prm)
Rank predictors.
Definition: MuGen.cpp:8271
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr)
Selection constructor with missing predictor data.
Definition: MuGen.h:4236
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX()
Default constructor.
Definition: MuGen.h:4057
MuGrpEE::operator=
MuGrpEE & operator=(const MuGrpEE &mG)
Assignment operator.
Definition: MuGen.cpp:6737
MuGrpEE::_errInd
vector< size_t > _errInd
Trait index.
Definition: MuGen.h:3460
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r)
Univariate random constructor with vector.
Definition: MuGen.h:1491
SigmaI::getOutFile
string getOutFile() const
Access the output file.
Definition: MuGen.h:5766
SigmaIblk::~SigmaIblk
~SigmaIblk()
Destructor.
Definition: MuGen.h:5853
MVnorm::valSet
void valSet(const size_t i, const double x)
Setting an element to a value.
Definition: MuGen.h:611
RanIndexVS::_rejectDrop
vector< bool > _rejectDrop
Reject a drop.
Definition: MuGen.h:2388
SigmaI::_mat
gsl_matrix * _mat
Inverse-covariance matrix.
Definition: MuGen.h:5567
Grp::update
virtual void update(const Grp &, const SigmaI &, const Qgrp &, const SigmaI &)=0
Gaussian likelihood, 0-mean Student- prior.
BetaGrpPEX::_updateAfitted
void _updateAfitted()
Calculate redundant parameter fitted values.
Definition: MuGen.cpp:8706
Apex::~Apex
~Apex()
Destructor.
Definition: MuGen.cpp:4801
BetaGrpSnp::~BetaGrpSnp
~BetaGrpSnp()
Destructor.
Definition: MuGen.cpp:9458
RanIndex::getIndVec
vector< size_t > & getIndVec()
Retrieve the index vector.
Definition: MuGen.h:2197
MVnorm::scalePar
virtual double scalePar() const
Scale parameter.
Definition: MuGen.h:663
MuGrpEEmiss::_missErrMat
vector< list< size_t > > _missErrMat
Error index.
Definition: MuGen.h:3550
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, RanIndex &up, const string &outFlNam, const int &nThr)
Selection constructor.
Definition: MuGen.h:4192
MVnormMuPEX::_tSAprod
gsl_matrix_view _tSAprod
Pre-computed auxiliary matrix.
Definition: MuGen.h:900
meanImpute
void meanImpute(gsl_matrix *inplace, const double &absLab)
Mean imputation without centering.
Definition: MuGen.cpp:231
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with Grp type response and prior index.
Definition: MuGen.h:1645
QgrpPEX::alpha
double alpha() const
Const access to .
Definition: MuGen.h:6183
MuGrpPEX::mean
MuGrp mean(RanIndex &grp)
Group mean.
Definition: MuGen.cpp:6327
BetaGrpSnpCV::BetaGrpSnpCV
BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr)
Constructor with no replication and -values.
Definition: MuGen.h:4650
MuGrpPEX::getA
Apex & getA()
Access the redundant parameter.
Definition: MuGen.h:3343
MVnorm::len
size_t len() const
Length of the location vector.
Definition: MuGen.h:624
MVnormBetaBlk::update
virtual void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:3274
SigmaI::SigmaI
SigmaI()
Default constructor.
Definition: MuGen.cpp:12867
MVnormMuMiss::getMisPhen
const vector< size_t > getMisPhen() const
Indexes of missing values.
Definition: MuGen.h:1242
MVnormBetaFtBlk::update
void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:3623
MVnormBetaPEX::_X
gsl_vector_view _X
Predictor.
Definition: MuGen.h:975
MuGrpEEmiss::operator=
MuGrpEEmiss & operator=(const MuGrpEEmiss &mG)
Assignment operator.
Definition: MuGen.cpp:6982
Grp::update
virtual void update(const Grp &, const SigmaI &)=0
Gaussian likelihood, improper prior.
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N, const string &outFileNam)
Deterministic size-only constructor with output file name.
Definition: MuGen.h:6156
Qgrp::update
virtual void update(const Grp &dat, const Grp &mu, const SigmaI &SigI)
Update with a mean.
Definition: MuGen.cpp:13768
MuGrpPEX::save
void save()
Save the adjusted values.
Definition: MuGen.cpp:6281
mhl
double mhl(const gsl_vector *beta, const gsl_matrix *SigI)
Mahalanobis distance.
Definition: MuGen.cpp:130
RanIndexVS::_relLD
vector< vector< size_t > > _relLD
Mapping selected to original predictors.
Definition: MuGen.h:2367
MuBlk::fMat
const gsl_matrix * fMat() const
Access to the expanded value matrix.
Definition: MuGen.h:5380
BetaBlk::_updateFitted
void _updateFitted()
Update fitted values.
Definition: MuGen.cpp:12830
MVnormBetaFtBlk::MVnormBetaFtBlk
MVnormBetaFtBlk(const Grp &resp, gsl_matrix *pred, vector< double > &eaFt, const vector< size_t > &iCl, const gsl_matrix *Sig, const vector< size_t > &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Constructor with no prior index.
Definition: MuGen.h:1999
RanIndexVS::_pepOutFlnam
string _pepOutFlnam
PEP output file name.
Definition: MuGen.h:2421
MVnorm::update
virtual void update(const Grp &, const SigmaI &, const SigmaI &, const gsl_rng *)=0
Gaussian likelihood, Gaussian prior.
SigmaI::_r
gsl_rng * _r
Pseudo-random number generator.
Definition: MuGen.h:5594
MuBlk::~MuBlk
~MuBlk()
Destructor.
Definition: MuGen.h:5377
RanIndexVS
BVSR index class.
Definition: MuGen.h:2346
BetaGrpPCpex::save
void save(const SigmaI &SigI)
Save adjusted values with the adjusted covariance matrix.
Definition: MuGen.h:4468
MuBlk::_shortLevels
vector< size_t > _shortLevels
Blocks with few levels.
Definition: MuGen.h:5331
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with Grp type response and prior index.
Definition: MuGen.h:1679
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const double &Spr)
Finishing constructor.
Definition: MuGen.h:4054
BetaGrpPEX::save
virtual void save()
Save adjusted values.
Definition: MuGen.cpp:8766
Grp::_lowLevel
RanIndex * _lowLevel
Lower level index.
Definition: MuGen.h:2731
BetaGrpFt::_updateFitted
virtual void _updateFitted()
Update fitted values.
Definition: MuGen.cpp:8209
Grp::phenD
const size_t phenD() const
Get number of traits.
Definition: MuGen.h:2969
BetaGrpFt::_ldToss
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.
Definition: MuGen.cpp:8363
Grp::operator[]
const MVnorm * operator[](const size_t i) const
Subscript operator.
Definition: MuGen.h:2991
Qgrp::Qgrp
Qgrp()
Default constructor.
Definition: MuGen.h:5981
MuGrpMiss::~MuGrpMiss
~MuGrpMiss()
Destructor.
Definition: MuGen.h:3393
MVnormBeta::_N
size_t _N
Length of the predictor.
Definition: MuGen.h:1265
Grp::operator-
friend MuGrp operator-(const Grp &m1, const Grp &m2)
Subtraction operator.
Definition: MuGen.cpp:5243
SigmaIpex::~SigmaIpex
~SigmaIpex()
Destructor.
Definition: MuGen.h:5916
BetaGrpSnpMissCV::BetaGrpSnpMissCV
BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab)
Constructor with no replication and -values.
Definition: MuGen.h:4980
BetaGrpBVSR::_ldToss
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.
Definition: MuGen.cpp:11293
BetaGrpSnpMiss::_Npred
size_t _Npred
Number of predictors (SNPs)
Definition: MuGen.h:4828
BetaGrpSnpCV::BetaGrpSnpCV
BetaGrpSnpCV()
Default constructor.
Definition: MuGen.h:4637
MuGrpEE
Data with measurement error.
Definition: MuGen.h:3444
Qgrp::size
size_t size()
Length of the weight vector.
Definition: MuGen.h:6074
MuGrp::~MuGrp
virtual ~MuGrp()
Destructor.
Definition: MuGen.h:3180
SigmaI::_n0
double _n0
Prior degrees of freedom.
Definition: MuGen.h:5585
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, gsl_matrix *bet, const size_t &iRw)
Deterministic constructor.
Definition: MuGen.h:1693
Grp::save
virtual void save(const SigmaI &SigI)
Save with inverse-covariance.
Definition: MuGen.h:2913
MVnormMuPEX::~MVnormMuPEX
virtual ~MVnormMuPEX()
Destructor.
Definition: MuGen.h:950
RanIndexVS::_mcmcPutFlNam
string _mcmcPutFlNam
Accept/reject file name.
Definition: MuGen.h:2426
MVnormMuBlk::update
void update(const Grp &dat, const SigmaI &SigIm, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:2664
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const int &nThr)
Simple constructor with a prior index.
Definition: MuGen.h:4069
MVnormBeta
Generic regression.
Definition: MuGen.h:1250
BetaGrpSnp::_numSaves
double _numSaves
Number of saves.
Definition: MuGen.h:4516
RanIndexVS::_acceptSwap
vector< bool > _acceptSwap
Accept a swap.
Definition: MuGen.h:2406
BetaGrpPCpex::fMat
const gsl_matrix * fMat() const
Access adjusted fitted value matrix.
Definition: MuGen.h:4464
MuGrpMiss::operator=
MuGrpMiss & operator=(const MuGrpMiss &mG)
Assignment operator.
Definition: MuGen.cpp:6574
BetaGrpFt::operator=
BetaGrpFt & operator=(const BetaGrpFt &mG)
Assignment operator.
Definition: MuGen.cpp:8166
SigmaI::~SigmaI
virtual ~SigmaI()
Destructor.
Definition: MuGen.cpp:13088
BetaGrpFt::~BetaGrpFt
virtual ~BetaGrpFt()
Destructor.
Definition: MuGen.cpp:8204
MVnormMu::nMissP
virtual size_t nMissP() const
Number of missing values.
Definition: MuGen.h:862
Grp::_outFlNam
string _outFlNam
Name of the output file.
Definition: MuGen.h:2745
MVnorm::getVec
const gsl_vector * getVec() const
Access the location vector.
Definition: MuGen.h:618
MuGrpPEX::update
void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
Gaussian likelihood, 0-mean Gaussian prior.
Definition: MuGen.cpp:6345
MVnormBetaPEX::~MVnormBetaPEX
~MVnormBetaPEX()
Destructor.
Definition: MuGen.h:1047
BetaGrpSnpMiss::~BetaGrpSnpMiss
~BetaGrpSnpMiss()
Destructor.
Definition: MuGen.cpp:10096
MVnormMuBlk::_upLevel
const size_t * _upLevel
Pointer to a row index of the prior.
Definition: MuGen.h:1764
MuGrp::operator-
friend MuGrp operator-(const Grp &m1, const Grp &m2)
Subtraction operator.
Definition: MuGen.cpp:5243
MVnormBetaBlk
Individual vector of regression coefficients with blocks of traits.
Definition: MuGen.h:1838
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
Simple constructor with a prior index, replication and output file name.
Definition: MuGen.h:4111
BetaGrpPEX::fMat
virtual const gsl_matrix * fMat() const
Access adjusted fitted value matrix.
Definition: MuGen.h:4268
BetaGrpBVSR::BetaGrpBVSR
BetaGrpBVSR()
Default constructor.
Definition: MuGen.h:5212
BetaGrpPSR::BetaGrpPSR
BetaGrpPSR(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar)
Constructor with replication and ABF.
Definition: MuGen.h:4778
BetaGrpPSR::BetaGrpPSR
BetaGrpPSR(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr)
Constructor with replication and -values.
Definition: MuGen.h:4750
BetaGrpPC::BetaGrpPC
BetaGrpPC()
Default constructor.
Definition: MuGen.h:4309
MuBlk::MuBlk
MuBlk()
Default constructor.
Definition: MuGen.h:5349
BetaGrpSnp::dump
virtual void dump()
Dump results to the output file.
Definition: MuGen.cpp:9468
MVnormMu::up
const size_t * up() const
Points to the prior.
Definition: MuGen.h:879
MVnorm::update
virtual void update(const Grp &, const SigmaI &, const double &, const SigmaI &, const gsl_rng *)=0
Gaussian likelihood, Student- prior.
RanIndex::getNtot
size_t getNtot() const
Number of lower-level elements.
Definition: MuGen.h:2225
Grp::center
void center()
Center the value matrix.
Definition: MuGen.h:3044
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &up, const int &nThr)
Missing data constructor with a prior index.
Definition: MuGen.h:4125
MuGrpPEX::_A
Apex _A
Redundant parameter matrix.
Definition: MuGen.h:3236
MVnormBetaFt::operator=
MVnormBetaFt & operator=(const MVnormBetaFt &)
Deterministic assignment operator.
Definition: MuGen.cpp:2284
BetaGrpPSR::BetaGrpPSR
BetaGrpPSR(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr)
Constructor with no replication and -values.
Definition: MuGen.h:4737
RanIndexVS::_numSaves
double _numSaves
Number of calls to save()
Definition: MuGen.h:2419
BetaGrpPCpex::save
void save()
Save adjusted values.
Definition: MuGen.h:4466
BetaGrpFt::fMat
virtual const gsl_matrix * fMat() const
Access to the fitted value matrix.
Definition: MuGen.h:3969
BetaGrpSnpMiss::_priorVar
double _priorVar
Prior variance.
Definition: MuGen.h:4845
BetaGrpBVSR::_selB
gsl_matrix * _selB
Matrix of selected predictors.
Definition: MuGen.h:5152
BetaGrpFt::_nThr
int _nThr
Number of threads.
Definition: MuGen.h:3633
MVnormMu::operator=
MVnormMu & operator=(const MVnormMu &)
Assignment operator.
Definition: MuGen.cpp:562
MuGrp::operator+
friend MuGrp operator+(const Grp &m1, const Grp &m2)
Addition operator.
Definition: MuGen.cpp:4978
MVnormBetaFt::_fitted
gsl_matrix_view _fitted
Matrix of already fitted values.
Definition: MuGen.h:1471
Qgrp::~Qgrp
virtual ~Qgrp()
Destructor.
Definition: MuGen.h:6035
Apex::update
void update(const Grp &y, const gsl_matrix *xi, const SigmaI &SigIm)
Unreplicated Gaussian update.
Definition: MuGen.cpp:4835
SigmaI::srDetUpdate
void srDetUpdate()
Update square-root of the determinant.
Definition: MuGen.cpp:13200
BetaGrpPCpex::BetaGrpPCpex
BetaGrpPCpex()
Default constructor.
Definition: MuGen.h:4395
BetaGrpSnp::_Ystore
gsl_matrix * _Ystore
Response storage.
Definition: MuGen.h:4506
MVnormMu::down
const vector< size_t > * down() const
Points to the corresponding data.
Definition: MuGen.h:871
RanIndexVS::update
void update(const Grp &y, const SigmaI &SigIe, BetaGrpBVSR *theta, const SigmaI &SigIp)
Variable selection update.
Definition: MuGen.cpp:4462
BetaGrpFt::_MGkernel
virtual double _MGkernel(const Grp &dat, const SigmaI &SigI) const
Gaussian kernel.
Definition: MuGen.cpp:8431
RanIndexVS::dump
void dump()
Save PEP to a file.
Definition: MuGen.cpp:4424
BetaGrpFt::update
void update(const Grp &dat, const SigmaI &SigIm)
Gaussian likelihood, improper prior.
Definition: MuGen.cpp:8570
MVnormBeta::_upLevel
const size_t * _upLevel
Row index of the prior.
Definition: MuGen.h:1272
colCenter
void colCenter(gsl_matrix *inplace)
Matrix centering in-place.
Definition: blupEMMAX.cpp:51
BetaGrpSnpMiss::operator=
BetaGrpSnpMiss & operator=(const BetaGrpSnpMiss &mG)
Assignment operator.
Definition: MuGen.cpp:10077
MVnormMu
Individual vector of means.
Definition: MuGen.h:673
MVnormBeta::operator=
MVnormBeta & operator=(const MVnormBeta &)
Deterministic assignement operator.
Definition: MuGen.cpp:1966
BetaGrpSnpMiss::update
void update(const Grp &dat, const SigmaI &SigIm)
Response update function.
Definition: MuGen.cpp:10297
Grp::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const SigmaI &)=0
Student- likelihood, non-zero mean Gaussian prior.
MVnormMuPEX::operator=
MVnormMuPEX & operator=(const MVnormMuPEX &mu)
Assignment operator.
Definition: MuGen.cpp:903
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N, const string &outFileNam, const double &nu)
Deterministic constructor with degrees of freedom and output file name.
Definition: MuGen.h:6165
MuBlk::_blkStart
vector< size_t > _blkStart
Block start indexes.
Definition: MuGen.h:5315
BetaGrpSnp::BetaGrpSnp
BetaGrpSnp()
Default constructor.
Definition: MuGen.cpp:9370
BetaGrpSnp::operator=
BetaGrpSnp & operator=(const BetaGrpSnp &mG)
Assignment operator.
Definition: MuGen.cpp:9438
MuGrpPEX::_outSigFlNam
string _outSigFlNam
Covariance output file name.
Definition: MuGen.h:3250
BetaGrpSnpMiss::BetaGrpSnpMiss
BetaGrpSnpMiss()
Default constructor.
Definition: MuGen.cpp:10021
MVnormBetaFtBlk::~MVnormBetaFtBlk
~MVnormBetaFtBlk()
Destructor.
Definition: MuGen.h:2052
BetaGrpSnp::_fakeFmat
gsl_matrix * _fakeFmat
Matrix for addition operators.
Definition: MuGen.h:4500
SigmaIpex::_alpha
double _alpha
The PEX parameter.
Definition: MuGen.h:5871
Grp::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Qgrp &, const SigmaI &)=0
Student- likelihood, 0-mean Student- prior.
RanIndexVS::_proposal
size_t _proposal(const size_t &Ntot, const int &Nmn, const gsl_rng *r)
Rank proposal-generating function.
Definition: MuGen.cpp:4346
MixP::operator=
MixP & operator=(const MixP &)
Assignement operator.
Definition: MuGen.cpp:13932
MVnormMu::_lowLevel
const vector< size_t > * _lowLevel
Data indexes.
Definition: MuGen.h:681
BetaGrpPSR::BetaGrpPSR
BetaGrpPSR()
Default constructor.
Definition: MuGen.h:4724
BetaGrpSnp::update
void update(const Grp &dat, const SigmaI &SigIm)
Response update function.
Definition: MuGen.cpp:9615
Grp::_rV
vector< gsl_rng * > _rV
Vector of PNG pointers.
Definition: MuGen.h:2742
Qgrp::_nu
double _nu
Student- degrees of freedom.
Definition: MuGen.h:5966
MVnorm::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const gsl_rng *)=0
Sudent- likelihood.
MVnormBetaFtBlk::_fitted
gsl_matrix_view _fitted
Matrix of fitted values.
Definition: MuGen.h:1975
BetaGrpPSR::operator=
BetaGrpPSR & operator=(const BetaGrpPSR &mG)
Assignment operator.
Definition: MuGen.cpp:9840
MVnorm::_d
size_t _d
Length of the data vector.
Definition: MuGen.h:256
Qgrp::operator[]
double operator[](const size_t i)
Subscript operator.
Definition: MuGen.h:6048
MuGrpPEX::_tSigIAt
gsl_matrix * _tSigIAt
Scaled inverse-covariance.
Definition: MuGen.h:3234
MVnorm::getMisPhen
virtual const vector< size_t > getMisPhen() const
Indexes of missing values.
Definition: MuGen.h:639
BetaGrpFt::_fittedAll
gsl_matrix * _fittedAll
Matrix of fitted values.
Definition: MuGen.h:3621
Grp::mean
virtual MuGrp mean(RanIndex &grp)
Group mean.
Definition: MuGen.cpp:5606
MuGrpMiss::update
virtual void update(const Grp &mu, const SigmaI &SigIm)
Standard Gaussian imputation.
Definition: MuGen.cpp:6600
MVnormBetaBlk::~MVnormBetaBlk
virtual ~MVnormBetaBlk()
Destructor.
Definition: MuGen.h:1944
BetaGrpPEX::update
virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
Gaussian likelihood, 0-mean Gaussian prior.
Definition: MuGen.cpp:8821
SigmaI::save
virtual void save(const char *how="a")
Save to a stored file name.
Definition: MuGen.cpp:13217
BetaGrpSnpCV::BetaGrpSnpCV
BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar)
Constructor with replication and ABF.
Definition: MuGen.h:4691
MuBlk::_expandedVM
gsl_matrix * _expandedVM
Expanded _valueMat.
Definition: MuGen.h:5325
MuGrpPEX::operator=
MuGrpPEX & operator=(const MuGrpPEX &mGp)
Assignment operator.
Definition: MuGen.cpp:6252
BetaGrpPSRmiss::operator=
BetaGrpPSRmiss & operator=(const BetaGrpPSRmiss &mG)
Assignment operator.
Definition: MuGen.cpp:10564
RanIndexVS::_prior
MixP * _prior
Prior proportions.
Definition: MuGen.h:2375
BetaGrpSnpCV::operator=
BetaGrpSnpCV & operator=(const BetaGrpSnpCV &mG)
Assignment operator.
Definition: MuGen.cpp:9642
MuGrpEEmiss::MuGrpEEmiss
MuGrpEEmiss()
Default constructor.
Definition: MuGen.h:3554
RanIndexVS::init
void init(const vector< vector< size_t > > &idx, const vector< vector< size_t > > &rLD)
Complete initialization.
Definition: MuGen.cpp:4366
SigmaIblk::_eachBlk
vector< gsl_matrix_view > _eachBlk
Inverse-covariance matrix submatrices.
Definition: MuGen.h:5799
BetaGrpSnpMissCV
Single-SNP regression with conditional variance and missing data.
Definition: MuGen.h:4961
Apex::operator=
Apex & operator=(const Apex &A)
Assignement constructor.
Definition: MuGen.cpp:4822
MVnormBetaBlk::_X
vector< gsl_vector_view > _X
Separate predictors.
Definition: MuGen.h:1857
MVnorm::MVnorm
MVnorm(const size_t &d)
Dimension-only constructor.
Definition: MuGen.h:269
BetaGrpPEX::_tSigIAt
gsl_matrix * _tSigIAt
Scaled inverse-covariance.
Definition: MuGen.h:4010
MVnorm::update
virtual void update(const Grp &, const SigmaI &, const Grp &, const SigmaI &, const gsl_rng *)=0
Gaussian likelihood, Gaussian prior.
RanIndex::getNgrp
size_t getNgrp() const
Number of upper-level elements.
Definition: MuGen.h:2242
Grp::operator[]
MVnorm * operator[](const size_t i)
Subscript operator.
Definition: MuGen.h:3000
BetaGrpPSRmiss::~BetaGrpPSRmiss
~BetaGrpPSRmiss()
Destructor.
Definition: MuGen.h:5118
SigmaI
Basic inverse-covariance.
Definition: MuGen.h:5561
Grp::mhlSave
void mhlSave(const string &outFlNam, const SigmaI SigI)
Save Mahalanobis distance.
Definition: MuGen.cpp:5592
BetaGrpSnp
Simple single-SNP regression class.
Definition: MuGen.h:4489
Qgrp::save
void save(const char *how="a")
Save to a stored file name.
Definition: MuGen.cpp:13734
MVnorm::_vec
gsl_vector_view _vec
Data vector.
Definition: MuGen.h:253
BetaGrpBVSR::_MGkernel
double _MGkernel(const Grp &dat, const SigmaI &SigI) const
Gaussian kernel.
Definition: MuGen.cpp:11365
BetaGrpSnpMiss::_inPredFl
string _inPredFl
Predictor (SNP) file name.
Definition: MuGen.h:4848
printMat
void printMat(const gsl_matrix *m)
Print matrix to screen.
Definition: MuGen.cpp:254
MVnormBeta::scalePar
double scalePar() const
Scale parameter.
Definition: MuGen.h:1456
Grp::_valueMat
gsl_matrix * _valueMat
Value matrix.
Definition: MuGen.h:2725
Qgrp::alpha
virtual double alpha()
Access to .
Definition: MuGen.h:6063
BetaGrpPCpex::update
void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
Student- likelihood, non-zero mean Gaussian prior.
Definition: MuGen.h:4476
RanIndex::operator[]
const vector< size_t > & operator[](const size_t i) const
Subscript operator.
Definition: MuGen.h:2171
Grp::dataVec
const vector< MVnorm * > & dataVec() const
Get vector of row pointers.
Definition: MuGen.h:2944
Grp::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &)=0
Student- likelihood, non-zero mean Student- prior.
RanIndex::dump
virtual void dump()
Dump results to a file.
Definition: MuGen.h:2295
BetaGrpPCpex::update
void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp)
Gaussian likelihood, non-zero mean Student- prior.
Definition: MuGen.h:4477
BetaGrpSnp::_Xmat
gsl_matrix * _Xmat
SNP predictor matrix.
Definition: MuGen.h:4495
BetaBlk::_eachB
vector< gsl_matrix_view > _eachB
Regression coefficient submatrices.
Definition: MuGen.h:5420
BetaGrpPEX::_A
Apex _A
Multiplicative redundant parameter.
Definition: MuGen.h:4012
BetaGrpPSRmiss::BetaGrpPSRmiss
BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab)
Constructor with replication and ABF.
Definition: MuGen.h:5115
MVnormMuPEX::_A
Apex * _A
Pointer to the redundant parameter.
Definition: MuGen.h:894
Grp::Ndata
const size_t Ndata() const
Get number of rows.
Definition: MuGen.h:2964
BetaGrpSnp::fMat
const gsl_matrix * fMat() const
Access adjusted fitted value matrix.
Definition: MuGen.h:4609
MuGrpEEmiss::_meanVal
vector< list< double > > _meanVal
Means for values with errors.
Definition: MuGen.h:3545
BetaGrpPC::operator=
BetaGrpPC & operator=(const BetaGrpPC &mG)
Assignment operator.
Definition: MuGen.cpp:9326
BetaGrpPCpex::update
void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const SigmaI &SigIp)
Student- likelihood, 0-mean Gaussian prior.
Definition: MuGen.h:4471
MVnormMuMiss::~MVnormMuMiss
~MVnormMuMiss()
Destructor.
Definition: MuGen.h:1206
BetaGrpPEX::_fittedAllAdj
gsl_matrix * _fittedAllAdj
Adjusted fitted matrix.
Definition: MuGen.h:4024
SigmaI::_srDet
double _srDet
Square root of the determinant.
Definition: MuGen.h:5577
MVnormBetaPEX::_fitted
gsl_matrix_view _fitted
Fitted values.
Definition: MuGen.h:989
MVnormBetaFt::update
void update(const Grp &resp, const SigmaI &SigIb, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:2296
BetaGrpBVSR::~BetaGrpBVSR
~BetaGrpBVSR()
Destructor.
Definition: MuGen.cpp:11259
Grp::operator+
friend MuGrp operator+(const Grp &m1, const Grp &m2)
Addition operator.
Definition: MuGen.cpp:4978
MVnormBeta::_scale
double _scale
Scale parameter.
Definition: MuGen.h:1263
RanIndexVS::save
void save(const Grp &y, const BetaGrpBVSR *theta, const SigmaI &SigIe)
Save PEP.
Definition: MuGen.cpp:4384
SigmaI::update
virtual void update(const Grp &dat)
Basic Gaussian update.
Definition: MuGen.cpp:13095
MVnormBetaFtBlk::MVnormBetaFtBlk
MVnormBetaFtBlk(const gsl_matrix *resp, gsl_matrix *pred, vector< double > &eaFt, const vector< size_t > &iCl, const gsl_matrix *Sig, const vector< size_t > &blkStart, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Constructor with no prior index.
Definition: MuGen.h:2032
MuGrpPEX::fMat
const gsl_matrix * fMat() const
Access the adjusted value matrix.
Definition: MuGen.h:3321
BetaGrpPC
Relationship matrix regression.
Definition: MuGen.h:4304
Qgrp::_qVec
vector< double > _qVec
Vector of weights.
Definition: MuGen.h:5959
RanIndexVS::_rejectSwap
vector< bool > _rejectSwap
Reject a swap.
Definition: MuGen.h:2412
BetaGrpPEX::~BetaGrpPEX
virtual ~BetaGrpPEX()
Destructor.
Definition: MuGen.cpp:8649
MuBlk::_blkLow
vector< vector< vector< size_t > > > _blkLow
Vector of low level indexes.
Definition: MuGen.h:5320
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N, const double &nu, const string &misVecFlNam)
Deterministic constructor with degrees of freedom and missing values.
Definition: MuGen.h:6148
BetaGrpFt::lnOddsRat
double lnOddsRat(const Grp &y, const SigmaI &SigI, const size_t i) const
Log-odds ratio.
Definition: MuGen.cpp:8548
MVnorm::density
double density(const gsl_vector *theta, const SigmaI &SigI)
Multivariate Gaussian density.
Definition: MuGen.cpp:446
BetaGrpSnpMiss::dump
virtual void dump()
Dump results to the output file.
Definition: MuGen.cpp:10101
RanIndexVS::~RanIndexVS
~RanIndexVS()
Destructor.
Definition: MuGen.h:2453
MuBlk::update
void update(const Grp &dat, const SigmaI &SigIm)
Gaussian likelihood, improper prior.
Definition: MuGen.cpp:11877
BetaGrpSnpCV::~BetaGrpSnpCV
~BetaGrpSnpCV()
Destructor.
Definition: MuGen.h:4694
BetaGrpSnpMiss::_Ystore
gsl_matrix * _Ystore
Response storage.
Definition: MuGen.h:4825
MVnormBeta::MVnormBeta
MVnormBeta()
Default constructor.
Definition: MuGen.cpp:1761
BetaGrpSnpCV::BetaGrpSnpCV
BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr)
Constructor with replication and -values.
Definition: MuGen.h:4663
BetaGrpPCpex::update
void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
Student- likelihood, 0-mean Student- prior.
Definition: MuGen.h:4473
MVnormBetaFtBlk::MVnormBetaFtBlk
MVnormBetaFtBlk()
Default constructor.
Definition: MuGen.h:1983
Grp
Base location parameter group class.
Definition: MuGen.h:2705
MVnormBetaBlk::MVnormBetaBlk
MVnormBetaBlk()
Default constructor.
Definition: MuGen.h:1879
SigmaIpex::SigmaIpex
SigmaIpex()
Default constructor.
Definition: MuGen.h:5875
MuGrp
Hierarchical mean.
Definition: MuGen.h:3053
MVnormMuMiss::nMissP
size_t nMissP() const
Number of missing values.
Definition: MuGen.h:1234
vecCenter
void vecCenter(gsl_vector *inplace)
Vector centering in-place.
Definition: MuGen.cpp:221
BetaGrpFt::_numSaves
double _numSaves
Number of saves.
Definition: MuGen.h:3639
MVnormMuPEX::update
virtual void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r)
Gaussian likelihood, Gaussian prior.
Definition: MuGen.cpp:914
MVnorm::down
virtual const vector< size_t > * down() const
Points to the corresponding data.
Definition: MuGen.h:647
operator-
MuGrp operator-(const Grp &m1, const Grp &m2)
Subtraction operator.
Definition: MuGen.cpp:5243
SigmaIblk
Block-diagonal inverse-covariance.
Definition: MuGen.h:5788
MuBlk
Hierarchical mean with independent blocks of traits.
Definition: MuGen.h:5309
MVnormBeta::~MVnormBeta
virtual ~MVnormBeta()
Destructor.
Definition: MuGen.cpp:1977
MVnormMu::_upLevel
const size_t * _upLevel
Prior index.
Definition: MuGen.h:688
Apex::getMat
const gsl_matrix * getMat() const
Get redundant parameter matrix.
Definition: MuGen.h:2578
MVnorm::update
virtual void update(const Grp &, const SigmaI &, const gsl_rng *)=0
Gaussian likelihood.
SigmaIblk::_blkStart
vector< size_t > _blkStart
Block start indexes.
Definition: MuGen.h:5794
RanIndex::~RanIndex
virtual ~RanIndex()
Destructor.
Definition: MuGen.h:2161
MVnorm::save
void save(const string &fileNam, const char *how="a")
Save function.
Definition: MuGen.cpp:471
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with response matrix.
Definition: MuGen.h:1592
QgrpPEX::_alpha
double _alpha
Redundant parameter .
Definition: MuGen.h:6120
Apex
Multiplicative redundant parameter.
Definition: MuGen.h:2505
MuGrpPEX::~MuGrpPEX
~MuGrpPEX()
Destructor.
Definition: MuGen.cpp:6276
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r)
Multivariate random constructor with vector.
Definition: MuGen.h:1523
MVnormMu::MVnormMu
MVnormMu()
Default constructor.
Definition: MuGen.cpp:492
MuGrpEE::_errorInvVar
gsl_matrix * _errorInvVar
Matrix of error inverse-variances.
Definition: MuGen.h:3450
SigmaI::_d
size_t _d
Dimension of the matrix.
Definition: MuGen.h:5572
BetaGrpSnpMissCV::BetaGrpSnpMissCV
BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab)
Constructor with replication and -values.
Definition: MuGen.h:4994
SigmaIblk::SigmaIblk
SigmaIblk()
Default constructor.
Definition: MuGen.cpp:13286
BetaGrpSnpCV
Single-SNP regression with conditional variance.
Definition: MuGen.h:4632
MVnorm::up
virtual const size_t * up() const
Points to the prior.
Definition: MuGen.h:655
BetaGrpPCpex::update
void update(const Grp &dat, const SigmaI &SigIm, const Grp &muPr, const SigmaI &SigIp)
Gaussian likelihood, non-zero mean Gaussian prior.
Definition: MuGen.h:4475
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const string &outFlNam, const int &nThr)
Simple constructor with a prior index and output file name.
Definition: MuGen.h:4096
RanIndex::getIndVec
const vector< size_t > & getIndVec() const
Retrieve the index vector.
Definition: MuGen.h:2189
BetaGrpPCpex::BetaGrpPCpex
BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const int &nThr)
Constructor with a prior index.
Definition: MuGen.h:4408
Qgrp
Standard Student- weights.
Definition: MuGen.h:5956
BetaGrpSnp::_nThr
int _nThr
Number of threads.
Definition: MuGen.h:4511
BetaGrpPCpex::BetaGrpPCpex
BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &up, const string &outFlNam, const int &nThr)
Constructor with a prior index, replication and output file name.
Definition: MuGen.h:4439
MuGrpEEmiss::_errorInvVar
vector< list< double > > _errorInvVar
Measurement error inverse-variances.
Definition: MuGen.h:3540
MVnormMuMiss::MVnormMuMiss
MVnormMuMiss(const size_t &d)
0-mean deterministic constructor
Definition: MuGen.h:1090
SigmaIblk::_eachLS
vector< gsl_matrix_view > _eachLS
Prior matrix submatrices.
Definition: MuGen.h:5804
SigmaIpex::SigmaIpex
SigmaIpex(const Grp &dat, const string &outFlNam, const double &prDiag, const double &nu0)
Location data-based constructor with output file name.
Definition: MuGen.h:5913
BetaGrpSnpMiss::_numSaves
double _numSaves
Number of saves.
Definition: MuGen.h:4835
BetaGrpPSRmiss::dump
void dump()
Dump results to the output file.
Definition: MuGen.cpp:10587
BetaGrpSnp::_priorVar
double _priorVar
Prior variance.
Definition: MuGen.h:4521
MVnorm::mhl
virtual double mhl(const MVnorm *x, const SigmaI &SigI)
Mahalanobis distance to a vector.
Definition: MuGen.cpp:384
RanIndex::props
virtual const vector< double > props() const
Proportions of each group.
Definition: MuGen.cpp:4152
MVnormBetaBlk::_scale
vector< double > _scale
Vector of scales.
Definition: MuGen.h:1863
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with Grp type response.
Definition: MuGen.h:1627
MVnormBetaBlk::_eachVec
vector< gsl_vector_view > _eachVec
Trait blocks.
Definition: MuGen.h:1851
BetaGrpFt::BetaGrpFt
BetaGrpFt()
Default constructor.
Definition: MuGen.cpp:7053
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &up, const string &outFlNam, const int &nThr)
Missing data constructor with a prior index and output file name.
Definition: MuGen.h:4154
MVnormMuMiss::MVnormMuMiss
MVnormMuMiss(const MVnormMuMiss &)
Deterministic copy constructor.
BetaGrpPEX::_finishFitted
void _finishFitted()
Adjusted matrix calculation.
Definition: MuGen.cpp:8671
BetaGrpBVSR::_updateFitted
void _updateFitted()
Update fitted values.
Definition: MuGen.cpp:11265
MVnormBetaFtBlk::MVnormBetaFtBlk
MVnormBetaFtBlk(const gsl_matrix *resp, gsl_matrix *pred, vector< double > &eaFt, const vector< size_t > &iCl, const gsl_matrix *Sig, const vector< size_t > &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Constructor with a prior index.
Definition: MuGen.h:2049
MVnormMuMiss
Individual vector of means with missing data.
Definition: MuGen.h:1065
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with response matrix and prior index.
Definition: MuGen.h:1609
RanIndex::_r
gsl_rng * _r
Pointer to a PNG.
Definition: MuGen.h:2105
MVnormMuBlk::_eachLL
const vector< vector< size_t > > * _eachLL
Data matrix row indexes.
Definition: MuGen.h:1783
operator+
MuGrp operator+(const Grp &m1, const Grp &m2)
Addition operator.
Definition: MuGen.cpp:4978
BetaBlk::BetaBlk
BetaBlk()
Default constructor.
Definition: MuGen.h:5429
BetaGrpPCpex::update
void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp)
Gaussian likelihood, 0-mean Gaussian prior.
Definition: MuGen.h:4470
MuGrpPEX::_updateFitted
void _updateFitted()
Update adjusted values.
Definition: MuGen.cpp:6434
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_vector *b, const gsl_vector *sd, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r, const size_t &up)
Univariate random constructor with vector and prior index.
Definition: MuGen.h:1507
RanIndex::getNtot
size_t getNtot()
Number of lower-level elements.
Definition: MuGen.h:2233
MVnormBeta::up
const size_t * up() const
Points to the prior.
Definition: MuGen.h:1455
MVnormMuBlk::up
const size_t * up() const
Points to the prior.
Definition: MuGen.h:1817
MVnormMuMiss::update
void update(const Grp &mu, const SigmaI &SigIm, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:1557
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_vector *b, const gsl_matrix *Sig, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_rng *r, const size_t &up)
Multivariate random constructor with vector and prior index.
Definition: MuGen.h:1539
Grp::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const SigmaI &)=0
Student- likelihood, 0-mean Gaussian prior.
MVnormMuBlk::_blkStart
const vector< size_t > * _blkStart
Start positions of blocks.
Definition: MuGen.h:1770
MuGrpPEX::_adjValMat
gsl_matrix * _adjValMat
Adjusted value matrix.
Definition: MuGen.h:3229
BetaGrpSnpMiss
Simple single-SNP regression class with missing data.
Definition: MuGen.h:4807
BetaGrpSnpMiss::_absLab
double _absLab
Missing value label.
Definition: MuGen.h:4840
MuGrp::operator=
MuGrp & operator=(const MuGrp &mG)
Assignemnt operator.
Definition: MuGen.cpp:6036
MixP::~MixP
~MixP()
Destructor.
Definition: MuGen.h:6292
Grp::_upLevel
RanIndex * _upLevel
Upper level index.
Definition: MuGen.h:2737
RanIndex::priorInd
const size_t & priorInd(const size_t i) const
Upper-level index.
Definition: MuGen.h:2207
Qgrp::_outFile
string _outFile
Output file name.
Definition: MuGen.h:5968
RanIndexVS::RanIndexVS
RanIndexVS()
Default constructor.
Definition: MuGen.cpp:4252
MVnormBetaPEX::MVnormBetaPEX
MVnormBetaPEX()
Default constructor.
Definition: MuGen.h:993
SigmaI::_LamSc
gsl_matrix * _LamSc
Prior inverse-covariance.
Definition: MuGen.h:5583
Grp::fMat
virtual const gsl_matrix * fMat() const
Access the value matrix.
Definition: MuGen.h:2958
MixP::MixP
MixP(const vector< double > &initP)
Constructor with a vector of proportions.
Definition: MuGen.h:6225
RanIndexVS::_acceptDrop
vector< bool > _acceptDrop
Accept a drop.
Definition: MuGen.h:2382
RanIndex::operator[]
vector< size_t > & operator[](const size_t i)
Subscript operator.
Definition: MuGen.h:2180
Grp::dMat
virtual const gsl_matrix * dMat() const
Access the value matrix.
Definition: MuGen.h:2951
MuGrp::MuGrp
MuGrp()
Default constructor.
Definition: MuGen.h:3064
MVnormMuMiss::_myInd
size_t _myInd
own index
Definition: MuGen.h:1078
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, 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.
Definition: MuGen.h:4259
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with response matrix.
Definition: MuGen.h:1557
MVnorm::~MVnorm
virtual ~MVnorm()
Virtual destructor.
Definition: MuGen.h:350
MVnormMuBlk
Individual vector of means with blocks of traits.
Definition: MuGen.h:1757
MVnormMuBlk::MVnormMuBlk
MVnormMuBlk()
Default constructor.
Definition: MuGen.h:1787
MVnormBetaPEX
Individual regression with parameter expansion.
Definition: MuGen.h:968
BetaGrpSnpCV::BetaGrpSnpCV
BetaGrpSnpCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar)
Constructor with no replication and ABF.
Definition: MuGen.h:4677
MuGrpMiss::MuGrpMiss
MuGrpMiss()
Default constructor.
Definition: MuGen.h:3377
BetaGrpPCpex::update
void update(const Grp &dat, const Qgrp &q, const SigmaI &SigIm, const Grp &muPr, const Qgrp &qPr, const SigmaI &SigIp)
Student- likelihood, non-zero mean Student- prior.
Definition: MuGen.h:4478
MuGrpMiss::_misInd
vector< size_t > _misInd
Index of the rows with missing data.
Definition: MuGen.h:3373
BetaGrpSnp::_inPredFl
string _inPredFl
Predictor (SNP) file name.
Definition: MuGen.h:4524
RanIndexVS::_Ntp
size_t _Ntp
Original number of predictors.
Definition: MuGen.h:2369
BetaGrpSnpMiss::fMat
const gsl_matrix * fMat() const
Access adjusted fitted value matrix.
Definition: MuGen.h:4937
BetaGrpSnpMissCV::~BetaGrpSnpMissCV
~BetaGrpSnpMissCV()
Destructor.
Definition: MuGen.h:5027
MVnorm::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const SigmaI &, const gsl_rng *)=0
Student- likelihood, Gaussian prior.
Apex::setPr
void setPr(const double &pr)
Set prior value.
Definition: MuGen.cpp:4807
MVnorm::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const double &, const SigmaI &, const gsl_rng *)=0
Student- likelihood, Student- prior.
MVnormBetaBlk::_blkStart
const vector< size_t > * _blkStart
Start positions of blocks.
Definition: MuGen.h:1845
MixP::operator[]
const double & operator[](const size_t i) const
Subscript operator.
Definition: MuGen.h:6310
SigmaI::getSrDet
double getSrDet() const
Access the square-root of the determinant.
Definition: MuGen.h:5780
MuGrpEE::_meanVal
gsl_matrix * _meanVal
Matrix of means.
Definition: MuGen.h:3455
BetaGrpSnpMissCV::dump
void dump()
Dump results to the output file.
Definition: MuGen.cpp:10341
MuGrpPEX
"Random effect" with parameter expansion
Definition: MuGen.h:3223
Grp::~Grp
virtual ~Grp()
Destructor.
Definition: MuGen.cpp:5527
Qgrp::_presInd
vector< size_t > _presInd
Vector of indexes of present data.
Definition: MuGen.h:5964
RanIndex::RanIndex
RanIndex()
Default constructor.
Definition: MuGen.cpp:4023
SigmaIpex::save
void save(const char *how="a")
Save to a stored file name.
Definition: MuGen.cpp:13608
RanIndexVS::_mcmcTrack
vector< bool > _mcmcTrack
Transition tracking variable.
Definition: MuGen.h:2361
RanIndex
Generic index class.
Definition: MuGen.h:2084
RanIndex::save
virtual void save(const Grp &y, const Grp &theta, const SigmaI &SigIe)
Probability save.
Definition: MuGen.h:2289
SigmaI::operator=
SigmaI & operator=(const SigmaI &)
Assignment operator.
Definition: MuGen.cpp:13077
MVnormMuMiss::operator=
MVnormMuMiss & operator=(const MVnormMuMiss &)
Assignment operator.
MVnormBetaPEX::update
void update(const Grp &dat, const SigmaI &SigIm, const SigmaI &SigIp, const gsl_rng *r)
Gaussian likelihood, Gaussian prior.
Definition: MuGen.cpp:1243
BetaGrpFt::dump
void dump()
Dump to a file.
Definition: MuGen.cpp:8538
MixP::MixP
MixP()
Default constructor.
MVnormBetaFtBlk
Individual vector of conditional regression coefficients with blocks of traits.
Definition: MuGen.h:1968
RanIndex::update
virtual void update(const Grp &y, const SigmaI &SigIe, BetaGrpBVSR *theta, const SigmaI &SigIp)
Variable selection update.
Definition: MuGen.h:2335
MVnorm::update
virtual void update(const Grp &, const SigmaI &, const Grp &, const double &, const SigmaI &, const gsl_rng *)=0
Gaussian likelihood, Student- prior.
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt()
Default constructor.
Definition: MuGen.h:1475
MVnormBetaFtBlk::MVnormBetaFtBlk
MVnormBetaFtBlk(const Grp &resp, gsl_matrix *pred, vector< double > &eaFt, const vector< size_t > &iCl, const gsl_matrix *Sig, const vector< size_t > &blkStart, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Constructor with a prior index.
Definition: MuGen.h:2016
SigmaIpex::SigmaIpex
SigmaIpex(const Grp &dat, const double &prDiag, const double &nu0)
Location data-based constructor.
Definition: MuGen.h:5903
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Deterministic constructor with a prior index.
Definition: MuGen.h:1707
MVnorm::MVnorm
MVnorm()
Default constructor.
Definition: MuGen.h:262
RanIndex::priorInd
size_t & priorInd(const size_t i)
Upper-level index.
Definition: MuGen.h:2216
BetaGrpPSR
Single-SNP regression with partial effects.
Definition: MuGen.h:4719
MixP::update
void update(const RanIndex &Nvec)
Gibbs update function.
Definition: MuGen.cpp:13942
BetaGrpPSR::~BetaGrpPSR
~BetaGrpPSR()
Destructor.
Definition: MuGen.h:4781
MuGrpEE::MuGrpEE
MuGrpEE()
Default constructor.
Definition: MuGen.cpp:6615
BetaGrpPSR::dump
void dump()
Dump results to the output file.
Definition: MuGen.cpp:9867
MuBlk::_fillInUp
void _fillInUp()
Fill in blocks with few levels and a prior grouping.
Definition: MuGen.cpp:11845
RanIndex::_vecInd
vector< size_t > _vecInd
Indexes of upper levels.
Definition: MuGen.h:2099
MuBlk::_updateExp
void _updateExp()
Update the _expandedVM matrix.
Definition: MuGen.cpp:11803
rtgeom
size_t rtgeom(const double &, const size_t &, const gsl_rng *)
Truncated geometric distribution.
Definition: MuGen.cpp:120
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const gsl_matrix *resp, gsl_matrix *pred, const size_t &iCl, gsl_matrix *allFt, const size_t &begRw, const gsl_matrix *Sig, const gsl_rng *r, const size_t &up, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with response matrix and prior index.
Definition: MuGen.h:1575
MVnormBeta::update
virtual void update(const Grp &dat, const SigmaI &SigIb, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:1986
RanIndexVS::_pep
vector< double > _pep
Posterior exclusion probabilities.
Definition: MuGen.h:2355
MVnormMu::~MVnormMu
virtual ~MVnormMu()
Destructor.
Definition: MuGen.cpp:571
BetaGrpBVSR
Bayesian variable selection regression.
Definition: MuGen.h:5145
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, 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.
Definition: MuGen.h:4170
Qgrp::size
size_t size() const
Const length of the weight vector.
Definition: MuGen.h:6069
Qgrp::alpha
virtual double alpha() const
Const access to .
Definition: MuGen.h:6056
MVnormBetaFt
Regression with multiple predictors.
Definition: MuGen.h:1464
SigmaIpex::update
void update(const Grp &dat, const Qgrp &q)
Basic Student- update.
Definition: MuGen.cpp:13597
BetaGrpSnpMissCV::BetaGrpSnpMissCV
BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab)
Constructor with no replication and ABF.
Definition: MuGen.h:5009
MixP
Dirichlet-multinomial mixture prior.
Definition: MuGen.h:6204
BetaBlk::~BetaBlk
~BetaBlk()
Destructor.
Definition: MuGen.h:5541
BetaGrpPCpex
Multiplicative parameter expansion for PC regression.
Definition: MuGen.h:4390
BetaGrpSnp::_Npred
size_t _Npred
Number of predictors (SNPs)
Definition: MuGen.h:4509
BetaBlk::_blkStart
vector< size_t > _blkStart
Block start indexes.
Definition: MuGen.h:5410
MVnormMuBlk::~MVnormMuBlk
virtual ~MVnormMuBlk()
Destructor.
Definition: MuGen.h:1815
MVnorm
The abstract base class for location parameter rows.
Definition: MuGen.h:246
MVgauss
void MVgauss(const gsl_vector *, const gsl_matrix *, const gsl_rng *, gsl_vector *)
Multivariate Gaussian sampling function.
Definition: MuGen.cpp:77
BetaGrpPSR::BetaGrpPSR
BetaGrpPSR(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar)
Constructor with no replication and ABF.
Definition: MuGen.h:4764
Grp::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &)=0
Student- likelihood, improper prior.
SigmaIpex::SigmaIpex
SigmaIpex(const size_t &d, const double &invVar, const double &df)
Deterministic diagonal matrix constructor.
Definition: MuGen.h:5884
MuGrpPEX::_ftA
vector< vector< double > > _ftA
Fitted values.
Definition: MuGen.h:3242
Apex::getMat
gsl_matrix * getMat()
Get redundant parameter matrix.
Definition: MuGen.h:2576
MuGrpEEmiss
Data with measurement error and missing phenotypes.
Definition: MuGen.h:3534
SigmaIblk::update
void update(const Grp &dat)
Basic Gaussian update.
Definition: MuGen.cpp:13542
BetaGrpSnpMiss::_Xmat
vector< vector< double > > _Xmat
Predictor array.
Definition: MuGen.h:4813
MVnorm::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const SigmaI &, const gsl_rng *)=0
Student- likelihood, Gaussian prior.
BetaGrpPCpex::BetaGrpPCpex
BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const int &nThr)
Constructor with a prior index and replication.
Definition: MuGen.h:4423
BetaGrpBVSR::_tmpXb
gsl_matrix * _tmpXb
matrix for the candidate dropped/added element
Definition: MuGen.h:5154
BetaGrpSnpCV::dump
void dump()
Dump results to the output file.
Definition: MuGen.cpp:9663
Grp::save
virtual void save(const Grp &y, const SigmaI &SigI)
Save with data and inverse-covariance.
Definition: MuGen.h:2922
MVnorm::operator[]
double operator[](const size_t i) const
Subscript operator.
Definition: MuGen.h:602
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, const double &absLab, RanIndex &low, RanIndex &up, const int &nThr)
Missing data constructor with a prior index and replication.
Definition: MuGen.h:4140
MuGrpMiss
Data with missing phenotype values.
Definition: MuGen.h:3370
MVnormBetaPEX::operator=
MVnormBetaPEX & operator=(const MVnormBetaPEX &bet)
Assignment operator.
Definition: MuGen.cpp:1228
MuGrpEE::update
virtual void update(const Grp &muPr, const SigmaI &SigIm)
Gaussian prior.
Definition: MuGen.cpp:6759
BetaGrpPCpex::BetaGrpPCpex
BetaGrpPCpex(const Grp &rsp, const string &predFlNam, const string &evFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
Constructor with a prior index and replication.
Definition: MuGen.h:4455
BetaGrpPSRmiss
Single-SNP regression with partial effects and missing data.
Definition: MuGen.h:5052
QgrpPEX::update
void update(const Grp &dat, const Grp &mu, const SigmaI &SigI)
Update with a mean.
Definition: MuGen.cpp:13801
rdtsc
unsigned long long rdtsc()
Accessing the processor RTDSC instruction.
Definition: MuGen.cpp:264
BetaGrpPSRmiss::BetaGrpPSRmiss
BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab)
Constructor with replication and -values.
Definition: MuGen.h:5085
MVnormMuMiss::MVnormMuMiss
MVnormMuMiss()
Default constructor.
Definition: MuGen.h:1082
BetaGrpPEX
Multivariate multiple regression with parameter expansion.
Definition: MuGen.h:4004
BetaGrpSnpMiss::_fakeFmat
gsl_matrix * _fakeFmat
Matrix for addition operators.
Definition: MuGen.h:4819
BetaGrpPSRmiss::BetaGrpPSRmiss
BetaGrpPSRmiss()
Default constructor.
Definition: MuGen.h:5057
BetaGrpFt::_fittedEach
vector< vector< double > > _fittedEach
Partial fitted value matrices.
Definition: MuGen.h:3616
MVnorm::nMissP
virtual size_t nMissP() const
Number of missing values.
Definition: MuGen.h:631
BetaGrpPCpex::update
void update(const Grp &dat, const SigmaI &SigIm, const Qgrp &qPr, const SigmaI &SigIp)
Gaussian likelihood, 0-mean Student- prior.
Definition: MuGen.h:4472
Grp::update
virtual void update(const Grp &, const SigmaI &, const Grp &, const Qgrp &, const SigmaI &)=0
Gaussian likelihood, non-zero mean Student- prior.
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const SigmaI &SigI, const string &predFlNam, const size_t &Npred, const double &Spr, const double &Nmul, const double &rSqMax, RanIndex &low, RanIndex &up, const string &outFlNam, const int &nThr)
Selection constructor with replication.
Definition: MuGen.h:4214
Apex::Apex
Apex()
Default constructor.
Definition: MuGen.cpp:4753
MVnormMuMiss::_misPhenInd
vector< size_t > _misPhenInd
Missing data index.
Definition: MuGen.h:1072
MuBlk::_fillIn
void _fillIn()
Fill in blocks with few levels.
Definition: MuGen.cpp:11822
BetaGrpPEX::_finishConstruct
void _finishConstruct(const double &Spr)
Finish construction.
Definition: MuGen.cpp:8654
BetaGrpSnpMissCV::operator=
BetaGrpSnpMissCV & operator=(const BetaGrpSnpMissCV &mG)
Assignment operator.
Definition: MuGen.cpp:10322
MuGrpEE::~MuGrpEE
~MuGrpEE()
Destructor.
Definition: MuGen.cpp:6714
QgrpPEX::QgrpPEX
QgrpPEX()
Default constructor.
Definition: MuGen.h:6124
MVnorm::update
virtual void update(const Grp &, const Qgrp &, const SigmaI &, const Grp &, const double &, const SigmaI &, const gsl_rng *)=0
Student- likelihood, Student- prior.
MVnormMu::update
virtual void update(const Grp &dat, const SigmaI &SigIm, const gsl_rng *r)
Gaussian likelihood.
Definition: MuGen.cpp:582
BetaGrpSnpMissCV::BetaGrpSnpMissCV
BetaGrpSnpMissCV(const string &predFlNam, const string &outFlNam, RanIndex &low, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab)
Constructor with replication and ABF.
Definition: MuGen.h:5024
Grp::update
virtual void update(const Grp &, const SigmaI &, const SigmaI &)=0
Gaussian likelihood, 0-mean Gaussian prior.
RanIndex::save
virtual void save(const Grp &y, const BetaGrpBVSR *theta, const SigmaI &SigIe)
Variable selection save.
Definition: MuGen.h:2279
BetaGrpFt
Multivariate multiple regression.
Definition: MuGen.h:3609
MVnormMuPEX
Individual vector of means with parameter expansion.
Definition: MuGen.h:887
MVnormBetaFt::~MVnormBetaFt
virtual ~MVnormBetaFt()
Destructor.
Definition: MuGen.h:1725
RanIndexVS::_rejectAdd
vector< bool > _rejectAdd
Rject an addition.
Definition: MuGen.h:2400
Grp::dump
virtual void dump()
Dump to a file.
Definition: MuGen.h:2938
MVnormBeta::_X
gsl_vector_view _X
Predictor.
Definition: MuGen.h:1257
Grp::save
virtual void save()
Save to pre-specified file.
Definition: MuGen.cpp:5540
SigmaI::_outFlNam
string _outFlNam
Output file name.
Definition: MuGen.h:5588
BetaGrpPEX::_ftA
vector< vector< double > > _ftA
Fitted values.
Definition: MuGen.h:4018
RanIndex::_idx
vector< vector< size_t > > _idx
Indexes of lower levels.
Definition: MuGen.h:2093
MVnormMu::getMisPhen
virtual const vector< size_t > getMisPhen() const
Indexes of missing values.
Definition: MuGen.h:863
Grp::lnOddsRat
virtual double lnOddsRat(const Grp &y, const SigmaI &SigI, const size_t i) const
Log-odds ratio.
Definition: MuGen.h:2981
Grp::_theta
vector< MVnorm * > _theta
Vector of pointers to value rows.
Definition: MuGen.h:2720
BetaGrpPSRmiss::BetaGrpPSRmiss
BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &absLab)
Constructor with no replication and -values.
Definition: MuGen.h:5071
BetaGrpPCpex::~BetaGrpPCpex
~BetaGrpPCpex()
Destructor.
Definition: MuGen.h:4458
MVnormMu::MVnormMu
MVnormMu(const size_t &d)
Zero vector constructor.
Definition: MuGen.h:703
BetaGrpPCpex::save
void save(const string &outFlNam)
Save adjusted values to named file.
Definition: MuGen.h:4467
MVnorm::operator=
MVnorm & operator=(const MVnorm &)
Assignement operator.
Definition: MuGen.cpp:343
QgrpPEX
Student- weights for PEX.
Definition: MuGen.h:6117
BetaGrpPEX::BetaGrpPEX
BetaGrpPEX(const Grp &rsp, const string &predFlNam, const size_t &Npred, const double &Spr, RanIndex &low, RanIndex &up, const int &nThr)
Simple constructor with a prior index and replication.
Definition: MuGen.h:4083
BetaGrpFt::_valueSum
gsl_matrix * _valueSum
Sample storage matrix.
Definition: MuGen.h:3626
SigmaI::getMat
const gsl_matrix * getMat() const
Access to the inverse-covariance matrix.
Definition: MuGen.h:5772
MVnormMuPEX::MVnormMuPEX
MVnormMuPEX()
Default constructor.
Definition: MuGen.h:906
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N, const string &outFileNam, const double &nu, const string &misVecFlNam)
Deterministic constructor with degrees of freedom, missing values and output file name.
Definition: MuGen.h:6175
BetaGrpSnpMiss::_nThr
int _nThr
Number of threads to use.
Definition: MuGen.h:4830
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N, const double &nu)
Deterministic constructor with degrees of freedom.
Definition: MuGen.h:6139
MVnormBetaBlk::_upLevel
const size_t * _upLevel
Pointer to a row index of the prior.
Definition: MuGen.h:1870
RanIndexVS::_acceptAdd
vector< bool > _acceptAdd
Accept an addition.
Definition: MuGen.h:2394
SigmaI::save
void save(FILE *fileStr)
Save to file stream.
Definition: MuGen.h:5761
Qgrp::_r
gsl_rng * _r
Pseudo-random number generator.
Definition: MuGen.h:5974
MuGrpEEmiss::update
void update(const Grp &muPr, const SigmaI &SigIm)
Standard Gaussian imputation.
Definition: MuGen.cpp:7012
BetaGrpSnpMissCV::BetaGrpSnpMissCV
BetaGrpSnpMissCV()
Default constructor.
Definition: MuGen.h:4966
BetaGrpPC::~BetaGrpPC
virtual ~BetaGrpPC()
Destructor.
Definition: MuGen.h:4368
MVnormMuBlk::_eachVec
vector< gsl_vector_view > _eachVec
Trait blocks.
Definition: MuGen.h:1776
SigmaIpex::SigmaIpex
SigmaIpex(const size_t &d, const double &invVar, const double &df, const string &outFlNam)
Deterministic diagonal matrix constructor with output file name.
Definition: MuGen.h:5894
MuGrpPEX::_nThr
int _nThr
number of threads
Definition: MuGen.h:3244
MVnormBetaBlk::up
const size_t * up() const
Points to the prior.
Definition: MuGen.h:1946
Qgrp::operator[]
double operator[](const size_t i) const
Const subscript operator.
Definition: MuGen.h:6042
QgrpPEX::alpha
double alpha()
Access to .
Definition: MuGen.h:6190
RanIndex::init
virtual void init(const vector< vector< size_t > > &idx, const vector< vector< size_t > > &rLD)
Initialization function.
Definition: MuGen.cpp:4165
MuGrpEEmiss::~MuGrpEEmiss
~MuGrpEEmiss()
Destructor.
Definition: MuGen.h:3583
MVnormBetaPEX::_scale
double _scale
Scale parameter.
Definition: MuGen.h:981
QgrpPEX::QgrpPEX
QgrpPEX(const size_t &N)
Deterministic size-only constructor.
Definition: MuGen.h:6131
MVnormBetaFt::MVnormBetaFt
MVnormBetaFt(const Grp &resp, gsl_matrix *pred, const size_t &iCl, vector< double > &eaFt, const gsl_matrix *Sig, const gsl_rng *r, gsl_matrix *bet, const size_t &iRw)
Multivariate random constructor with Grp type response.
Definition: MuGen.h:1662
BetaGrpPSRmiss::BetaGrpPSRmiss
BetaGrpPSRmiss(const string &predFlNam, const string &outFlNam, const size_t &Ndat, const size_t &Npred, const size_t &d, const int &Nthr, const double &prVar, const double &absLab)
Constructor with no replication and ABF.
Definition: MuGen.h:5100
BetaGrpFt::_Xmat
gsl_matrix * _Xmat
Predictor matrix.
Definition: MuGen.h:3631
MVnormBetaPEX::_N
size_t _N
Length of the predictor.
Definition: MuGen.h:983
Grp::Grp
Grp()
Definition: MuGen.cpp:5517
MuGrp::update
virtual void update(const Grp &dat, const SigmaI &SigIm)
Gaussian likelihood, improper prior.
Definition: MuGen.cpp:6053
RanIndex::getNgrp
size_t getNgrp()
Number of upper-level elements.
Definition: MuGen.h:2250
SigmaIpex
PEX inverse-covariance.
Definition: MuGen.h:5867