Program g11aafe
! G11AAF Example Program Text
! Mark 27.1 Release. NAG Copyright 2020.
! .. Use Statements ..
Use nag_library, Only: g11aaf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: chi, df, g, prob
Integer :: i, ifail, ldnobs, ncol, nrow
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: chist(:,:), expt(:,:)
Integer, Allocatable :: nobs(:,:)
! .. Executable Statements ..
Write (nout,*) ' G11AAF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the problem size
Read (nin,*) nrow, ncol
ldnobs = nrow
Allocate (nobs(ldnobs,ncol),expt(ldnobs,ncol),chist(ldnobs,ncol))
! Read in data
Read (nin,*)(nobs(i,1:ncol),i=1,nrow)
! Perform chi-squared test
ifail = -1
Call g11aaf(nrow,ncol,nobs,ldnobs,expt,chist,prob,chi,g,df,ifail)
If (ifail/=0) Then
If (ifail/=3) Then
Go To 100
End If
End If
! Display results
Write (nout,99999) ' Probability =', prob
Write (nout,99998) ' Pearson Chi-square statistic = ', chi
Write (nout,99998) ' Likelihood ratio test statistic = ', g
Write (nout,99997) ' Degrees of freedom = ', df
100 Continue
99999 Format (A,F7.4)
99998 Format (A,F8.3)
99997 Format (A,F4.0)
End Program g11aafe