"BVS" Matlab toolbox for Bayesian logistic and probit regression 
with variable selection for high-dimensional data
----------------------------------------------------------------
Manuela Zucknick, June 2008


Requirements:
-------------
This library requires the "lightspeed" Matlab toolbox by Tom Minka for optimised 
versions of primitive functions and efficient  random number generators and 
evaluation of common probability densities 
(http://research.microsoft.com/~minka/software/lightspeed).

The code requires Matlab 5 or above.


Instructions: 
-------------
1. Unzip the BVS.zip file where you want the BVS directory to be
2. Download the lightspeed.zip file from the webpage given above and unzip 
   the lightspeed.zip file where you want the lightspeed directory to be
3. Add the paths to the BVS and lightspeed directories to the MATLAB search paths
4. Open the MATLAB console and type "help logisticVS" for info on how to run
   logistic BVS, or type "help probitVS" for probit BVS


Functions:
----------
The BVS.zip file contains the following MATLAB files. For more information on each 
function xxx.m, type "help xxx".

(1) Main functions:
- logisticVS.m		(Logistic BVS)
- logisticVS_tempMult.m	(Logistic BVS with parallel tempering with k chains)
- probitVS.m		(Probit BVS)
- probitVS_temp2.m	(Probit BVS with parallel tempering with 2 chains)

(2) Auxiliary functions:
- betaGAM_update_blockJoint.m
- betaGAM_update_blockRand.m
- betaGAM_update_blockSingleGibbs.m
- betaGAM_update_simple.m
- KS_pdf.m
- lambdadist.m
- lambdadist_temp.m
- LAMz_update.m
- lefttrunclogis.m
- lefttruncnorm.m
- logt_cdf.m		(function by K Hornik and JP LeSage)
- logt_inv.m		(function by K Hornik and JP LeSage)
- normalcdf.m		(copyright (c) 1993-97 by The MathWorks, Inc.)
- normalinv.m		(copyright (c) 1993-97 by The MathWorks, Inc.)
- normlt.m		
- normrt.m
- righttrunclogis.m
- righttruncnorm.m
- ZbetaGAM_update.m

(3) Example data set (subset of the Pima Indians data set in ):
- PimaData.mat


Output files:
-------------
(1) for add/delete Metropolis-Hastings MCMC algorithm:
- beta.txt		(sparse matrix of beta, variables that are not selected,
			 have a value of zero)
- alpha.txt		(vector of Metropolis-Hastings acceptance rates)

(2) for block MCMC samplers:
- beta.txt		(sparse matrix of beta, variables that are not selected,
			 have a value of zero)
- numneigh.txt		(vector of the number of neighbours in the blocks)


Example: 
--------
To perform logistic BVS with the Pima data, enter the following in the MATLAB 
console.

load PimaData;
[n,p] = size(PimaX);	
c2 = 100;		%hyper-prior for beta ~ N(0, c2*I)
PI = 0.5;		%hyper-prior for gamma: prior probability for all gamma_i
mcmc = 1000;		%number of MCMC iterations
burnin = 100;		%number of burn-in iterations to discard

%Add/delete Metropolis-Hastings:
logisticVS(PimaX,c2*eye(p),PI,PimaY,mcmc);
load alpha.txt;		
load beta.txt;	

%Block MCMC using pcor80Pima matrix to determine blocks:	
logisticVS(PimaX,c2*eye(p),PI,PimaY,mcmc,pcor80Pima,0,0,'singleGibbs');	
load numneigh.txt;	
load beta.txt;

beta = sparse(beta);	%beta matrix of dimension MCMC x p
spy(beta);		%trace plot of gamma
gamma = beta ~= 0;	%gamma matrix of dimension MCMC x p

