The REGRESS function performs a multiple linear regression fit and returns an Nterm-element column vector of coefficients.
REGRESS fits the function:
yi = const + a0x0, i + a1x1, i + ... + aNterms-1xNterms-1, i
This routine is written in the IDL language. Its source code can be found in the file
regress.pro in the
lib subdirectory of the IDL distribution.
Result = REGRESS( X, Y, [, CHISQ=variable] [, CONST=variable] [, CORRELATION=variable] [, /DOUBLE] [, FTEST=variable] [, MCORRELATION=variable] [, MEASURE_ERRORS=vector] [, SIGMA=variable] [, STATUS=variable] [, YFIT=variable] )
REGRESS returns a 1 x Nterm array of coefficients. If the DOUBLE keyword is set, or if X or Y are double-precision, then the result will be double precision, otherwise the result will be single precision.
An Nterms by Npoints array of independent variable data, where Nterms is the number of coefficients (independent variables) and Npoints is the number of samples.
An Npoints-element vector of dependent variable points.
The Weights argument is obsolete, and has been replaced by the MEASURE_ERRORS keyword. Code that uses the Weights argument will continue to work as before, but new code should use the MEASURE_ERRORS keyword instead. Note that the definition of the MEASURE_ERRORS keyword is different from that of the Weights argument. Using the Weights argument, SQRT(1/Weights[i]) represents the measurement error for each point Y[i]. Using the MEASURE_ERRORS keyword, the measurement error for each point is represented as simply MEASURE_ERRORS[i]. Also note that the RELATIVE_WEIGHTS keyword is not necessary when using the MEASURE_ERRORS keyword.
The Yfit, Const, Sigma, Ftest, R, Rmul, Chisq, and Status arguments are obsolete, and have been replaced by the YFIT, CONST, SIGMA, FTEST, CORRELATION, MCORRELATION, CHISQ, and STATUS keywords, respectively. Code that uses these arguments will continue to work as before, but new code should use the keywords instead.
Set this keyword equal to a named variable that will contain the value of the unreduced chi-square goodness-of-fit statistic.
Set this keyword to a named variable that will contain the constant term of the fit.
Set this keyword to a named variable that will contain the vector of linear correlation coefficients.
Set this keyword to force computations to be done in double-precision arithmetic.
Set this keyword to a named variable that will contain the F-value for the goodness-of-fit test.
Set this keyword to a named variable that will contain the multiple linear correlation coefficient.
Set this keyword to a vector containing standard measurement errors for each point Y[i]. This vector must be the same length as X and Y.
This keyword is obsolete. Code using the Weights argument and RELATIVE_WEIGHT keyword will continue to work as before, but new code should use the MEASURE_ERRORS keyword, for which case the RELATIVE_WEIGHT keyword is not necessary. Using the Weights argument, it was necessary to specify the RELATIVE_WEIGHT keyword if no weighting was desired. This is not the case with the MEASURE_ERRORS keyword-when MEASURE_ERRORS is omitted, REGRESS assumes you want no weighting.
Set this keyword to a named variable that will contain the 1-sigma uncertainty estimates for the returned parameters.
Set this keyword to a named variable that will contain the status of the operation. Possible status values are:
Set this keyword to a named variable that will contain the vector of calculated Y values.
; Create two vectors of independent variable data: X1 = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0] X2 = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] ; Combine into a 2x6 array X = [TRANSPOSE(X1), TRANSPOSE(X2)] ; Create a vector of dependent variable data: Y = 5 + 3*X1 - 4*X2 ; Assume Gaussian measurement errors for each point: measure_errors = REPLICATE(0.5, N_ELEMENTS(Y)) ; Compute the fit, and print the results: result = REGRESS(X, Y, SIGMA=sigma, CONST=const, $ MEASURE_ERRORS=measure_errors) PRINT, 'Constant: ', const PRINT, 'Coefficients: ', result[*] PRINT, 'Standard errors: ', sigma
Constant: 4.99999 Coefficients: 3.00000 -3.99999 Standard errors: 0.0444831 0.282038
CURVEFIT, GAUSSFIT, LINFIT, LMFIT, POLY_FIT, SFIT, SVDFIT