# Software

## spBayes: Univariate and Multivariate Spatio-temporal Modeling

spBayes fits univariate and multivariate models with Markov chain Monte Carlo (MCMC). Core functions include:

- spLM – univariate Gaussian regression with spatial random effects
- spMvLM – multivariate Gaussian regression with spatial random effects
- spMisalignLM – multivariate Gaussian regression with spatial random effects for misaligned data
- spGLM – univariate Logistic and Poisson regression with spatial random effects
- spMvGLM – multivariate Logistic and Poisson regression with spatial random effects
- spMisalignGLM – multivariate Logistic and Poisson regression with spatial random effects for misaligned data
- spDynLM – univariate Gaussian regression with dynamic space-time random effects

For the core functions, a predictive process model can be specified for large data sets. Also adaptive MCMC is available for those parameters that cannot be updated using Gibbs. Course material and illustrations can be found here.

The stable version is available on CRAN.

## spNNGP: Spatial Regression Models for Large Datasets using Nearest Neighbor Gaussian Processes

spNNGP fits Gaussian univariate Bayesian spatial regression models for massive datasets using "Nearest Neighbor Gaussian Processes (NNGP)". Core functions include:

- CHM - Canopy Height Model from NASA Goddard's LiDAR Hyperspectral and Thermal (G-LiHT)
- spConjNNGP - Function for fitting univariate Bayesian conjugate spatial regression models
- spNNGP – Function for fitting univariate Bayesian spatial regression models
- spPredict - Function for prediction at new locations using spNNGP models

The stable version is available on CRAN.

## MBA: Multilevel B-spline Approximation

MBA generates surfaces interpolated from scattered data using Multilevel B-Splines. The most recent version is available on CRAN.

## B2Z: Bayesian Two-Zone Model

This package fits the Bayesian two-Zone Models. The most recent version is available on CRAN.

- lapack.cpp -- a C++ file containing several matrix algebra functions, including basic matrix and vector operations (addition, subtraction, multiplication, kronecker products), matrix inversion, solving linear systems, determinants, log-determinants, matrix decompositions (Cholesky, LU, QR and SVD), eigen-values and eigen-vectors etc. Only C++ classes have been used (not templates) to make this more accessible (for example C programmers can easily port these functions). The header file containing the class definitions is lapack.h.
- generators.cpp -- a C++ file containing some useful random number generation routines from different distributions: uniform, normal, exponential, gamma, beta, multinomial, multivariate normal, Wishart and inverted-Wishart. The header file is generators.h
- A makefile format for creating a static library, StatPack.a is also included.

## **C++ programs**

## StatPack.zip is a zip file containing the following files:

- areal.cpp -- C++ functions for statistical modelling of areal data . Includes the CAR prior and some functions for creating the neighborhoods.
- geodesy.cpp -- C++ functions for calculating geodetic distances based upon latitude-longitude and also for euclidean distances. These are useful for geostatistical modelling.

## Spatial.zip is a zip file containing the following files:

- This is a Java Archive file containing the JAMA (JAvaMAtrix) package from NIST (I have added a kronecker method for kronecker products and a symmetrize method that helps in stabilizing symmetric matrices for Cholesky decompositions). Also included is a Distribution package with classes for random number generation, and some useful functions for spatial modelling. Just add StatPack.jar to your CLASSPATH and you should be able to access the methods.

## **Java Programs**

## StatPack.jar

- This is a JAVA package providing a Java interface for numerical linear algebra using the LAPACK and BLAS libraries. This package contains two different versions: JaLAJni and JaLAJniLite. Both of them serve as a Java interface for LAPACK and BLAS. The main difference is that JaLAJni calls an intermediate C interface - cblas and lapacke - which requires previous installation. So if you want to use JaLAJni, you have to install cblas and lapacke first (detailed installation instructions are available from the website). JaLAJniLite is a simplified version which requires no installation of any libraries other than LAPACK and BLAS that can be installed in Linux/Windows/MacOS either as precompiled binaries or built from source using Fortran compilers (such as gfortran).

## JaLAJni

- This contains some simple linear model examples that are fitted using MCMC. They include Gibbs samplers, component-wise Metropolis (in subdirectory Metropolis) and joint Metropolis (in two different Java styles, uner Metropolis2 and Metropolis3). These do not really need MCMC, but can prove useful for someone starting to hard-code MCMC. Uses the statpack.jarfile.

## LinearModel.zip

- Installing geo-R: The file InstallingGeoR is a simple text file containing instructions to install geoR on R for Windows and Linux.
- Getting started with geo-R: The file Book.R is a simple introduction to some geoR functions that illustrate some spatial analysis tools using the scallops data, found in scallops.txt.
- A Bayesian kriging example: The file Bayes1.R is a first example of Bayesian kriging in geoR on the data TemperaturePrecipitationElevation.txt.
- distonearth.R is a R source file containing functions for computing distances on the earth's surface using different methods. Some of these have been used in my Biometrics paper On Geodetic Distance Computations in Spatial Modelling. as given in the file GeodesicsExample.R.
- Slopes.zip is a zip file containing the R program to compute spatial gradients using the methods described in Banerjee, S., Gelfand, A.E. and Sirmans, C.F (2003). "Directional Rates of Change Under Spatial Process Models".
*Journal of the American Statistical Association*,**98:**946-954. - OrderFreeGMCARwin32.zip and OrderFreeGMCARlinux.zip are zip files containing the programs and the Minnesota cancer data used in the manuscript Jin, X., Banerjee, S. and Carlin, B.P. (2006) Order-free Coregionalized Areal Data Models with Application to Multiple Disease Mapping. The programs are written in C to harness maximum efficiency in terms of speed and use the Rlapack and Rblas libraries for matrix computations. They can be run from within R by sourcing the "mcar.R" function present in the directory. The Linux version includes a Makefile that compiles and creates the mcar_main.so dynamic library which is dynamically loaded by mcar.R.

## ** Other R Programs **

- CBCScodes.txt is a text file containing the WinBUGS programs to compute cure rate models using the methods described in Cooner, F., Banerjee, S., Carlin, B.P. and Sinha, D. (2006). "Flexible Cure Rate Modelling Under Latent Activation Schemes".
*Journal of the American Statistical Association*, (to appear).