sperr1 Subroutine

subroutine sperr1(x, avh, dy, n, r, p, var, se)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: x
real, intent(in) :: avh
real, intent(in), dimension(:) :: dy
integer, intent(in) :: n
real, intent(inout), dimension(0:n+1, 3) :: r
real, intent(in) :: p
real, intent(in) :: var
real, intent(out), dimension(:) :: se

Contents

Source Code


Source Code

  subroutine sperr1(x,avh,dy,n,r,p,var,se)
!
! calculates bayesian estimates of the standard errors of the fitted
! values of a cubic smoothing spline by calculating the diagonal elements
! of the influence matrix.
!
!---specifications for arguments---
    integer, intent(in) :: n
    real, dimension(:), intent(in) :: x, dy
    real, dimension(:), intent(out) :: se
    real, dimension(0:n+1, 3), intent(in out) :: r
    real, intent(in) :: avh, p, var
!
!---specifications for local variables---
    integer :: i
    real :: f,g,h,f1,g1,h1
    real, parameter :: zero = 0.
    real, parameter :: one = 1.
!
!---initialize---
    h = avh/ (x(2)-x(1))
    se(1) = one - p*dy(1)*dy(1)*h*h*r(2,1)
    r(1,1) = zero
    r(1,2) = zero
    r(1,3) = zero
!
!---calculate diagonal elements---
    do i = 2,n - 1
       f = h
       h = avh/ (x(i+1)-x(i))
       g = -f - h
       f1 = f*r(i-1,1) + g*r(i-1,2) + h*r(i-1,3)
       g1 = f*r(i-1,2) + g*r(i,1) + h*r(i,2)
       h1 = f*r(i-1,3) + g*r(i,2) + h*r(i+1,1)
       se(i) = one - p*dy(i)*dy(i)* (f*f1+g*g1+h*h1)
    end do
    se(n) = one - p*dy(n)*dy(n)*h*h*r(n-1,1)
!
!---calculate standard error estimates---
    do i = 1,n
       se(i) = sqrt(amax1(se(i)*var,zero))*dy(i)
    end do

  end subroutine sperr1