I have come across 2 different methods for calculating the R-Squared of price against time. And though the results are very close, I notice if looking as far as three decimal places in the calculated result at times there is a minor difference.
I am wondering if one method is perhaps "more" correct than the other.
/**R-Squared**/
Periods = 20; // set the periods
correlationcoefficientR = Correlation( Cum(1), Close, Periods ); //R the correlation coefficient
R2 = correlationcoefficientR ^ 2; // coefficient of determination denoted R2
// a different way to calculate in afl, using BarIndex() instead of Cum(1)
// BarIndex() returns zero-based bar number - the same as Cum(1)-1
anotherR2 =Correlation( BarIndex(), Close, periods ) ^ 2;
Filter=1;
AddColumn(BarIndex(),"BarIndex");
AddColumn(Cum(1),"Cum");
AddColumn(R2, "R-Squared",1.3);
AddColumn(anotherR2, "anotherR2", 1.3);
Plot(r2, "R-Squared("+periods+")", colorBlue, styleLine);
Plot(anotherR2, "barIndex R2("+periods+")", colorYellow, styleThick);
Attachment(s) from portfoliobuilder99@gmail.com [amibroker] | View attachments on the web
1 of 1 Photo(s)
1 of 1 File(s)
Posted by: portfoliobuilder99@gmail.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
EmoticonEmoticon