How do I perform a weighted least squares fit with error bars?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
7 replies · 3K views
pergradus
Messages
137
Reaction score
1
Hi, I am trying to do a best least-squares fit to a set of data which is described by the following equation:

[tex]y=a\exp(-b\ln^2(c/x))[/tex]

Where a,b,c are constant parameters I am trying to find values for.

Any advice on how to proceed?
 
Last edited:
on Phys.org
You write ln(c/x)²
does it mean
(ln(c/x))² = (ln(x/c))²
or
ln((c/x)²) = -2 ln(x/c)
?
 
JJacquelin said:
You write ln(c/x)²
does it mean
(ln(c/x))² = (ln(x/c))²
or
ln((c/x)²) = -2 ln(x/c)
?

The former, I fixed it, sorry for the bad notation.
 
You are lucky. After some transformations, it can be solved by linear regression (in attachment)
 

Attachments

  • Regression.JPG
    Regression.JPG
    25.4 KB · Views: 519
JJacquelin said:
You are lucky. After some transformations, it can be solved by linear regression (in attachment)

Thanks, I'm at home now, but in your attachment you're missing the 'b' parameter, does that change things?
 
Damn ! I forgot the 'b' !
It doesn't change much : the simple linear regression becomes a multivariate linear regression.
 

Attachments

  • Multivariate linear regression.JPG
    Multivariate linear regression.JPG
    26.3 KB · Views: 483
JJacquelin said:
Damn ! I forgot the 'b' !
It doesn't change much : the simple linear regression becomes a multivariate linear regression.

Thanks! I was able to use that transform to produce a decent fit in MatLab - but I'm wondering, do I have to perform a transform on the error bars too if I want to weight the data?
 
do I have to perform a transform on the error bars too if I want to weight the data?
Yes. Knowing the error ranges on the (xi , yi) it is possible to compute the error ranges on (Xi , Yi , Ti).