Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pearson correlation (r) to lineal regression #332

Open
fredyagomez opened this issue Sep 5, 2018 · 2 comments
Open

Add Pearson correlation (r) to lineal regression #332

fredyagomez opened this issue Sep 5, 2018 · 2 comments

Comments

@fredyagomez
Copy link

Just checking if this worths a PR. Currently Lineal Regression returns m and b, but you always want to check R square attached to see how well the fit was. I know there is a R-square function but would be handy to have this one returned from the function since all formulas are already there.

Planning to push this one
image

which will translate to something like:

  //Pearson correlation
  r = (dataLength * sumXY - sumX * sumY) / 
    (Math.sqrt(dataLength * sumX2 - sumX * sumX) * Math.sqrt(dataLength * sumY2 - sumY * sumY))

Using the same definitions you have for sumXY, SumY, SumX. I would add sumX2 and sumY2 plus the return value r to the function.

@tmcw
Copy link
Member

tmcw commented Sep 10, 2018

Hi Fredy!

Sure, I think that'd be a good addition - given that it can just be another property on the object already returned by linearRegression we should be able to add it in a minor version release.

@nilsga
Copy link

nilsga commented Mar 19, 2020

Are there any plans to add this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants