P1, P2;
-
- //calculate P0 (null) and P1 (for every SNP)
-
-
-
- //loop through the number of combinations
- for (size_t s=0; s10) {break;}
-
- if (a_mode==13) {
- SampleZ (y, z_hat, z);
- mean_z=CenterVector (z);
-
- time_start=clock();
- gsl_blas_dgemv (CblasTrans, 1.0, U, z, 0.0, Utz);
- time_UtZ+=(clock()-time_start)/(double(CLOCKS_PER_SEC)*60.0);
-
- //First proposal
- if (cHyp_old.n_gamma==0 || cHyp_old.rho==0) {
- logPost_old=CalcPosterior(Utz, K_eval, Utu_old, alpha_old, cHyp_old);
- beta_old.clear();
- for (size_t i=0; isize; ++i) {
- beta_old.push_back(gsl_vector_get(beta, i));
- }
- gsl_matrix_free (UtXgamma);
- gsl_vector_free (beta);
- }
- }
-
-
- delete [] p_gamma;
- beta_g.clear();
-
- return;
-}
-
-*/
-
-
-
-
-
-
-/*
-//below fits MCMC for rho=1
-void BSLMM::CalcXtX (const gsl_matrix *X, const gsl_vector *y, const size_t s_size, gsl_matrix *XtX, gsl_vector *Xty)
-{
- time_t time_start=clock();
- gsl_matrix_const_view X_sub=gsl_matrix_const_submatrix(X, 0, 0, X->size1, s_size);
- gsl_matrix_view XtX_sub=gsl_matrix_submatrix(XtX, 0, 0, s_size, s_size);
- gsl_vector_view Xty_sub=gsl_vector_subvector(Xty, 0, s_size);
-
-#ifdef WITH_LAPACK
- lapack_dgemm ((char *)"T", (char *)"N", 1.0, &X_sub.matrix, &X_sub.matrix, 0.0, &XtX_sub.matrix);
-#else
- gsl_blas_dgemm (CblasTrans, CblasNoTrans, 1.0, &X_sub.matrix, &X_sub.matrix, 0.0, &XtX_sub.matrix);
-#endif
- gsl_blas_dgemv(CblasTrans, 1.0, &X_sub.matrix, y, 0.0, &Xty_sub.vector);
-
- time_Omega+=(clock()-time_start)/(double(CLOCKS_PER_SEC)*60.0);
-
- return;
-}
-
-
-
-double BSLMM::CalcPosterior (const double yty, class HYPBSLMM &cHyp)
-{
- double logpost=0.0;
-
- //for quantitative traits, calculate pve and pge
- //pve and pge for case/control data are calculted in CalcCC_PVEnZ
- if (a_mode==11) {
- cHyp.pve=0.0;
- cHyp.pge=1.0;
- }
-
- //calculate likelihood
- if (a_mode==11) {logpost-=0.5*(double)ni_test*log(yty);}
- else {logpost-=0.5*yty;}
-
- logpost+=((double)cHyp.n_gamma-1.0)*cHyp.logp+((double)ns_test-(double)cHyp.n_gamma)*log(1-exp(cHyp.logp));
-
- return logpost;
-}
-
-
-double BSLMM::CalcPosterior (const gsl_matrix *Xgamma, const gsl_matrix *XtX, const gsl_vector *Xty, const double yty, const size_t s_size, gsl_vector *Xb, gsl_vector *beta, class HYPBSLMM &cHyp)
-{
- double sigma_a2=cHyp.h/( (1-cHyp.h)*exp(cHyp.logp)*(double)ns_test);
- double logpost=0.0;
- double d, P_yy=yty, logdet_O=0.0;
-
- gsl_matrix_const_view Xgamma_sub=gsl_matrix_const_submatrix (Xgamma, 0, 0, Xgamma->size1, s_size);
- gsl_matrix_const_view XtX_sub=gsl_matrix_const_submatrix (XtX, 0, 0, s_size, s_size);
- gsl_vector_const_view Xty_sub=gsl_vector_const_subvector (Xty, 0, s_size);
-
- gsl_matrix *Omega=gsl_matrix_alloc (s_size, s_size);
- gsl_matrix *M_temp=gsl_matrix_alloc (s_size, s_size);
- gsl_vector *beta_hat=gsl_vector_alloc (s_size);
- gsl_vector *Xty_temp=gsl_vector_alloc (s_size);
-
- gsl_vector_memcpy (Xty_temp, &Xty_sub.vector);
-
- //calculate Omega
- gsl_matrix_memcpy (Omega, &XtX_sub.matrix);
- gsl_matrix_scale (Omega, sigma_a2);
- gsl_matrix_set_identity (M_temp);
- gsl_matrix_add (Omega, M_temp);
-
- //calculate beta_hat
- logdet_O=CholeskySolve(Omega, Xty_temp, beta_hat);
- gsl_vector_scale (beta_hat, sigma_a2);
-
- gsl_blas_ddot (Xty_temp, beta_hat, &d);
- P_yy-=d;
-
- //sample tau
- double tau=1.0;
- if (a_mode==11) {tau =gsl_ran_gamma (gsl_r, (double)ni_test/2.0, 2.0/P_yy); }
-
- //sample beta
- for (size_t i=0; i.
+ along with this program. If not, see .
*/
-
#ifndef __BSLMMDAP_H__
#define __BSLMMDAP_H__
@@ -24,25 +23,14 @@
#include