Re: LinearModelFit doesn't work with constraints?
- To: mathgroup at smc.vnet.net
- Subject: [mg126266] Re: LinearModelFit doesn't work with constraints?
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Sat, 28 Apr 2012 05:23:44 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201204271049.GAA20072@smc.vnet.net>
On 4/27/2012 5:49 AM, Michael B. Heaney wrote: > Why does this fit work with FindFit but not with LinearModelFit? Can it be > fixed to work with LinearModelFit?: > > Clear[data]; data = {{115.72406725682761`, -15.570108102859956`}, \ > {117.8314200026393`, -15.968691594983845`}, {120.50868883703222`, \ > -15.557184099102274`}, {123.16961208975692`, -17.846622221595887`}, \ > {125.3164877613608`, -18.43251273767855`}, {128.24732225661378`, \ > -16.84848062166309`}, {131.05256326055346`, -17.081766983527483`}, \ > {133.7064123558641`, -19.059419077883778`}, {136.18274587879156`, \ > -19.208721233907866`}, {139.95296926627307`, -18.628905889943834`}, \ > {143.2369087194593`, -18.591163617876923`}, {147.14564801682326`, \ > -18.888777713700467`}, {150.85049708613295`, -21.835515088942074`}, \ > {153.57145686694008`, -23.25406602083415`}, {156.9233738005359`, \ > -22.508610494557008`}, {159.94900229896672`, -22.69235624566059`}, \ > {164.25282291760502`, -21.402179278192076`}, {168.2678963595429`, \ > -23.077039100878793`}, {172.9451931425859`, -22.880000000000077`}, \ > {177.59703028246392`, -23.833509165832456`}, {181.89037272389143`, \ > -27.41435932731815`}, {186.93493381792146`, -24.650015260962466`}, \ > {193.41672302408762`, -26.41596918746758`}, {196.47059064117093`, \ > -30.300000797662353`}, {202.877012880498`, -28.550517035150595`}, \ > {207.29663799516817`, -26.260039093487233`}, {213.5919610462257`, \ > -28.25441495743196`}, {218.34896467314775`, -32.55484530810561`}, \ > {224.4069723198895`, -32.62174158456492`}, {233.64434669525724`, \ > -32.080784583708244`}}; > ListPlot[data, AxesOrigin -> {0, 0}] > Clear[lmf, a, b, x]; > lmf = LinearModelFit[data, {a + b*x, {a< 0, b< 0}}, {a, b}, {x}]; > Normal[lmf] > > NonlinearModelFit handles constrained least squares fitting. You can use it for this type of fitting. In[9]:= lmf = NonlinearModelFit[data, {a + b*x, {a < 0, b < 0}}, {a, b}, {x}]; Normal[lmf] Out[10]= -0.00424958 - 0.138747 x Darren Glosemeyer Wolfram Research
- References:
- LinearModelFit doesn't work with constraints?
- From: "Michael B. Heaney" <mheaney@gmail.com>
- LinearModelFit doesn't work with constraints?