PROGRAM g02cafe ! G02CAF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : g02caf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. INTEGER :: i, ifail, n ! .. Local Arrays .. REAL (KIND=nag_wp) :: reslt(20) REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:) ! .. Executable Statements .. WRITE (nout,*) 'G02CAF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read in the problem size READ (nin,*) n ALLOCATE (x(n),y(n)) ! Read in data READ (nin,*) (x(i),y(i),i=1,n) ! Display data WRITE (nout,*) ' Case Independent Dependent' WRITE (nout,*) 'number variable variable' WRITE (nout,*) WRITE (nout,99999) (i,x(i),y(i),i=1,n) WRITE (nout,*) ! Fit linear regression model ifail = 0 CALL g02caf(n,x,y,reslt,ifail) ! Display results WRITE (nout,99998) 'Mean of independent variable = ', & reslt(1) WRITE (nout,99998) 'Mean of dependent variable = ', & reslt(2) WRITE (nout,99998) 'Standard deviation of independent variable = ', & reslt(3) WRITE (nout,99998) 'Standard deviation of dependent variable = ', & reslt(4) WRITE (nout,99998) 'Correlation coefficient = ', & reslt(5) WRITE (nout,*) WRITE (nout,99998) 'Regression coefficient = ', & reslt(6) WRITE (nout,99998) 'Standard error of coefficient = ', & reslt(8) WRITE (nout,99998) 't-value for coefficient = ', & reslt(10) WRITE (nout,*) WRITE (nout,99998) 'Regression constant = ', & reslt(7) WRITE (nout,99998) 'Standard error of constant = ', & reslt(9) WRITE (nout,99998) 't-value for constant = ', & reslt(11) WRITE (nout,*) WRITE (nout,*) 'Analysis of regression table :-' WRITE (nout,*) WRITE (nout,*) ' Source Sum of squares D.F. & & Mean square F-value' WRITE (nout,*) WRITE (nout,99997) 'Due to regression', reslt(12:15) WRITE (nout,99997) 'About regression', reslt(16:18) WRITE (nout,99997) 'Total ', reslt(19:20) 99999 FORMAT (1X,I4,2F15.4) 99998 FORMAT (1X,A,F8.4) 99997 FORMAT (1X,A,F14.3,F8.0,2F14.3) END PROGRAM g02cafe