#################################################################################
Readme file for the C code of 
"A Bayesian nonparametric model for spatially distributed multivariate binary data 
with application to a multidrug-resistant tuberculosis (MDR-TB) study"
Author: Jian Kang, Nanhua Zhang, Ran Shi
#################################################################################

Requirement: 
GNU Scientific Library (GSL) (http://www.gnu.org/software/gsl/)
Any UNIX-like system with an ANSI C compiler


Compile:
1. Open the terminal and change directory to the folder where the source code "MDR_TB.c" are located.
2. Prepare the following five input files (see later parts for detailed specifications)
   and store them under the current directory: 
   inipara:  initial parameter values 
   iniprior: initial prior values
   obsdata:  observed multivariate binary data
   obsloc:   observed location data
   obscov:   observed covariate data
3. Have the GSL library available on your OS file system. 
   Default installation path: "/usr/local/include" and "usr/local/lib"
   Remark: do make sure that lgsl and lgslcblas are available under "usr/local/lib"
3. Type in the following command:
   gcc -Wall -I/usr/local/include -c MDR_TB.c 
4. Type in the following command:
   gcc -L/usr/local/lib MDR_TB.o -lgsl -lgslcblas -lm

   
Running the program and output results:
After compilation, use the following command to run the program:
./MDT_TB.o -inipara iniprior obsdata obsloc obscov
The output file is the MCMC samples for the covariate coefficient, 
coefficient for the GP surface expansion and various variance terms in the model.





Input file format specifications:

#######################################################################################
File inipara:  initial parameter values 
n (integer, number of observations)
q (integer, dimension of the multivariate binary outcomes)
p (integer, number of covariates)
MC_T (integer, number of MCMC iterations)
RecGap (integer, the thinning parameter for MCMC records)
BurnIn (integer, the number of burn-in observations to remove)
SEED (integer, the SEED for random number generation)
#######################################################################################


#######################################################################################
File iniprior: initial prior values
Gamma_S_shape (double scalar, shape parameter for the inverse gamma prior for \sigma^2)
Gamma_S_scale (double scalar, scale parameter for the inverse gamma prior for \sigma^2)
Wish_Sigma_nu (double scalar, hyperior for \beta variance)
Wish_Sigma (p by p double matrix, hyperprior for \beta variance)
Gamma_shape (double scalar, hyperprior for \alpha variance)
Gamma_scale (double scalar, hyperprior for \alpha variance)
########################################################################################


########################################################################################
File obsdata: observed multivariate binary data
n by q zero-one integer matrix, observed multivariate binary outcomes
########################################################################################


########################################################################################
File obsloc: observed location data
n by 2 double matrix: location information
########################################################################################

########################################################################################
File obscov: observed covariate data
n by p double matrix: each row is the covariate record for the specific observations
########################################################################################

Remark: make sure that the obsdata, obsloc and obscov files have match records across locations.