Français | English


The idea of spatially weighted context data first emerged from the TRACES project. Against the backdrop of comparative survey research on the impact of collective war experiences across the former Yugoslavia, variegated factors revealed a need for new context analytic tools. However, although the path that led us to spatially weighted context data was based on a particular substantive agenda and research site, there are good reasons to believe that the methodological challenges that were revealed by these particular contingencies are not completely bounded to these contingencies. Thus, in the following analysis, we aimed to transfer this partially novel approach to contextual data analysis onto other research fields and sites and to stimulate a wider debate on the current methods of contextual analysis and their possible alternatives or extensions.

Descriptive and multilevel modelling analyses using spatially weighted context data complement classic multilevel regression in conditions where critical assumptions regarding the underlying structure of contextual data do not fully apply, more specifically, when contextual units lack clear-cut boundaries. In these circumstances, spatial weighting functions allow researchers to study open-ended contextual influences that unfold as a decreasing function of geographic and/or social distances.

The R package spacom has been developed to facilitate the use of the spatially weighted context data approach. Spacom’s functions can be used to construct and describe spatially weighted context data, to introduce spatially weighted contextual indicators in multilevel models (and estimate models through bootstrap procedures that provide robust point estimates and standard errors), and to diagnose spatial dependency in residuals from multilevel models. Typical analyses with spacom consist of four steps; first, the creation of spatial weights by applying a kernel function with a user-defined bandwidth value (i.e., scale) to a distance matrix provided by the user; second, the creation and description of spatially weighted context data from user-provided precise contextual indicators or micro-survey data; third, the performance of multilevel analyses with spatially weighted contextual indicators, including functions that provide robust point estimates and adjusted standard errors, obtained by stratified bootstrap resampling; fourth, the test of spatial dependency in upper-level residuals from spatially weighted multilevel analysis. Furthermore, spacom includes functions for exploratory scalar analysis, i.e., an analytical strategy for the direct examination of the scale effects of spatially weighted contextual indicators.

Spacom can be downloaded and installed from the Comprehensive R Archive Network (CRAN). The user has to provide several datasets: a dataset with individual level predictor and outcome variables, a dataset with micro-level data to generate contextual indicators by aggregation and/or a dataset with precise contextual indicators, and a distance matrix (a square matrix consisting of distances between contextual level units). A new helper package, called geospacom, now facilitates the generation of distance matrices used in the spacom package.

For any questions about spacom, please contact,, or

Reference : Junge, T., Penic, S., Cossutta, M., & and Elcheroth., G. (2013). Spacom: Spatially Weighted Context Data for Multilevel Modelling. R package version 1.0-0.


 in this site:

Géopolis - CH-1015 Lausanne  - Suisse  -  Phone +41 21 692 38 40  -  Fax  +41 21 692 38 45