PROGRAM nag_lin_reg_ex01 ! Example Program Text for nag_lin_reg ! NAG fl90, Release 4. NAG Copyright 2000. ! .. Use Statements .. USE nag_examples_io, ONLY : nag_std_out, nag_std_in USE nag_lin_reg, ONLY : nag_simple_lin_reg ! .. Implicit None Statement .. IMPLICIT NONE ! .. Intrinsic Functions .. INTRINSIC KIND ! .. Parameters .. INTEGER, PARAMETER :: wp = KIND(1.0D0) REAL (wp), PARAMETER :: x_miss = 0.0_wp REAL (wp), PARAMETER :: y_miss = 99.0_wp ! .. Local Scalars .. INTEGER :: i, n ! .. Local Arrays .. REAL (wp) :: result(21) REAL (wp), ALLOCATABLE :: x(:), y(:) ! .. Executable Statements .. WRITE (nag_std_out,*) 'Example Program Results for nag_lin_reg_ex01' READ (nag_std_in,*) ! Skip heading in data file READ (nag_std_in,*) n ALLOCATE (x(n),y(n)) ! Allocate storage DO i = 1, n READ (nag_std_in,*) x(i), y(i) END DO CALL nag_simple_lin_reg(x,y,result,x_miss=x_miss,y_miss=y_miss) WRITE (nag_std_out,*) WRITE (nag_std_out,*) & ' ***** Descriptive Statistics ***** ' WRITE (nag_std_out,*) WRITE (nag_std_out,*) 'Variable Mean Std-deviation' WRITE (nag_std_out,*) WRITE (nag_std_out,'(1x,a,5x,f8.4,7x,f10.4)') 'response (Y) ', & result(2), result(4), 'predictor (X)', result(1), result(3) WRITE (nag_std_out,*) WRITE (nag_std_out,*) WRITE (nag_std_out,*) & ' ***** Analysis of variance (ANOVA) table ***** ' WRITE (nag_std_out,*) WRITE (nag_std_out,*) 'Source of variation D.F & &Sum of squares Mean square F-value' WRITE (nag_std_out,*) WRITE (nag_std_out,'(1x,a,15x,f3.0,6x,f14.4,6x,f11.4,4x,f8.4)') & 'Regression', result(13), result(12), result(14:15), 'Error ', & result(17), result(16), result(18) WRITE (nag_std_out,*) WRITE (nag_std_out,'(1x,a,15x,f3.0,6x,f14.4)') 'Total ', result(20), & result(19) WRITE (nag_std_out,*) WRITE (nag_std_out,'(a,f7.4)') ' Coeff. of determination (R^2)= ', & result(5)**2 WRITE (nag_std_out,*) WRITE (nag_std_out,*) WRITE (nag_std_out,*) & ' ***** Estimates of regression parameters ***** ' WRITE (nag_std_out,*) WRITE (nag_std_out,*) & ' Estimate std-error t-value ' WRITE (nag_std_out,*) WRITE (nag_std_out,'(1x,a,5x,f8.4,9x,f9.4,9x,f7.4)') 'intercept', & result(7), result(9), result(11), 'slope ', result(6), result(8), & result(10) DEALLOCATE (x,y) ! Deallocate storage END PROGRAM nag_lin_reg_ex01