weighted correlation in Q?

76 views
Skip to first unread message

Matt Fang

unread,
Jun 7, 2021, 10:34:29 AMJun 7
to Kdb+ Personal Developers
I know there is a correlation function in Q.  https://code.kx.com/q/ref/cor/
Is there a "weighted correlation"? 

Ajay Rathore

unread,
Jun 7, 2021, 11:29:13 AMJun 7
to personal...@googlegroups.com
There is no inbuilt weighted correlation, but you can easily implement Pearson Weighted Correlation as follows

wcov: {[x;y;w] w wavg (x-w wavg x)*y-w wavg y}    // weighted covariance

wcor: {[x;y;w] wcov[x;y;w]%sqrt wcov[x;x;w]*wcov[y;y;w]}   // weighted correlation


-Ajay

On 7 Jun 2021 at 15:11:16, Matt Fang <matt....@gmail.com> wrote:
I know there is a correlation function in Q.  https://code.kx.com/q/ref/cor/
Is there a "weighted correlation"? 

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbpl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/personal-kdbplus/ef0ab020-1cc9-44fe-a008-189fd012c114n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages