Bayesian spatial analysis
Two updates:
There are three updates related to spatial connectivity matrices:
browseVignettes('geostan')
), written for new users.geostasn::n_nbs
function)There was one change to the geostan::predict method:
Updates to geostan:
prep_icar_data
has been fixedinstall_github
Details:
The model fitting functions (stan_glm
, stan_car
, etc.) now allow for missing data in the outcome variable (not covariates). This is explained in the geostan::stan_glm documentation, next to the discussion of handling censored observations. When missing observations are present, there will (only) be a warning issued. This functionality is available for any GLM (stan_glm
), any ESF model (stan_esf
), and any model for count data (Poisson and binomial models including CAR and SAR models). The only models for which this functionality is not currently available are CAR and SAR models that are being been fit to continuous outcome variables.
The prep_icar_data
function, which is used inside stan_icar, did not have the expected behavior in all cases - for some cases the function would fail to create the data required for the ICAR models, and the models would fail. (This means that it is unlikely that any results obtained from the models were negatively influenced by this issue - if you obtained results, then the bug probably didn't affect you.) This has been fixed thanks to this pull request.
New install instructions are found on the package home page https://connordonegan.github.io/geostan/ Please report any difficulties with installation.
This release updates some of the vignettes (especially the one on measurement error models) and incorporates an important update to StanHeaders, which addresses an issue that may have caused installation errors for some users.
Minor updates
This release was built using rstan 2.26.23, which incorporates Stan's new syntax for declaring arrays. Some models seems to run a little bit faster, but otherwise there are no changes that users should notice.
A new vignette shows how to implement some of geostan's spatial models directly in Stan, using the custom Stan functions that make the CAR and SAR models sample quickly, and using some geostan functions that make the data cleaning part easy.
The warnings issued about the sp package can be ignored; these are due to geostan's dependence on spdep, which imports sp but does not use any of the deprecated functions.
This release fixes some issues that were introduced with the slim and drop arguments (in v0.5.0).
The package now provides some support for spatial regression with raster data, including for layers with hundreds of thousands of observations (possibly more, depending on one’s computational resources). Two new additions make this possible.
prep_sar_data2
and prep_car_data2
These two functions can quickly prepare required data for SAR and CAR models when using raster layers (observations on a regularly spaced grid). The standard and more generally applicable functions, prep_car_data
and prep_sar_data
, are limited in terms of the size of spatial weights matrices they can handle. These new functions are discussed in a new vignette titled “Raster regression." See vignette("raster-regression", package = "geostan")
.The PDF documentation has been improved—previously, multi-line equations were not rendered properly. Now they render correctly, and a mistake in the description of Binomial CAR models has been corrected.
This pre-release is connected to the JOSS article: geostan: An R package for Bayesian spatial analysis. Some additional changes were implemented before sending version 0.4.1 to CRAN.
sp_diag
) will now take a spatial connectivity matrix from the fitted model object provided by the user. This way the matrix will be the same one that was used to fit the model. (All of the model fitting functions have been updated to support this functionality.)residuals
, fitted
, spatial
, etc.) were previously packed into one page. Now, the documentation is spread over a few pages and the methods are grouped together in a more reasonable fashion.The simultaneously-specified spatial autoregressive (SAR) model---referred to as the spatial error model (SEM) in the spatial econometrics literature---has been implemented. The SAR model can be applied directly to continuous data (as the likelihood function) or it can be used as prior model for spatially autocorrelated parameters. Details are provided on the documentation page for the stan_sar
function.
Previously, when getting fitted values from an auto-normal model (i.e., the CAR model with family = auto_gaussian()
) the fitted values did not include the implicit spatial trend. Now, the fitted.geostan_fit
method will return the fitted values with the implicit spatial trend (by default; change using the trend
argument); this is consistent with the behavior of residuals.geostan_fit
, which has an option to detrend
the residuals. This applies to the SAR and CAR auto-normal specifications. For details, see the documentation pages for stan_car
and stan_sar
.
The documentation for the models (stan_glm
, stan_car
, stan_esf
, stan_icar
, stan_sar
) now uses Latex to typeset the model equations.