1
C @(#)tdmregr.for 19.1 (ES0-DMD) 02/25/03 14:11:18
2
C===========================================================================
3
C Copyright (C) 1995 European Southern Observatory (ESO)
5
C This program is free software; you can redistribute it and/or
6
C modify it under the terms of the GNU General Public License as
7
C published by the Free Software Foundation; either version 2 of
8
C the License, or (at your option) any later version.
10
C This program is distributed in the hope that it will be useful,
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
C GNU General Public License for more details.
15
C You should have received a copy of the GNU General Public
16
C License along with this program; if not, write to the Free
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
21
C Internet e-mail: midas@eso.org
22
C Postal address: European Southern Observatory
23
C Data Management Division
24
C Karl-Schwarzschild-Strasse 2
25
C D 85748 Garching bei Muenchen
27
C===========================================================================
29
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
C.COPYRIGHT: Copyright (c) 1987 European Southern Observatory,
33
C.VERSION: 1.0 ESO-FORTRAN Conversion, AA 17:54 - 11 DEC 1987
35
C.LANGUAGE: F77+ESOext
38
C.IDENTIFICATION TDMREGR.FOR
39
C.KEYWORDS TABLE, APPLICATIONS
42
C THE SUBROUTINE DOES A MULTIPLE REGRESION ANALYZES ON THE MATRIX
43
C 'A(N,N)' WITH THE WEIGHTS 'WM(N)'
48
C A.RALSTON & H.S.WILF,
49
C MATHEMATICAL METHODS FOR DIGITAL COMPUTERS, VOL 1
50
C JOHN WILEY & SONS, 1967
53
C------------------------------------------------------------------
55
SUBROUTINE TDMLRG(A,N,WM,TW,COE,RMS,F1,F2,TOL)
57
INTEGER N ! IN : number of variables (dep + indep.)
58
DOUBLE PRECISION A(N,N) ! IN : matrix with correlation coeffs.
59
DOUBLE PRECISION WM(N) ! IN : weighted sum of variables
60
DOUBLE PRECISION TW ! IN : total weight
61
DOUBLE PRECISION COE(N) ! OUT: regression coeffs.
62
REAL RMS(N) ! OUT : standard errors on the coeffs.
63
REAL F1 ! IN : F value to enter variable
64
REAL F2 ! IN : F value to remove variable
65
DOUBLE PRECISION TOL ! IN : the zero level of the matrix
67
INTEGER NM1,I,J,IP1,NO,NMIN,NMAX,K
68
DOUBLE PRECISION DF1,DF2,FI,SY,BO,BX,VMIN,VMAX,VI,AKK
69
DOUBLE PRECISION B(10),RO(10),S(10)
71
C INITIATE COUNTERS AND ARRAYS
73
IF (N.LT.2 .OR. N.GT.10) RETURN
84
C NORMALIZE MATRIX AND WEIGHTED SUMS
88
A(I,J) = A(I,J) - WM(I)*WM(J)/TW
93
IF (A(I,I).LT.0.0D0) RETURN
99
A(I,J) = A(I,J)/ (RO(I)*RO(J))
107
C DO THE MATRIX MANIPULATIONS
111
80 IF (FI.LE.0.0D0) RETURN
112
SY = RO(N)*DSQRT(A(N,N)/FI)
114
IF (NO.GT.1000) GO TO 190
123
IF (A(I,I).LE.TOL) GO TO 110
124
VI = A(I,N)*A(N,I)/A(I,I)
126
90 IF (VI.LE.VMAX) GO TO 110
131
100 B(I) = A(I,N)*RO(N)/RO(I)
132
S(I) = SY*DSQRT(A(I,I))/RO(I)
133
IF (DABS(VI).GE.DABS(VMIN)) GO TO 110
143
IF (DABS(VMIN)*FI.GE.DF2*A(N,N)) GO TO 130
148
130 IF (VMAX* (FI-1.0D0).LE.DF1* (A(N,N)-VMAX)) GO TO 190
155
IF (I.EQ.K) GO TO 160
157
IF (J.EQ.K) GO TO 150
158
A(I,J) = A(I,J) - A(I,K)*A(K,J)/AKK
163
IF (I.EQ.K) GO TO 170
167
IF (J.EQ.K) GO TO 180
173
C REGRATION ANALYZES IS FINISHED GET RESULTS OUT