0

I am working with daily precipitation measurements from nearly 1500 rain gauges. I have calculated the correlation between the measurements of each station and its 20 nearest neighbors. I also have the distances between the stations.

I am now trying to find the correlation decay distance (CDD) from the resulting correlation matrix. CDD is defined as the distance where the correlation between one station and all other stations decays below 1/e. I am following Hofstra and New's calculation of CDD:

enter image description here

Specifically, I am attempting to reproduce their Figure 2:

enter image description here

Based on this post, my first try was using SSasymp to fit a self-starting exponential decay function to my data. This is what I have so far:

library(data.table)

# load data
dat <- fread("https://www.dropbox.com/s/jgo5b91owpllbq3/cor_vs_dist.csv?dl=1", sep=",") # ~ 465 KB

# visually inspect it
plot(correl ~ dist, data=dat)

# fit a model using SSasymp
fit <- nls(correl ~ SSasymp(dist, Asym, R0, lrc), data=dat)
summary(fit)
coef(fit)
lines(dat$correl, predict(fit), col="red")

However, the fit is terribly poor:

enter image description here

So my questions are:

  1. How can I fit a better another exponential decay model to my data?
  2. Once the model is fit, how can I determine the 1/e value like in the referenced paper?

Any input highly appreciated!

thiagoveloso
  • 2,537
  • 3
  • 28
  • 57
  • 2
    Hello, this seems like a question for [Cross Validated](https://stats.stackexchange.com/) rather than stackoverflow. Maybe you'll have a better chance at answers there – RoB Mar 24 '20 at 13:34

1 Answers1

2

Your fit isn't bad, you are just plotting the predictions in the wrong way, using correl as the x-axis instead of dist.

Moreover, rather than predicting and plotting every unique value of dist in your dataset, it's better to predict and plot for a range of values of dist.

Here's a clean plot:

plot(correl ~ dist, data=dat)
lines(0:1000, predict(fit, newdata = data.frame(dist = 0:1000)), col="red")

enter image description here

Bas
  • 4,628
  • 1
  • 14
  • 16
  • Nice, thanks for catching that! But I still consider it a poor fit. I would like to adjust the line so it starts from closer to one instead of 0.3. – thiagoveloso Mar 24 '20 at 15:28