idlastro / Math and Statistics: SIXLIN

[Source code]

NAME
SIXLIN
PURPOSE
Compute linear regression coefficients by six different methods.
EXPLANATION
Adapted from the FORTRAN program (Rev. 1.1)  supplied by Isobe, 
Feigelson, Akritas, and Babu Ap. J. Vol. 364, p. 104 (1990).   
Suggested when there is no understanding about the nature of the 
scatter about a linear relation, and NOT when the errors in the 
variable are calculable.
CALLING SEQUENCE
SIXLIN, xx, yy, a, siga, b, sigb, [WEIGHT = ]  
INPUTS
XX - vector of X values
YY - vector of Y values, same number of elements as XX
OUTPUTS
A - Vector of 6 Y intercept coefficients
SIGA - Vector of standard deviations of 6 Y intercepts
B - Vector of 6 slope coefficients
SIGB - Vector of standard deviations of slope coefficients
The output variables are computed using linear regression for each of 
the following 6 cases:
        (0) Ordinary Least Squares (OLS) Y vs. X (c.f. linfit.pro)
        (1) Ordinary Least Squares  X vs. Y
        (2) Ordinary Least Squares Bisector
        (3) Orthogonal Reduced Major Axis
        (4) Reduced Major-Axis 
        (5) Mean ordinary Least Squares
OPTIONAL INPUT KEYWORD
WEIGHT -  vector of weights, same number of elements as XX and YY
          For 1 sigma Gausssian errors, the weights are 1/sigma^2 but
          the weight vector can be more general.   Default is no 
          weighting. 
NOTES
Isobe et al. make the following recommendations
(1) If the different linear regression methods yield similar results
        then quoting OLS(Y|X) is probably the most familiar.
(2) If the linear relation is to be used to predict Y vs. X then
        OLS(Y|X) should be used.   
(3) If the goal is to determine the functional relationship between
        X and Y then the OLS bisector is recommended.
REVISION HISTORY
Written   Wayne Landsman          February, 1991         
Corrected sigma calculations      February, 1992
Added WEIGHT keyword   J. Moustakas   February 2007