FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | dimension (:) | :: | x | |||
real | :: | avh | ||||
real, | dimension (:) | :: | dy | |||
integer | :: | n | ||||
real, | dimension (0:n+1, 3) | :: | r | |||
real | :: | p | ||||
real | :: | var | ||||
real, | dimension (:) | :: | se |
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 n
real, dimension (:) :: x, dy, se
real, dimension (0:n+1, 3) :: r
real :: avh, p, var
!
!---specifications for local variables---
integer i
real :: f,g,h,f1,g1,h1
real :: zero = 0.
real :: 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