This is an update to my previous post on using bootstrapping to test for differences in the slopes of 2 lines.
I tested my previous method by additionally comparing the slope of lines that are apparently parallel (fig below).
This is a very similar situation to the previous example, just a different data set. When I ran the old method on new data I got a very significant difference with a t-test comparing the means of these slopes, which I shouldn't be seeing. This poked a big hole in the way I had run things previously and as I thought about it, it made sense. The t-test is very sensitive to the n of the two populations being compared. So the 10,000 replicates from each bootstrapped sample was going to reveal a significant difference between the two almost no matter how similar the slopes were.
So I searched the internet a little to see what other folks had come up with. I found this stackexchange that provided an answer.
In a nutshell, what I ended up doing was to use the same bootstrapped slopes from my previous method, take the difference between the two populations of slopes (producing 10,000 differences), and then among those differences I calculated the proportion of those that were less than or equal to zero (which is basically the probability that the slopes were equal or overlapping). I then multiplied the proportion by two (to account for two tails) and then used the result to assess significance.
Here's the R code and output from what I did on the parallel lines above:
#take the differences, calculate the % of samples where the difference is <= 0 (where values are equal or overlap) and multiply that by 2. bootdiff.eea <- boot.eea.dry$t - boot.eea.wet$t hist(bootdiff.eea) overlap.eea <- sum(ifelse(bootdiff.eea <= 0, 1, 0)) # > overlap.eea # [1] 3352 2*overlap.eea/length(bootdiff.eea) # [1] 0.6704
Here's the histogram of differences:
So you can see that these two parallel slopes are definitely not significantly different.
Here's the same analysis with the data from the previous post:
bootdiff.otu <- boot.wet$t - boot.dry$t hist(bootdiff.otu) overlap.otu <- sum(ifelse(bootdiff.otu <= 0, 1, 0)) # > overlap.otu # [1] 1 2*overlap.otu/length(bootdiff.otu) # [1] 0.00020002
Histogram of differences:
There's a strong significant difference between these slopes, which is visually obvious.
Feel free to comment or contact me if you have any questions or thoughts about this method. Thanks!












