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












1












$begingroup$


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$








  • 2




    $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
    6 hours ago












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    4 hours ago










  • $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    32 mins ago
















1












$begingroup$


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$








  • 2




    $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
    6 hours ago












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    4 hours ago










  • $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    32 mins ago














1












1








1





$begingroup$


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$




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.







fitting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









JoeJoe

667213




667213








  • 2




    $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
    6 hours ago












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    4 hours ago










  • $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    32 mins ago














  • 2




    $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
    6 hours ago












  • $begingroup$
    thx, if i'd found that i wouldn't have asked.
    $endgroup$
    – Joe
    4 hours ago










  • $begingroup$
    See also Difference between fitting algorithms
    $endgroup$
    – MarcoB
    32 mins ago








2




2




$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
6 hours ago






$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
6 hours ago














$begingroup$
thx, if i'd found that i wouldn't have asked.
$endgroup$
– Joe
4 hours ago




$begingroup$
thx, if i'd found that i wouldn't have asked.
$endgroup$
– Joe
4 hours ago












$begingroup$
See also Difference between fitting algorithms
$endgroup$
– MarcoB
32 mins ago




$begingroup$
See also Difference between fitting algorithms
$endgroup$
– MarcoB
32 mins ago










1 Answer
1






active

oldest

votes


















6












$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$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "387"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192147%2fshould-a-new-user-just-default-to-linearmodelfit-vs-fit%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6












    $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$


















      6












      $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$
















        6












        6








        6





        $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 5 hours ago









        eyorbleeyorble

        5,5531927




        5,5531927






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192147%2fshould-a-new-user-just-default-to-linearmodelfit-vs-fit%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Liste der Baudenkmale in Friedland (Mecklenburg)

            Single-Malt-Whisky

            Czorneboh