简体   繁体   中英

R - How to find 1/e in an exponential decay model?

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:

在此处输入图片说明

Specifically, I am attempting to reproduce their Figure 2:

在此处输入图片说明

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:

在此处输入图片说明

So my questions are:

  1. How can I fit a better其他 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!

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")

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM