DHARMa icon indicating copy to clipboard operation
DHARMa copied to clipboard

Spatial variogram using DHARMa residuals

Open florianhartig opened this issue 2 years ago • 1 comments

From a DHARMa user via email:

Based on ?testSpatialAutocorrelation, I have been making variograms using the gstat package. I am hoping to determine the range beyond which there is no spatial autocorrelation. I am running this routine for each of >100 tree species.

I have 2 questions I was hoping to get your advice on -- code is below.

  1. To fit the variogram, which residuals are best to use? I see 3 options:

    a. the original residuals from the glmm, b. the initial simulated residuals from DHARMa, or c. the grouped, recalculated residuals from DHARMa (which I used for calculating Moran's I)?

  2. If I use the residuals from DHARMa (either b or c above), the sill is always ~ 0.08 -- even though I'm running this over and over again for each tree species. Is there a reason you would expect this behavior? Or perhaps I should ask the gstat authors?

florianhartig avatar Aug 31 '21 20:08 florianhartig

Regarding 1: My thinking is that it is better to use DHARMa residuals because the change of the distribution with the mean in GLMM distribution such as the Poisson / binomial could show up in variograms. That being said, I have never really looked into creating an example that shows this, so I'm not sure how much of a problem that is. I think you have to ask one a variogram expert about whether it's better to aggregate or not. I'm not sure what happens in the variogram calculation if you have several data points in the same location. I would suspect that this is averaged over, so my guess would be that it's better to choose option b) = normal DHARMa residuals, but I cannot say for sure.

Regarding 2: I have no idea. Maybe it's just the right value? The fact that b/c doesn't seem surprising, as those are the same residuals, just grouped.

florianhartig avatar Aug 31 '21 20:08 florianhartig