      program fracvar
c
c     determine fractional variance of series2 explained by series1
c
      parameter (nmax=4000)
      real series1(nmax),series2(nmax)
      open (unit=4,file='fracvar.in',status='old')
      do i=1,nmax
         read (4,*,end=99) idum,series1(i),series2(i)
      end do
99    continue
      close (unit=4)
      nx = i-1
c
      sum1 = 0.0
      sum2 = 0.0
      do i=1,nx
         sum1 = sum1+ (series2(i)-series1(i))**2
         sum2 = sum2 + series2(i)**2
      end do
      beta = 1.0-sum1/sum2
      write (6,*) 'explained variance: ',beta
      stop
      end
