comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » regression with error bars
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: regression with error bars [message #70812 is a reply to message #70719] Tue, 04 May 2010 19:19 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On May 4, 3:57 pm, Meagan Adams <meagan....@gmail.com> wrote:
> Hello
>
> I have two columns of data y (with errors Err+ and Err- for each data
> point) and x (with Err). I would like to find the linear regression
> coefficients A and B (in y=Ax+B) considering the errors in my data
> point. Is their a function in IDL which would do the trick? and the
> regression has to do with the errors in y only but not in x, right?

I don't believe there is a built-in function in IDL which can do this.

You can use MPFIT. The trick is that you will need to be able to form
your own scaled residual. Normally you would have a user function
something like this,
FUNCTION MYFUNCT, P, X=X, Y=Y, ERROR=ERROR
MODEL = F(X,P) ;; User model
RETURN, (Y - MODEL)/ERROR
END

but now you will need to reformulate as,
FUNCTION MYFUNCT, P, X=X, Y=Y, ERROR_PLUS=ERROR_PLUS,
ERROR_MINUS=ERROR_MINUS
MODEL = F(X,P) ;; User model
RESID_PLUS = (Y - MODEL) / ERROR_PLUS ;; Residual for positive
values
RESID_MINUS = (Y - MODEL) / ERROR_MINUS ;; Residual for negative
values
;; Combine the two kinds of residuals
RESID = (RESID_PLUS GT 0)*RESID_PLUS + (RESID_MINUS LT
0)*RESID_MINUS
RETURN, RESID
END

Happy fitting,
Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: color plot over greyscale image - postscript
Next Topic: Re: how to retain header info even after writefits

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 07:50:36 PDT 2025

Total time taken to generate the page: 0.97909 seconds