# NonLinearModelFit with Two Dimensional List of Weights

I'm currently trying to fit Planck's law (B[λ, T]) to measurements, thereby determining Planck's constant.

I have a list of triplets containing wavelength, temperature and measured intensity and a list of triplets with their errors, like:

datalist  = {{λ1, T1, B1}, {λ2, T2, B2}, ...}
errorlist = {{σλ1, σT1, σB1}, {σλ2, σT2, σB2}, ...}


Although NonlinearModelFit can fit functions of the type R2 → R, it seems to only accept a one dimensional list as Weights. This is what I tried:

NonlinearModelFit[datalist, B[λ, T], {{h, hlit}}, {λ,T}, Weights -> (errorlist)^-2]


I could of course propagate the partial uncertainties to create one uncertainty for each triplet, thereby have a one dimensional Weights list instead, but it seems a bit unethic.

Would it be possible to fit Planck's curve to my measurements without having to combine the errors first?

Edit: Here's the exact error message that I get:

NonlinearModelFit::wts: The value of option Weights -> {{100.,100.,2500.},{11.1111,25.,25.},{11.1111,2.77778,11.1111}} should be a list of real numbers or a pure function. >>

(I used this data and function as an example: http://pastebin.com/pqxDfe4u)

-
it seems this works: NonlinearModelFit[datalist, F[x, y], {{a, 2}}, {x, y} , Weights -> Last/@(errorlist)] but may be you want errors in x and y as well? –  chris Jun 5 '13 at 21:30
What I have done in the past is simply to multiply the reciprocal variances in the abscissa and the ordinate together and use that as a weight. Of course, that is not strictly correct, but it will be a reasonable approximation if the residuals are small. If you want it done strictly correctly (i.e. through total least squares), NonlinearModelFit can't help you--you'll have to code it yourself. –  Oleksandr R. Jun 6 '13 at 4:10