## Matlab Codes for Scalar-on-Image Regression Using Ising-DP Prior

The following matlab code implements Bayesian scalar-on-image regression using Ising-DP prior for image data, proposed in the paper *Spatial Bayesian variable selection and grouping in high-dimensional scalar-on-image regressions* (Li, Zhang, Wang, Gonzalez, Maresh, and Coan 2014).

DataGeneration.r: The r code that generates data defined on 10x10x10 lattice.
InitSimuGamma.m: The matlab function that assigns initial values to indicator variables \gamma.
InitSimuWH.m: The matlab function that assigns initial values to the weights W_h of values generated from DP.
neighbor_list.m: The matlab function that creates the list of neighbors for each voxel given voxels' spatial locations.
Vicinity.m: The matlab function that creates the vicinity matrix used in the Ising prior given voxels' spatial locations.
CondPostGamma.m: The matlab function that simulates selection indicator variables \gamma from its posterior conditional distribution.
SimuPostLambda.m: The matlab function that simulates coefficients of covariates from their posterior conditional distribution. In the paper, the covariate is just the intercept of scalar-on-image regression.
SimuPostSigma2.m: The matlab function that simulates the variance of regression errors from its posterior conditional distribution.
SimuPostThetaH.m: The matlab function that simulates the DP values \theta_h from its posterior conditional distribution.
SimuPostWH.m: The matlab function that simulates the weights W_h of the DP values from their posterior conditional distribution.
SimuPostZh.m: The matlab function that simulates the DP cluster indicators Z_h of predictros from their posterior conditional distribution.
master.m: The matlab code that conducts the posterior simulations given data.
**Note** 1: The file master.m would call all the defined functions for posterior simulations, and output three files: Simu_gamma.txt file contiaining simulated \gamma,
Simu_ThetaH.txt file containing simulated DP values, and Simu_Zh.txt containing simulated DP cluster indicators of predictors.

**Note** 2: To run master.m, the user needs to provide three files: X.txt (an nxp predictor matrix), Y.txt (the response vector of length n), and Location.txt (a 3xp matrix denoting the spatial locations of p predictors).

**Note** 3: The user may run r file DataGeneration.r to generate data. This file will output three files: Location.txt of 1000 predictors defined on 10x10x10 lattice, Y.txt file of response variable of length 104, and X.txt file of 104x1000 pedictor matrix.

**Note** 4: The vaues of hyperparameters a & b for Ising prior are set for predictors located on 3d lattice. The user may use different sets of hyperparameters depending on data properties.

## Matlab Codes for Bayesian Modular and Indicator-based Dynamic Directional Model

BMIDDMfuns.zip: The compressed folder for BMIDDM codes.