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

NAG FL Interface Introduction
Example description
    Program g02ccfe

!     G02CCF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g02ccf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: xmiss, ymiss
      Integer                          :: i, ifail, n
!     .. Local Arrays ..
      Real (Kind=nag_wp)               :: reslt(21)
      Real (Kind=nag_wp), Allocatable  :: x(:), y(:)
!     .. Executable Statements ..
      Write (nout,*) 'G02CCF Example Program Results'
      Write (nout,*)

!     Skip heading in data file
      Read (nin,*)

!     Read in problem size
      Read (nin,*) n

      Allocate (x(n),y(n))

!     Read in data
      Read (nin,*)(x(i),y(i),i=1,n)

!     Read in missing value flags
      Read (nin,*) xmiss, ymiss

!     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 g02ccf(n,x,y,xmiss,ymiss,reslt,ifail)

      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)
      Write (nout,*)
      Write (nout,99996) 'Number of cases used = ', reslt(21)

99999 Format (1X,I4,2F15.4)
99998 Format (1X,A,F8.4)
99997 Format (1X,A,F14.4,F8.0,2F14.4)
99996 Format (1X,A,F3.0)
    End Program g02ccfe