Discussion of article "R-squared as an estimation of quality of the strategy balance curve" - page 2
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Figure 19: LR-Correlation distribution for 10,000 random walks
Figure 20: Distribution of R^2 for 10,000 random walks
I don't see how R^2 can take the negative values that are shown in the second graph? Yes and there are questions with the first graph. If the linear regression is plotted correctly, it seems like the Pearson's RQ (LR) should not be negative. But in the graph it is not. Where am I wrong?
Got it. I'm not wrong anywhere, it's just that the graphs have custom R^2 and LR - multiplication by -1 of the real value occurs if the last element of the numerical series is less than the first. It would be good to write about it before the graphs.
In the paper, linear regression is considered with an error - via CLinReg::LRLine.
Proof
Result
The sign is incorrect. Alternative LR implementation (CAlglib::LRBuild + CAlglib::LRUnpack) counts correctly:
The graphs of the LR Correlation and R^2 distributions for the 10,000 independent examples that are presented in the article show that R^2 != LR^2.
I don't understand why the second degree of the original "concave" distribution makes it "flat"?This is where I was proven wrong. To me, the statement is not obvious at all
What is surprising is that by a simple mathematical action (by raising to the second degree) we have completely removed the unwanted marginal effects of the distribution.
So I decided to experimentally confirm via animation (not to take my word for it)
It seems to be like this.
Fig. 21: R^2 value as a custom optimisation criterion
Where in MQL LR Correlation, which is on the picture? Or this and many other parameters are calculated only for single runs, so they are absent in ENUM_STATISTICS?
If so, they suggest to calculate this parameter from the reasonable considerations mentioned in this article: by equity without MM and squared.
ZY I measured how much time it takes to calculate GetCustomR for an array of a million values (like equity) - 2.5 seconds. That's a lot of time. Everything is spent on LR calculation(CAlglib::LRBuild + CAlglib::LRUnpack). But sometimes curved LR through CLinReg::LRLine is an order of magnitude faster. If you dope it up, it becomes tolerable in Optimisations as an Optimisation criterion.
Oh! I always thought it was 100. Thanks, interesting article.
Yes, that's a number I've come across in reputable books on R and statistics. But sorry couldn't find the link, so sorry.
It is also common to perform significance tests on the regression coefficient. Even Alglib has them :-)
Obviously, the tests are for normal distribution. We got a uniform distribution.
PearsonCorrelationSignificance(), SpearmanRankCorrelationSignificance().
Thanks for the link, I'll remember it.
ZY Wrong statement
R^2 is nothing but the correlation between a graph and its linear model
Yes indeed, a gross error in wording. I'm surprised I even wrote such a thing. I will correct it.
When you look at all the other MQL-codes, you don't understand why they are given, because they are completely unreadable without CStrategy knowledge
CStrategy is needed only for collecting requisites. The main code, as it was rightly noted, is the actual calculation of R2.
The code for calculating "equity", suitable for R^2. It is written in MT4-style, it is not difficult to translate it to MT5....
Let's study it.
I agree with this, all the rest will have to be ripped out of classes to add to your system... it would be better to have everything in separate f-iases or a separate includnik.
Take your equity calculation (or the code presented by fxsaber) as a double-array and insert it into the R^2 calculation function. You don't need to tear out anything, you don't need to use classes and CStrategy.
I don't understand how R^2 can take negative values as shown in the second graph? There are also questions with the first graph. If the linear regression is constructed correctly, it seems that Pearson's LR should not be negative. But in the graph it is not. Where am I wrong?
Got it. I'm not wrong anywhere, it's just that the graphs have custom R^2 and LR - multiplication by -1 of the real value occurs if the last element of the numerical series is less than the first. It would be good to write about this before the graphs.
It is hidden in the article:
Our script calculates both LR Correlation and R^2. We will see the difference between them a little later. There is a small addition to the script. We will multiply the resulting correlation coefficient by the final sign of the synthetic graph. If we end up with a result less than zero, the correlation will be negative, if more - positive. This is done in order to quickly and easily separate negative outcomes from positive ones without having to resort to other statistics. This is how LR Correlation works in MetaTrader 5, and R^2 will be built according to the same principle.