Forum Discussion
Greg_Deckler
8 years agoCommunity Champion
Serious Issue with New Correlation Coefficient Quick Measure
OK, in my opinion, there is a serious deficiency in the new Correlation Coefficient Quick Measure. The issue is that it does not factor in the possibility that there are more rows in, say Y than in X...
Greg_Deckler
8 years agoCommunity Champion
I would suggest perhaps this:
{X MEASURE} and {Y MEASURE} correlation for {CATEGORY} =
VAR __CORRELATION_TABLE = FILTER(ADDCOLUMNS(VALUES({CATEGORY}),"__X",CALCULATE({X MEASURE})),"__Y",CALCULATE({Y MEASURE}))), AND (
NOT ( ISBLANK ( [__X] ) ),
NOT ( ISBLANK ( [__Y] ) )
))
VAR __COUNT =
COUNTX(
KEEPFILTERS(__CORRELATION_TABLE),
[__X]
)
VAR __SUM_X =
SUMX(
KEEPFILTERS(__CORRELATION_TABLE),
[__X]
)
VAR __SUM_Y = SUMX(KEEPFILTERS(__CORRELATION_TABLE), [__Y])
VAR __SUM_XY =
SUMX(
KEEPFILTERS(__CORRELATION_TABLE),
[__X] * [__Y] * 1.
)
VAR __SUM_X2 =
SUMX(
KEEPFILTERS(__CORRELATION_TABLE),
[__X] ^ 2
)
VAR __SUM_Y2 =
SUMX(
KEEPFILTERS(__CORRELATION_TABLE),
[__Y] ^ 2
)
RETURN
DIVIDE(
__COUNT * __SUM_XY - __SUM_X * __SUM_Y * 1.,
SQRT(
(__COUNT * __SUM_X2 - __SUM_X ^ 2)
* (__COUNT * __SUM_Y2 - __SUM_Y ^ 2)
)
)