# Paper and R package for spatial models

**URL:** <https://discourse.mc-stan.org/t/paper-and-r-package-for-spatial-models/16336>\
**Category:** Publicity\
**Tags:** spatial, public-health, rstantools, ecology\
**Created:** [July 2, 2020, 2:37am UTC](https://discourse.mc-stan.org/t/paper-and-r-package-for-spatial-models/16336 "2020-07-02T02:37:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmcd](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/cmcd/32/8601_2.png) [@cmcd](https://discourse.mc-stan.org/u/cmcd)\
**Post date:** [July 2, 2020, 2:37am UTC](https://discourse.mc-stan.org/t/paper-and-r-package-for-spatial-models/16336/1 "2020-07-02T02:37:41Z")

</div>

Hi everyone,

I’d like to share some work on spatial models in Stan recently published in [Spatial Statistics](https://doi.org/10.1016/j.spasta.2020.100450)

The paper is on eigenvector spatial filter (ESF) models (known as principal coordinates of neighbor matrices (PCNM) in ecology), which estimate a spatially varying intercept (or map pattern) by introducing a bunch of the eigenvectors of a transformed spatial connectivity matrix into a GLM. The trick is to estimate the coefficients of all these synthetic map patterns, which is usually approached as a variable selection problem.

The paper I link to there uses the regularized horseshoe (RHS) prior to estimate those coefficients (rather than select/drop eigenvectors). Thanks @jpiironen and @avehtari! The number of important eigenvectors is largely a function of the degree of auto-correlation in the outcome variable, so setting the hyper-priors for the RHS prior is in many cases quite easy.

I put these models into an R package called `geostan`.

> **[ConnorDonegan/geostan](https://github.com/ConnorDonegan/geostan)**
>
> Bayesian Spatial Analysis with Stan. Contribute to ConnorDonegan/geostan development by creating an account on GitHub.

My goal is to make the package accessible to researchers who are somewhat experienced with R but new to spatial models, or who are new to Bayesian modeling. I borrowed heavily from `rstanarm` for syntax and default priors (hopefully in a good way?), and also put in options for using intrinsic auto-regressive and BYM2 models following Stan code from @mitzimorris

If anyone’s interested in trying out the package, I’d love to hear your feedback.

I’m sure from a development standpoint there are a bunch of .stan files that should be combined, but I’ve been dreading that task.
