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
Function "linear_model_fit" to carry out least squares fits to linear models #17732
Comments
Worksheet with examples |
Attachment: Test_examples_linear_model_fit.pdf.gz Mathematica's notebook with same examples as in worksheet |
Attachment: Test_Linear_model_fit.pdf.gz Attachment: Test_Linear_model_fit.nb.gz Mathematica's notebook for testing purposes |
Changed author from Rafael López to none |
comment:1
Looks like an exact duplicate of #17733 |
Changed branch from rafa_branch to none |
Changed merged from src/sage/numerical/optimize.py to none |
Changed upstream from Reported upstream. No feedback yet. to none |
Changed reviewer from Vincent Knight to Jeroen Demeyer |
A function ("linear_model_fit") is proposed for least squares fits to linear models. The main difference (which increases functionality) with respect to SAGE's "find_fit" function is that "linear_model_fit" provides detailed information about the quality of the fit and parameters error estimation.
In particular, it provides the values of R2, residuals, residuals sum (Delta2), variance estimation (s2), covariance and correlation matrices, standard errors estimation, parameters error estimation for the confidence level required, t-Statistics, Pvalues, fitting function
and functions corresponding to upper and lower boundaries of mean confidence region.
This function enables fitting of points with one or several independent variables to linear combinations of any arbitrary functions from either SAGE's standard functions, or any valid arithmetic expression built from them. Since only linear models are allowed, functions must not contain non-numerical symbols other than variable names. (A check on this point is carried out inside the function).
The output can be a list or a dictionary. To get it as a dictionary, the optional input parameter "solution_dict" must be set to True, as in other SAGE functions such as "solve" or "find_fit".
"linear_model_fit" tries to mimic Mathematica's function "LinearModelFit" (not in full) and its correctness has been tested against the latter. I am attaching a pdf print of the worksheet used to run the examples, as well as a mathematica notebook for further checking. The current content of the notebook (also attached as a pdf file) corresponds to these examples. Obviously, the notebook can be run with other data.
If you find it interesting, please let me know whether you consider that the function should provide further items such as ANOVA table entries and alike (for further options, see mathematica "LinearModelFit"). I have not included them in the current version because it seemed to be too verbose, but I can reconsider this.
Component: packages: standard
Keywords: regression, function fitting, linear model
Reviewer: Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/17732
The text was updated successfully, but these errors were encountered: