Learn R Programming

cudaBayesreg (version 0.3-2)

cudaMultireg.slice: CUDA Parallel Implementation of a Bayesian Multilevel Model for fMRI Data Analysis

Description

cudaMultireg.slice provides an interface to a CUDA implementation of a Bayesian multilevel model for the analysis of brain fMRI data.

Usage

cudaMultireg.slice(slicedata, ymaskdata, R, keep = 5, nu.e = 3,
	fsave = NA, zprior=FALSE)

Arguments

slicedata
list(slice=slice, niislicets=niislicets, mask=mask, dsgn=dsgn); input slice data used in simulation as returned by read.fmrislice
ymaskdata
list(yn = yn, kin = kin, nreg = nreg); masked and standardized slice data as returned by premask
R
number of MCMC draws
keep
MCMC thinning parameter: keep every keepth draw (def: 5)
nu.e
d.f. parameter for regression error variance prior (def: 3)
fsave
filename for saving the MCMC simulation (def: NULL do not save)
zprior
boolean {T,F}; default {F} - use just a mean for samp{Z}

Value

  • a list containing
  • betadrawnreg x nvar x R/keep array of individual regression coef draws
  • taudrawR/keep x nreg array of error variance draws
  • DeltadrawR/keep x nz x nvar array of Deltadraws
  • VbetadrawR/keep x nvar*nvar array of Vbeta draws

concept

  • bayes
  • MCMC
  • Gibbs Sampling
  • hierarchical models
  • linear model

Details

The statistical model implemented in CUDA was specified as a Gibbs Sampler for hierarchical linear models with a normal prior. This model has been analysed by Rossi, Allenby and McCulloch in Bayesian Statistics and Marketing, Chapter 3, and is referred to as rhierLinearModel in the R-package bayesm. The main computational work is done in parallel on a CUDA capable GPU. Each thread is responsible for fitting a general linear model at each voxel. The CUDA implementation has the following system requirements: nvcc NVIDIA Cuda Compiler driver, g++ GNU compiler (nvcc compatible version). The package includes source code files to build the libraries libcutil.so and newmat11.so. The former, is a shared version of the utility library used by the NVIDIA GPU Computing SDK software (see cudaBayesreg/src/Makefile for configuration). The later, is a matrix library by R. B. Davies used by the package's host C++ code.

References

Adelino Ferreira da Silva, A Bayesian Multilevel Model for fMRI Data Analysis, submitted for publication. Rossi, Allenby and McCulloch, Bayesian Statistics and Marketing, Chapter 3. http://faculty.chicagogsb.edu/peter.rossi/research/bsm.html Davies, R.B. (1994) Writing a matrix package in C++. In OON-SKI'94: The second annual object-oriented numerics conference, pp 207-213. Rogue Wave Software, Corvallis. http://www.robertnz.net/cpp_site.html.

See Also

read.fmrislice, read.Zsegslice, premask, pmeans.hcoef, regpostsim, plot.hcoef.post, post.simul.hist, post.ppm, post.tseries, post.randeff, post.shrinkage.mean

Examples

Run this code
## Simulation using the visual/auditory test dataset "fmri"  
slicedata <- read.fmrislice(fbase="fmri", slice=3, swap=TRUE)
ymaskdata <- premask(slicedata)
fsave <- "/tmp/simultest1.sav"
out <- cudaMultireg.slice(slicedata, ymaskdata, R=2000, keep=5, nu.e=3,
  fsave=fsave, zprior=FALSE )
## Post-processing simulation
post.ppm(out=out, slicedata=slicedata, ymaskdata=ymaskdata, vreg=2)
post.ppm(out=out, slicedata=slicedata, ymaskdata=ymaskdata, vreg=4)
## "bayesm" summaries 
require("bayesm")
summary(out$betadraw)
summary(out$Deltadraw)
plot(out$Deltadraw)
summary(out$Vbetadraw)
##
## Random effects simulation using the SPM auditory dataset "swrfM*" 
fbase <- "swrfM"
slice <- 21
slicedata <- read.fmrislice(fbase=fbase, slice=slice, swap=TRUE )
ymaskdata <- premask(slicedata)
fsave <- "/tmp/simultest3.sav"
out <- cudaMultireg.slice(slicedata, ymaskdata, R=2000, keep=5, nu.e=3,
  fsave=fsave, zprior=TRUE)
post.ppm(out=out, slicedata=slicedata, ymaskdata=ymaskdata, vreg=2)

Run the code above in your browser using DataLab