C****************************************************************
C* 								*
C*								*
C*	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY *
C*	EITHER FOR THE CREATION OR FOR THE CLINICAL EFFICACY	*
C*	OF THIS PROGRAM. USERS MUST ASSUME FULL RESPONSIBILITY	*
C*	FOR ANY RESULTS OR DIAGNOSES OBTAINED FROM THE USE	*
C*	OF THIS PROGRAM. QUESTIONS ON THE EXECUTION OF THIS	*
C*	PROGRAM MUST BE REFERRED BACK TO THE ORIGINAL AUTHOR.	*
C*								*
C* AUTHOR:	SALLY FORSTER					*
C*		C/O DEPARTMENT OF NUCLEAR MEDICINE		*
C*		GUY'S HOSPITAL				*
C*		LONDON, ENGLAND					*
C*								*
C*		TEL: 01-407-7600 EXT 2583/4			*
C*								*
C****************************************************************
	FUNCTION LOGFIT(I,J)
	IMPLICIT INTEGER*2(D-Z)
	IMPLICIT LOGICAL*1(A)
	COMMON//SAVDES(256),CURVE1(512),CURVE2(512)
	COMMON/FIT/CFITPA(4)
	REAL*8 CRES
C*****Y=LOG(A*X+B)
C*****RETURNS A,B,RESID IN CFITPA
C*****EXP(Y)=A*X+B
	LOGFIT=1
C*****PUTS Y VALUES TO DISK AND EXPONENTIATES
	IF(PCV(1,12).LT.0)GOTO 300
	CALL FEXP
C*****DOES LINEAR REGRESSION RETURNING FITTED VALUES IN CURVE1
	IF(LINREG(I,J).LT.0)GOTO 200
C*****TAKE LOGS OF FITTED CURVE
	CALL LOG
C*****RETRIEVES ORIGIONAL DATA TO CURVE2
	IF(GCV(2,12).LT.0)GOTO 300
C*****CALCULATES RESSIDUAL SUM OF SQUARES
	CFITPA(3)=SNGL(CRES(CURVE2,I,J,CURVE1))
	RETURN
200	LOGFIT=0
	RETURN
300	LOGFIT=-1
	RETURN
	END
