Re: NonLinearRegression Weights
- To: mathgroup at smc.vnet.net
- Subject: [mg73628] Re: [mg73584] NonLinearRegression Weights
- From: Peter Pershan <pershan at deas.harvard.edu>
- Date: Fri, 23 Feb 2007 04:39:14 -0500 (EST)
- References: <200702220937.EAA24446@smc.vnet.net> <45DDBEFE.3040808@wolfram.com>
Darren
Thanks. You are absolutely correct. In fact last night I discovered the
command Weights=wt[[All,1]] seems to do the same thing.
I tried to post the answer but I couldn't locate the original post.
Peter
Darren Glosemeyer wrote:
> From the message it appears that the weights were given as a list of
> single element lists. Numeric weights must be given as a vector (a
> flat list) of numbers. Using Weights->Flatten[wt] should do what you
> want.
>
> Darren Glosemeyer
> Wolfram Research
>
> pershan at seas.harvard.edu wrote:
>> I am trying to add Weights to NonlinearRegression Fit.
>> The relevant section of Mathematica Help (Statistics `NonlinearFit` )
>> is as follows
>>
>> The Weights option allows you to implement weighted least
>> squares by specifying a list of weights, one for each data point; the
>> default Weights -> Automatic implies a weight of unity for each data
>> point. When Weights -> {a, ... , a}, the parameter estimates are chosen
>> to minimize the weighted sum of squared residuals a.
>>
>> The command I am using is:
>> fitting[x_] = NonlinearFit[data, f[x], {x}, {
>> {Background, {0, 1000}},
>> {Amplitude, {10, 0}},
>> {Wid, {10, 25}}}, Weights -> wt]
>> where wt is a column vector that has precisely the same length as the
>> data file.
>> This command works perfectly if I use either Weights->Automatic or
>> something like Weights -> (Sqrt[#] &)
>> On the other hand, when the weights are from a list {....} I get the
>> following error.
>>
>> NonlinearFit::bdwghts: Warning: Value of option Weights ->
>> {{0.00322435}, \
>> {0.00359912}, \[LeftSkeleton]8\[RightSkeleton], \[LeftSkeleton]31\
>> \[RightSkeleton]} is not Automatic, a pure function mapping a
>> response to a \
>> non-negative numerical weight, or a non-negative numerical vector
>> having the \
>> same length as the data. Setting all weights to 1 (Weights ->
>> Automatic).
>>
>>
>
--
Prof. Peter S. Pershan
Frank B. Baird, Jr. Professor of Science
Division of Applied Sciences and Dept. of Physics
Harvard Univ.
205c Pierce Hall
Cambridge, MA 02138
Phone: 617 495 3214
FAX: 617 495 2875
pershan at deas.harvard.edu
Web: http://www.liquids.deas.harvard.edu/peter/welcome.html
- References:
- NonLinearRegression Weights
- From: pershan@seas.harvard.edu
- NonLinearRegression Weights