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

Function "linear_model_fit" to carry out least squares fits to linear models #17732

Closed
sagetrac-rafa-lopez mannequin opened this issue Feb 5, 2015 · 9 comments
Closed

Comments

@sagetrac-rafa-lopez
Copy link
Mannequin

sagetrac-rafa-lopez mannequin commented Feb 5, 2015

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

@sagetrac-rafa-lopez sagetrac-rafa-lopez mannequin added this to the sage-6.5 milestone Feb 5, 2015
@sagetrac-rafa-lopez
Copy link
Mannequin Author

sagetrac-rafa-lopez mannequin commented Feb 5, 2015

Worksheet with examples

@sagetrac-rafa-lopez
Copy link
Mannequin Author

sagetrac-rafa-lopez mannequin commented Feb 5, 2015

Attachment: Test_examples_linear_model_fit.pdf.gz

Mathematica's notebook with same examples as in worksheet

@sagetrac-rafa-lopez
Copy link
Mannequin Author

sagetrac-rafa-lopez mannequin commented Feb 5, 2015

Attachment: Test_Linear_model_fit.pdf.gz

Attachment: Test_Linear_model_fit.nb.gz

Mathematica's notebook for testing purposes

@jdemeyer
Copy link

Changed author from Rafael López to none

@jdemeyer
Copy link

comment:1

Looks like an exact duplicate of #17733

@jdemeyer
Copy link

Changed branch from rafa_branch to none

@jdemeyer
Copy link

Changed merged from src/sage/numerical/optimize.py to none

@jdemeyer
Copy link

Changed upstream from Reported upstream. No feedback yet. to none

@jdemeyer
Copy link

Changed reviewer from Vincent Knight to Jeroen Demeyer

@jdemeyer jdemeyer removed this from the sage-6.5 milestone Mar 13, 2015
@vbraun vbraun closed this as completed Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants