NAG Library Manual, Mark 27.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program g07cafe

!     G07CAF Example Program Text

!     Mark 27.3 Release. NAG Copyright 2021.

!     .. 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