home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
library
/
ssp
/
statcorr
/
multr.for
< prev
next >
Wrap
Text File
|
1985-11-29
|
6KB
|
174 lines
C
C ..................................................................
C
C SUBROUTINE MULTR
C
C PURPOSE
C PERFORM A MULTIPLE LINEAR REGRESSION ANALYSIS FOR A
C DEPENDENT VARIABLE AND A SET OF INDEPENDENT VARIABLES. THIS
C SUBROUTINE IS NORMALLY USED IN THE PERFORMANCE OF MULTIPLE
C AND POLYNOMIAL REGRESSION ANALYSES.
C
C USAGE
C CALL MULTR (N,K,XBAR,STD,D,RX,RY,ISAVE,B,SB,T,ANS)
C
C DESCRIPTION OF PARAMETERS
C N - NUMBER OF OBSERVATIONS.
C K - NUMBER OF INDEPENDENT VARIABLES IN THIS REGRESSION.
C XBAR - INPUT VECTOR OF LENGTH M CONTAINING MEANS OF ALL
C VARIABLES. M IS NUMBER OF VARIABLES IN OBSERVATIONS.
C STD - INPUT VECTOR OF LENGTH M CONTAINING STANDARD DEVI-
C ATIONS OF ALL VARIABLES.
C D - INPUT VECTOR OF LENGTH M CONTAINING THE DIAGONAL OF
C THE MATRIX OF SUMS OF CROSS-PRODUCTS OF DEVIATIONS
C FROM MEANS FOR ALL VARIABLES.
C RX - INPUT MATRIX (K X K) CONTAINING THE INVERSE OF
C INTERCORRELATIONS AMONG INDEPENDENT VARIABLES.
C RY - INPUT VECTOR OF LENGTH K CONTAINING INTERCORRELA-
C TIONS OF INDEPENDENT VARIABLES WITH DEPENDENT
C VARIABLE.
C ISAVE - INPUT VECTOR OF LENGTH K+1 CONTAINING SUBSCRIPTS OF
C INDEPENDENT VARIABLES IN ASCENDING ORDER. THE
C SUBSCRIPT OF THE DEPENDENT VARIABLE IS STORED IN
C THE LAST, K+1, POSITION.
C B - OUTPUT VECTOR OF LENGTH K CONTAINING REGRESSION
C COEFFICIENTS.
C SB - OUTPUT VECTOR OF LENGTH K CONTAINING STANDARD
C DEVIATIONS OF REGRESSION COEFFICIENTS.
C T - OUTPUT VECTOR OF LENGTH K CONTAINING T-VALUES.
C ANS - OUTPUT VECTOR OF LENGTH 10 CONTAINING THE FOLLOWING
C INFORMATION..
C ANS(1) INTERCEPT
C ANS(2) MULTIPLE CORRELATION COEFFICIENT
C ANS(3) STANDARD ERROR OF ESTIMATE
C ANS(4) SUM OF SQUARES ATTRIBUTABLE TO REGRES-
C SION (SSAR)
C ANS(5) DEGREES OF FREEDOM ASSOCIATED WITH SSAR
C ANS(6) MEAN SQUARE OF SSAR
C ANS(7) SUM OF SQUARES OF DEVIATIONS FROM REGRES-
C SION (SSDR)
C ANS(8) DEGREES OF FREEDOM ASSOCIATED WITH SSDR
C ANS(9) MEAN SQUARE OF SSDR
C ANS(10) F-VALUE
C
C REMARKS
C N MUST BE GREATER THAN K+1.
C
C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C NONE
C
C METHOD
C THE GAUSS-JORDAN METHOD IS USED IN THE SOLUTION OF THE
C NORMAL EQUATIONS. REFER TO W. W. COOLEY AND P. R. LOHNES,
C 'MULTIVARIATE PROCEDURES FOR THE BEHAVIORAL SCIENCES',
C JOHN WILEY AND SONS, 1962, CHAPTER 3, AND B. OSTLE,
C 'STATISTICS IN RESEARCH', THE IOWA STATE COLLEGE PRESS,
C 1954, CHAPTER 8.
C
C ..................................................................
C
SUBROUTINE MULTR (N,K,XBAR,STD,D,RX,RY,ISAVE,B,SB,T,ANS)
DIMENSION XBAR(1),STD(1),D(1),RX(1),RY(1),ISAVE(1),B(1),SB(1),
1 T(1),ANS(1)
C
C ...............................................................
C
C IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE
C C IN COLUMN 1 SHOULD BE REMOVED FROM THE DOUBLE PRECISION
C STATEMENT WHICH FOLLOWS.
C
C DOUBLE PRECISION XBAR,STD,D,RX,RY,B,SB,T,ANS,RM,BO,SSAR,SSDR,SY,
C 1 FN,FK,SSARM,SSDRM,F
C
C THE C MUST ALSO BE REMOVED FROM DOUBLE PRECISION STATEMENTS
C APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS
C ROUTINE.
C
C THE DOUBLE PRECISION VERSION OF THIS SUBROUTINE MUST ALSO
C CONTAIN DOUBLE PRECISION FORTRAN FUNCTIONS. SQRT AND ABS IN
C STATEMENTS 122, 125, AND 135 MUST BE CHANGED TO DSQRT AND DABS.
C
C ...............................................................
C
MM=K+1
C
C BETA WEIGHTS
C
DO 100 J=1,K
100 B(J)=0.0
DO 110 J=1,K
L1=K*(J-1)
DO 110 I=1,K
L=L1+I
110 B(J)=B(J)+RY(I)*RX(L)
RM=0.0
BO=0.0
L1=ISAVE(MM)
C
C COEFFICIENT OF DETERMINATION
C
DO 120 I=1,K
RM=RM+B(I)*RY(I)
C
C REGRESSION COEFFICIENTS
C
L=ISAVE(I)
B(I)=B(I)*(STD(L1)/STD(L))
C
C INTERCEPT
C
120 BO=BO+B(I)*XBAR(L)
BO=XBAR(L1)-BO
C
C SUM OF SQUARES ATTRIBUTABLE TO REGRESSION
C
SSAR=RM*D(L1)
C
C MULTIPLE CORRELATION COEFFICIENT
C
122 RM= SQRT( ABS(RM))
C
C SUM OF SQUARES OF DEVIATIONS FROM REGRESSION
C
SSDR=D(L1)-SSAR
C
C VARIANCE OF ESTIMATE
C
FN=N-K-1
SY=SSDR/FN
C
C STANDARD DEVIATIONS OF REGRESSION COEFFICIENTS
C
DO 130 J=1,K
L1=K*(J-1)+J
L=ISAVE(J)
125 SB(J)= SQRT( ABS((RX(L1)/D(L))*SY))
C
C COMPUTED T-VALUES
C
130 T(J)=B(J)/SB(J)
C
C STANDARD ERROR OF ESTIMATE
C
135 SY= SQRT( ABS(SY))
C
C F VALUE
C
FK=K
SSARM=SSAR/FK
SSDRM=SSDR/FN
F=SSARM/SSDRM
C
ANS(1)=BO
ANS(2)=RM
ANS(3)=SY
ANS(4)=SSAR
ANS(5)=FK
ANS(6)=SSARM
ANS(7)=SSDR
ANS(8)=FN
ANS(9)=SSDRM
ANS(10)=F
RETURN
END