Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.79k stars 144 forks source link

Add more regression operations #343

Open MithicSpirit opened 2 years ago

MithicSpirit commented 2 years ago

Under Statistics > Regression the only options are for correlation and not regression (pearson's correlation coefficient, spearman's rho, and the statistical correlation; see https://qalculate.github.io/manual/qalculate-definitions-functions.html#qalculate-definitions-functions-2-Regression). It would be nice if there were actual regression options there such as linear regression and other forms.

hanna-kn commented 2 years ago

I will change the category title (I do not why it has that title—it hasn't changed in 15 years) and look into the possibility of adding functions for actual regression.

MithicSpirit commented 2 years ago

I've been thinking and a possible issue is that regression would need to output a function, which I am not sure is currently possible. Another other option would be to have a function for each value for each regression method (e.g. slope, y-intercept for linear regression), or a single function per regression method that returns a vector of the values.

EDIT: I think that it would be possible to output a function if one of the inputs was the independent variable itself, or if a specific value is passed in the regression is just computed at that value.

hanna-kn commented 2 years ago

A function for linear regression could be defined using covar(\x,\y)/varp(\x)×(x−mean(\x))+mean(\y). This would return an expression with format ax + b. It can be extended to support a single argument and possibly return a confidence interval ((a±c)x + b±d).

MithicSpirit commented 2 years ago

While confidence intervals would certainly be nice to have, they might be a bit outside of the scope of a calculator and instead better suited for statistical analysis software like JASP.