Skip to content
Prev 15287 / 20628 Next

Repeated Observations Linear Mixed Model with Outside-Group Spatial Correlation

Thanks for the responses everyone.

David and Ben - I am in the midst of trying the hack right now. I created a
single 'group' with all observations. Then I constructed the correlation
distance matrix using three variables latitude, longitude, and *time*. This
way I can capture the correlations from repeated observations (they have
the same latitude and longitude) as a function of their temporal distance
(time) and the correlations across stations as a function of their spatial
and temporal distance. I think this structure is actually better and more
flexible. I am still trying to figure out how to determine the tradeoff
between spatial distance and temporal distance that I want. Also, as Ben
suggested this method appears to be quite inefficient. The model has been
running for 11 hours and is using around 12gb of RAM. I think I might
create groups by clustering the stations geographically to reduce the
computational burden of what is now 12,271x12,271 correlation matrix.

Dexter -  lm::lm(), nlme::lme(), and lme4::lmer() all have the function
resid(model) that provides the residual for each observation in the model.
I used the package "ape" to calculate the Moran I.

model_spatial = lme(log(counts) ~ log(Population)
                 +Drive +Med_Income + Buff2 +Rain + Temperature
                 , data = Data, random = ~1|id, method = "ML" )

model_All = lmer(log(counts) ~ log(Population)
                 +Drive +Med_Income + Buff2 +Rain + Temperature
                 + (1|id)
                  , data = Data )
Data$resid_spat = resid(model_spatial )
Data$resid_all = resid(model_All )

Thierry - I assume you meant "nlme *cant *do what you would like to do"?

I will check out the INLA, spaMM, and HSAR packages if the nlme workaround
does not actually work.
On Wed, Mar 22, 2017 at 11:02 AM, Ben Bolker <bbolker at gmail.com> wrote: