0

I am going through the documentation: https://www.postgresql.org/docs/9.5/static/functions-aggregate.html

for the aggregate functions: corr(Y, X), covar_pop(Y, X) but I cannot find any valid example.

Can you please show me how to use these two functions or pointing me to some extra doc/examples?

asked May 9, 2017 at 13:19

2 Answers 2

1

There is an answer on https://stackoverflow.com/questions/3015846/calculating-correlation-coefficient-using-postgresql that is relevant for you.

Corr(y,x) is pretty easy. Say you have a table of people with columns height and weight. You wanted to know if those were correlated.

select corr(height,weight) from people;
answered May 9, 2017 at 14:11
0

You can use these functions as any function in PostgreSQL. Here in a SQL Query:

SELECT corr(Y,X) FROM myTable;

If you need documentation about correlation or population covariance, you will find help here: https://en.wikipedia.org/wiki/Correlation_and_dependence https://en.wikipedia.org/wiki/Covariance

answered May 9, 2017 at 14:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.