R code implementing the spatial regression decision process