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?

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;
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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.