How to make a linear regression in postgresql?

Asked

Viewed 143 times

1

I wish to make a simple linear regression directly in the database. I noticed that postgresql already has some statistical functions, which seems to me to be for this purpose (regr_slope(Y, X), regr_intercept(Y, X), regr_count(Y, X)...) and I’d like to understand that better.

In a simple regression Y=aX+b, regr_intercept(Y, X) would equal "b" and regr_slope(Y, X) equal to "the"?

1 answer

0


Yes. The command is regr_intercept(Y, X) returns the intercept, i.e., the value b of the equation Y=aX+b, and the command regr_slope(Y, X) returns the angular coefficient, also called the slope of the line.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.