PROGRAM g07cafe ! G07CAF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : g07caf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: clevel, df, dl, du, prob, t, xmean, & xstd, ymean, ystd INTEGER :: ifail, nx, ny CHARACTER (1) :: equal, tail ! .. Executable Statements .. WRITE (nout,*) 'G07CAF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read in the sample sizes, means and standard deviations READ (nin,*) nx, xmean, xstd READ (nin,*) ny, ymean, ystd ! Display data WRITE (nout,*) 'Sample X' WRITE (nout,99996) ' Sample size = ', nx WRITE (nout,99995) ' Mean =', xmean WRITE (nout,99995) ' Standard deviation =', xstd WRITE (nout,*) WRITE (nout,*) 'Sample Y' WRITE (nout,99996) ' Sample size = ', ny WRITE (nout,99995) ' Mean =', ymean WRITE (nout,99995) ' Standard deviation =', ystd D_LP: DO ! Read in the type of statistic and CI required READ (nin,*,IOSTAT=ifail) clevel, tail, equal IF (ifail/=0) THEN EXIT D_LP END IF ! Calculate statistic ifail = 0 CALL g07caf(tail,equal,nx,ny,xmean,ymean,xstd,ystd,clevel,t,df,prob, & dl,du,ifail) ! Display results WRITE (nout,*) IF (equal=='E' .OR. equal=='e') THEN WRITE (nout,*) 'Assuming population variances are equal.' ELSE WRITE (nout,*) 'No assumptions about population variances.' END IF WRITE (nout,*) WRITE (nout,99999) 't test statistic = ', t WRITE (nout,99998) 'Degrees of freedom = ', df WRITE (nout,99997) 'Significance level = ', prob WRITE (nout,*) WRITE (nout,99999) 'Difference in means' WRITE (nout,99999) ' Value = ', xmean - ymean WRITE (nout,99999) ' Lower confidence limit = ', dl WRITE (nout,99999) ' Upper confidence limit = ', du WRITE (nout,99999) ' Confidence level = ', clevel END DO D_LP 99999 FORMAT (1X,A,F10.4) 99998 FORMAT (1X,A,F8.1) 99997 FORMAT (1X,A,F8.4) 99996 FORMAT (1X,A,I5) 99995 FORMAT (1X,A,E11.4) END PROGRAM g07cafe