home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
GRAD.ZIP
/
FUNC4.FOR
< prev
next >
Wrap
Text File
|
1988-08-09
|
3KB
|
99 lines
SUBROUTINE VALUE(A,B,C,A44,C44,FN,INF)
IMPLICIT REAL*8(A-H,O-Z)
REAL*4 X
DIMENSION A(2,4),B(2),C(2,4)
C ****** SUBST. MAX. NUMBER OF OBSERVATIONS ******
COMMON X(13,1800),NOBS,B3
COMMON/TRAPCODE/ITR
COMMON /VRNCS/ W1,W2,W3
ITR=0
C -- COMPUTE EIGENVALUES AND EIGENVECTORS -
DET=A(1,1)*A(2,2)-A(1,2)*A(2,1)
HFTRA=0.5*(A(1,1)+A(2,2))
DISCR=HFTRA**2-DET
IF(DISCR.GT.0.) GO TO 1
WRITE(3,11)
11 FORMAT(' COMPLEX EIGENVALUES')
INF=1
RETURN
1 IF(HFTRA.lt.0.) goto 91
XL1=HFTRA+DSQRT(DISCR)
91 continue
IF(HFTRA.ge.0.) goto 92
XL1=HFTRA-DSQRT(DISCR)
92 continue
XL2=DET/XL1
P11=XL1-A(2,2)
P12=A(1,2)
P13=(A(1,3)*P11+A(2,3)*P12)/(XL1+1.)
P14=(A(1,4)*P11+A(2,4)*P12)/(XL1-A44)
P21=A(2,1)
P22=XL2-A(1,1)
P23=(A(1,3)*P21+A(2,3)*P22)/(XL2+1.)
P24=(A(1,4)*P21+A(2,4)*P22)/(XL2-A44)
C -- COMPUTE LOG-LIKELIHOOD -
DETC=C(1,1)*C(2,2)-C(1,2)*C(2,1)
IF(ABS(DETC).GT.0.) GO TO 3
WRITE(3,33)
33 FORMAT(' C IS SINGULAR')
INF=1
RETURN
3 DETP=P11*P22-P12*P21
IF(ABS(DETP).GT.0.) GO TO 4
WRITE(3,44)
44 FORMAT(' P IS SINGULAR')
INF=1
RETURN
4 continue
FN=-DLOG(ABS(DETC*DETP))
W1=0.
W2=0.
W3=0.
PB1=P11*B(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