# Package for implementing regression with spatial correlation

**URL:** https://discourse.julialang.org/t/package-for-implementing-regression-with-spatial-correlation/111893
**Category:** General Usage
**Tags:** package, regression, geospatial
**Created:** [March 20, 2024, 5:16pm UTC](https://discourse.julialang.org/t/package-for-implementing-regression-with-spatial-correlation/111893 "2024-03-20T17:16:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JedPhillips](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@JedPhillips](https://discourse.julialang.org/u/JedPhillips)
#### Post date: [March 20, 2024, 5:16pm UTC](https://discourse.julialang.org/t/package-for-implementing-regression-with-spatial-correlation/111893/1 "2024-03-20T17:16:51Z")

</div>

Are there any Julia packages that allow one to specify spatial correlation (or any correlation structure) when implementing generalizes least squares regression? I’m looking for something akin to the gls() function in the nlme package in R, which allows one to specify variables that dictate correlation, along with correlation structure (e.g., AR1, symmetric, etc).

I’ve looked around a bunch but haven’t found anything even remotely close. Is anyone aware of something that might work?

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [March 24, 2024, 11:03pm UTC](https://discourse.julialang.org/t/package-for-implementing-regression-with-spatial-correlation/111893/2 "2024-03-24T23:03:59Z")

</div>

I have a work-in-progress: [MeasurementErrorModels.jl](https://github.com/Mattriks/MeasurementErrorModels.jl). It allows lag-covariance matrices for both the predictor noise and response noise. I’ve added a [github gist](https://gist.github.com/Mattriks/c297542525abbd1a4b5ec7b41370d2fe) which illustrates a spatial model example. I’m currently working on adding models that allow both noisy and noiseless predictors, and Fisher information derived confidence intervals. Currently I assume that the noise _covariances_ are known, but I’m interested in implementing models where e.g. only the _correlation_ structure is known too.
