I have two variables represented as a time-series with monthly observations. I am attempting to create a scoring system -1 to 1 where: 1 represents a strong shift in trend from B to A and -1 represents a strong shift in trend from A to B. Ultimately, I am looking to score the magnitude of trend change / momentum from A to B (vice-versa).
For example, given the sample data points in Example 1 below, the trend in A drops instantly and the trend in B increases. So the score should be close to -1.
Example 1
A = {20, 0, 0, 0, 0}
B = {0, 20, 15, 18, 30}
Conversely, the sample data points in Example 2 below illustrates the trend in B dropping instantly and the trend in A increases. So the score should be close to 1.
Example 2
A = {0, 5, 10, 12, 8}
B = {5, 0, 0, 0, 0}
Lastly, the sample data points in Example 3 below is mixed and the score would be negative but not as negative as in Example 1.
Example 3
A = {5, 8, 7, 4, 3}
B = {0, 0, 2, 5, 10}
I tried perhaps utilizing correlation or Granger causality, but did not quite address the requirements. Tried to search around but could not quite hone down to a feasible solution. Is there a general formula for scoring the trend changes between A and B?
The first thing that comes to mind would be the Pearson Correlation Coefficient, also called Pearson's R. It is a measure of linear correlation and takes values between -1 and 1. You can compute it in Python for example like this:
Now I see that this does not fit the description of your examples (Pearsons R would be close to -1 in all three cases), but I'm not sure there is anything that would fit it, and developing a new measure of correlation would be far beyond the scope of an answer here. Besides this, perhaps it's a good idea to think if the behavior you're describing is really desirable and consistent:
In summary, the three examples are most likely not a sufficient basis to identify a correlation measure that would do exactly what you want it to. The field of assessing variable dependence is vast and it's easy to get lost in the intricacies. I'd recommend you take something simple and well-understood like Pearson's R and adapt it if really necessary, but make sure you know what exactly you need before you do that.