Should a new user just default to LinearModelFit (vs Fit) [duplicate]












5












$begingroup$



This question already has an answer here:




  • Difference between Fitting Algorithms

    1 answer




I tried searching but the noise in the responses is high due to 'fit' being both a function and a valid term.



If I'm new to Mathematica should I just default to LinearModelFit (v7) and recognise Fit as a v1 version that got superceded?



My instinct is 'yes' but wondered if there were valid use cases where Fit would be preferred over LinearModelFit.










share|improve this question









$endgroup$



marked as duplicate by Henrik Schumacher, MarcoB, m_goldberg, eyorble, bbgodfrey Feb 25 at 22:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 3




    $begingroup$
    You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
    $endgroup$
    – eyorble
    Feb 24 at 23:13












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    Feb 25 at 0:52






  • 3




    $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    Feb 25 at 4:49
















5












$begingroup$



This question already has an answer here:




  • Difference between Fitting Algorithms

    1 answer




I tried searching but the noise in the responses is high due to 'fit' being both a function and a valid term.



If I'm new to Mathematica should I just default to LinearModelFit (v7) and recognise Fit as a v1 version that got superceded?



My instinct is 'yes' but wondered if there were valid use cases where Fit would be preferred over LinearModelFit.










share|improve this question









$endgroup$



marked as duplicate by Henrik Schumacher, MarcoB, m_goldberg, eyorble, bbgodfrey Feb 25 at 22:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 3




    $begingroup$
    You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
    $endgroup$
    – eyorble
    Feb 24 at 23:13












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    Feb 25 at 0:52






  • 3




    $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    Feb 25 at 4:49














5












5








5





$begingroup$



This question already has an answer here:




  • Difference between Fitting Algorithms

    1 answer




I tried searching but the noise in the responses is high due to 'fit' being both a function and a valid term.



If I'm new to Mathematica should I just default to LinearModelFit (v7) and recognise Fit as a v1 version that got superceded?



My instinct is 'yes' but wondered if there were valid use cases where Fit would be preferred over LinearModelFit.










share|improve this question









$endgroup$





This question already has an answer here:




  • Difference between Fitting Algorithms

    1 answer




I tried searching but the noise in the responses is high due to 'fit' being both a function and a valid term.



If I'm new to Mathematica should I just default to LinearModelFit (v7) and recognise Fit as a v1 version that got superceded?



My instinct is 'yes' but wondered if there were valid use cases where Fit would be preferred over LinearModelFit.





This question already has an answer here:




  • Difference between Fitting Algorithms

    1 answer








fitting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 24 at 23:11









JoeJoe

687213




687213




marked as duplicate by Henrik Schumacher, MarcoB, m_goldberg, eyorble, bbgodfrey Feb 25 at 22:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Henrik Schumacher, MarcoB, m_goldberg, eyorble, bbgodfrey Feb 25 at 22:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 3




    $begingroup$
    You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
    $endgroup$
    – eyorble
    Feb 24 at 23:13












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    Feb 25 at 0:52






  • 3




    $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    Feb 25 at 4:49














  • 3




    $begingroup$
    You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
    $endgroup$
    – eyorble
    Feb 24 at 23:13












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    Feb 25 at 0:52






  • 3




    $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    Feb 25 at 4:49








3




3




$begingroup$
You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
$endgroup$
– eyorble
Feb 24 at 23:13






$begingroup$
You may want to take a look at mathematica.stackexchange.com/questions/182053/… for an example of some of the usage differences. LinearModelFit generates a model object which has some useful properties (e.g. "RSquared"), in addition to the fit itself. In short, I'd only recommend Fit if you just want the shortest code for getting the linear fit expression without any other baggage.
$endgroup$
– eyorble
Feb 24 at 23:13














$begingroup$
thx, if i'd found that i wouldn't have asked.
$endgroup$
– Joe
Feb 25 at 0:52




$begingroup$
thx, if i'd found that i wouldn't have asked.
$endgroup$
– Joe
Feb 25 at 0:52




3




3




$begingroup$
See also Difference between fitting algorithms
$endgroup$
– MarcoB
Feb 25 at 4:49




$begingroup$
See also Difference between fitting algorithms
$endgroup$
– MarcoB
Feb 25 at 4:49










1 Answer
1






active

oldest

votes


















12












$begingroup$

There are a few major differences between Fit and LinearModelFit.



LinearModelFit generates a full model object as its output, which maintains a large set of interesting properties (such as RSquared or ANOVATable). These can be accessed by:



lmf = LinearModelFit[{2, 3, 4, 5}, {x}, x];
lmf["Properties"]
lmf["RSquared"]


By default, LinearModelFit assumes that the zero-intercept may be non-zero. This property is controlled by the IncludeConstantBasis option. LinearModelFit has several interesting but advanced options available as well, such as the ability to define weights and perform error propagation through the model.



The final fit expression from LinearModelFit can be extracted with Normal.



Fit does not assume a constant basis, and returns the fit expression directly. It does not calculate additional properties, will automatically convert exact numbers to machine precision, and only finds the least-squares fit. LinearModelFit and Fit can work at arbitrary precision (as unlikely as that may be to be useful), but only LinearModelFit allows the specification of WorkingPrecision as an option.



The primary advantage of Fit would appear to be its simplicity and brevity. If you only need the least-squares fit expression or are doing code-golf, Fit should suffice. In most other cases, I would recommend using LinearModelFit, if only to be able to access the various quality measures it can calculate on the side.



Note, however, that I wouldn't expect either function to have significant errors -- they ultimately should find the same model, assuming that the constant basis is either included or excluded in both, and that no special options are specified in LinearModelFit to adapt the model to a specific use case. It's just a question of if you want/need the additional data of the model object.






share|improve this answer









$endgroup$













  • $begingroup$
    I believe LinearModelFit uses Fit behind the scenes (not sure).
    $endgroup$
    – Szabolcs
    Feb 25 at 9:32






  • 2




    $begingroup$
    @Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
    $endgroup$
    – Carl Lange
    Feb 25 at 9:43




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









12












$begingroup$

There are a few major differences between Fit and LinearModelFit.



LinearModelFit generates a full model object as its output, which maintains a large set of interesting properties (such as RSquared or ANOVATable). These can be accessed by:



lmf = LinearModelFit[{2, 3, 4, 5}, {x}, x];
lmf["Properties"]
lmf["RSquared"]


By default, LinearModelFit assumes that the zero-intercept may be non-zero. This property is controlled by the IncludeConstantBasis option. LinearModelFit has several interesting but advanced options available as well, such as the ability to define weights and perform error propagation through the model.



The final fit expression from LinearModelFit can be extracted with Normal.



Fit does not assume a constant basis, and returns the fit expression directly. It does not calculate additional properties, will automatically convert exact numbers to machine precision, and only finds the least-squares fit. LinearModelFit and Fit can work at arbitrary precision (as unlikely as that may be to be useful), but only LinearModelFit allows the specification of WorkingPrecision as an option.



The primary advantage of Fit would appear to be its simplicity and brevity. If you only need the least-squares fit expression or are doing code-golf, Fit should suffice. In most other cases, I would recommend using LinearModelFit, if only to be able to access the various quality measures it can calculate on the side.



Note, however, that I wouldn't expect either function to have significant errors -- they ultimately should find the same model, assuming that the constant basis is either included or excluded in both, and that no special options are specified in LinearModelFit to adapt the model to a specific use case. It's just a question of if you want/need the additional data of the model object.






share|improve this answer









$endgroup$













  • $begingroup$
    I believe LinearModelFit uses Fit behind the scenes (not sure).
    $endgroup$
    – Szabolcs
    Feb 25 at 9:32






  • 2




    $begingroup$
    @Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
    $endgroup$
    – Carl Lange
    Feb 25 at 9:43


















12












$begingroup$

There are a few major differences between Fit and LinearModelFit.



LinearModelFit generates a full model object as its output, which maintains a large set of interesting properties (such as RSquared or ANOVATable). These can be accessed by:



lmf = LinearModelFit[{2, 3, 4, 5}, {x}, x];
lmf["Properties"]
lmf["RSquared"]


By default, LinearModelFit assumes that the zero-intercept may be non-zero. This property is controlled by the IncludeConstantBasis option. LinearModelFit has several interesting but advanced options available as well, such as the ability to define weights and perform error propagation through the model.



The final fit expression from LinearModelFit can be extracted with Normal.



Fit does not assume a constant basis, and returns the fit expression directly. It does not calculate additional properties, will automatically convert exact numbers to machine precision, and only finds the least-squares fit. LinearModelFit and Fit can work at arbitrary precision (as unlikely as that may be to be useful), but only LinearModelFit allows the specification of WorkingPrecision as an option.



The primary advantage of Fit would appear to be its simplicity and brevity. If you only need the least-squares fit expression or are doing code-golf, Fit should suffice. In most other cases, I would recommend using LinearModelFit, if only to be able to access the various quality measures it can calculate on the side.



Note, however, that I wouldn't expect either function to have significant errors -- they ultimately should find the same model, assuming that the constant basis is either included or excluded in both, and that no special options are specified in LinearModelFit to adapt the model to a specific use case. It's just a question of if you want/need the additional data of the model object.






share|improve this answer









$endgroup$













  • $begingroup$
    I believe LinearModelFit uses Fit behind the scenes (not sure).
    $endgroup$
    – Szabolcs
    Feb 25 at 9:32






  • 2




    $begingroup$
    @Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
    $endgroup$
    – Carl Lange
    Feb 25 at 9:43
















12












12








12





$begingroup$

There are a few major differences between Fit and LinearModelFit.



LinearModelFit generates a full model object as its output, which maintains a large set of interesting properties (such as RSquared or ANOVATable). These can be accessed by:



lmf = LinearModelFit[{2, 3, 4, 5}, {x}, x];
lmf["Properties"]
lmf["RSquared"]


By default, LinearModelFit assumes that the zero-intercept may be non-zero. This property is controlled by the IncludeConstantBasis option. LinearModelFit has several interesting but advanced options available as well, such as the ability to define weights and perform error propagation through the model.



The final fit expression from LinearModelFit can be extracted with Normal.



Fit does not assume a constant basis, and returns the fit expression directly. It does not calculate additional properties, will automatically convert exact numbers to machine precision, and only finds the least-squares fit. LinearModelFit and Fit can work at arbitrary precision (as unlikely as that may be to be useful), but only LinearModelFit allows the specification of WorkingPrecision as an option.



The primary advantage of Fit would appear to be its simplicity and brevity. If you only need the least-squares fit expression or are doing code-golf, Fit should suffice. In most other cases, I would recommend using LinearModelFit, if only to be able to access the various quality measures it can calculate on the side.



Note, however, that I wouldn't expect either function to have significant errors -- they ultimately should find the same model, assuming that the constant basis is either included or excluded in both, and that no special options are specified in LinearModelFit to adapt the model to a specific use case. It's just a question of if you want/need the additional data of the model object.






share|improve this answer









$endgroup$



There are a few major differences between Fit and LinearModelFit.



LinearModelFit generates a full model object as its output, which maintains a large set of interesting properties (such as RSquared or ANOVATable). These can be accessed by:



lmf = LinearModelFit[{2, 3, 4, 5}, {x}, x];
lmf["Properties"]
lmf["RSquared"]


By default, LinearModelFit assumes that the zero-intercept may be non-zero. This property is controlled by the IncludeConstantBasis option. LinearModelFit has several interesting but advanced options available as well, such as the ability to define weights and perform error propagation through the model.



The final fit expression from LinearModelFit can be extracted with Normal.



Fit does not assume a constant basis, and returns the fit expression directly. It does not calculate additional properties, will automatically convert exact numbers to machine precision, and only finds the least-squares fit. LinearModelFit and Fit can work at arbitrary precision (as unlikely as that may be to be useful), but only LinearModelFit allows the specification of WorkingPrecision as an option.



The primary advantage of Fit would appear to be its simplicity and brevity. If you only need the least-squares fit expression or are doing code-golf, Fit should suffice. In most other cases, I would recommend using LinearModelFit, if only to be able to access the various quality measures it can calculate on the side.



Note, however, that I wouldn't expect either function to have significant errors -- they ultimately should find the same model, assuming that the constant basis is either included or excluded in both, and that no special options are specified in LinearModelFit to adapt the model to a specific use case. It's just a question of if you want/need the additional data of the model object.







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 24 at 23:33









eyorbleeyorble

5,66311028




5,66311028












  • $begingroup$
    I believe LinearModelFit uses Fit behind the scenes (not sure).
    $endgroup$
    – Szabolcs
    Feb 25 at 9:32






  • 2




    $begingroup$
    @Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
    $endgroup$
    – Carl Lange
    Feb 25 at 9:43




















  • $begingroup$
    I believe LinearModelFit uses Fit behind the scenes (not sure).
    $endgroup$
    – Szabolcs
    Feb 25 at 9:32






  • 2




    $begingroup$
    @Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
    $endgroup$
    – Carl Lange
    Feb 25 at 9:43


















$begingroup$
I believe LinearModelFit uses Fit behind the scenes (not sure).
$endgroup$
– Szabolcs
Feb 25 at 9:32




$begingroup$
I believe LinearModelFit uses Fit behind the scenes (not sure).
$endgroup$
– Szabolcs
Feb 25 at 9:32




2




2




$begingroup$
@Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
$endgroup$
– Carl Lange
Feb 25 at 9:43






$begingroup$
@Szabolcs I just spent a few minutes PrintDefinitionsing LinearModelFit and didn't see any usage of Fit specifically.
$endgroup$
– Carl Lange
Feb 25 at 9:43





Popular posts from this blog

Index of /

Tribalistas

Listed building