Program g02bafe
! G02BAF Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: g02baf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, ldr, ldssp, ldx, m, n
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: r(:,:), ssp(:,:), std(:), x(:,:), &
xbar(:)
! .. Executable Statements ..
Write (nout,*) 'G02BAF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the problem size
Read (nin,*) n, m
ldr = m
ldssp = m
ldx = n
Allocate (x(ldx,m),r(ldr,m),ssp(ldssp,m),std(m),xbar(m))
! Read in data
Read (nin,*)(x(i,1:m),i=1,n)
! Display data
Write (nout,99999) 'Number of variables (columns) = ', m
Write (nout,99999) 'Number of cases (rows) = ', n
Write (nout,*)
Write (nout,*) 'Data matrix is:-'
Write (nout,*)
Write (nout,99998)(i,i=1,m)
Write (nout,99997)(i,x(i,1:m),i=1,n)
Write (nout,*)
! Compute summary statistics
ifail = 0
Call g02baf(n,m,x,ldx,xbar,std,ssp,ldssp,r,ldr,ifail)
! Display results
Write (nout,*) 'Variable Mean St. dev.'
Write (nout,99996)(i,xbar(i),std(i),i=1,m)
Write (nout,*)
Write (nout,*) 'Sums of squares and cross-products of deviations'
Write (nout,99998)(i,i=1,m)
Write (nout,99997)(i,ssp(i,1:m),i=1,m)
Write (nout,*)
Write (nout,*) 'Correlation coefficients'
Write (nout,99998)(i,i=1,m)
Write (nout,99997)(i,r(i,1:m),i=1,m)
99999 Format (1X,A,I0)
99998 Format (1X,6I12)
99997 Format (1X,I3,3F12.4)
99996 Format (1X,I5,2F11.4)
End Program g02bafe