DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer’s Manual P3–58

REGR_R2

The higher the correlation, the more accurate the set of data used for prediction. When the highest correlation (close to 1) is obtained, the predicted data is most accurate.

For example:

create table test(id int, num int);
insert into test values(1, 298),(2, 368),(3, 458),(4, 328),(5, 108),(6, 667),(7, 123),(8, 555);
Enter fullscreen mode Exit fullscreen mode

Calculate the correlation between two sets of data.

select count(*),regr_r2(t.num,test.num) from 
(select id-1 as id, num from test) as t,test where t.id=test.id ;

 COUNT(*) | REGR_R2(T.NUM,TEST.NUM)  
----------+--------------------------
       28 |       0.6088521468006012
(1 row)
Enter fullscreen mode Exit fullscreen mode
REGR_AVGX

regr_avgx(y, x) actually calculates the average of x (mathematical expectation), y has no role here.

Top comments (0)