Rev 4692 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c Part of R package KernSmoothc Copyright (C) 1995 M. P. Wandcc Unlimited use and distribution (see LICENCE).cccccccc FORTRAN subroutine blkest.f ccccccccccc For computing blocked polynomial estimatesc required for the direct plug-in bandwidthc selector of Ruppert, Sheather and Wand.c Last changed: 26/04/95subroutine blkest(X,Y,n,q,qq,Nval,Xj,Yj,coef,Xmat,wk,qraux,+ sigsqe,th22e,th24e)integer n,q,qq,Nval,nj,i,j,k,idiv,ilow,iupp,infodouble precision RSS,X(n),Y(n),Xj(n),Yj(n),coef(qq),wk(n),+ Xmat(n,qq),qraux(qq),fiti,th22e,th24e,sigsqe,+ ddm,ddddm,work(1)c It is assumed that the (X,Y) data arec sorted with respect to the X's.RSS = 0.0d0th22e = 0.0d0th24e = 0.0d0idiv = n/Nvaldo j = 1,Nvalc For each member of the partitionilow = (j-1)*idiv + 1iupp = j*idivif (j.eq.Nval) iupp = nnj = iupp - ilow + 1do k = 1,njXj(k) = X(ilow+k-1)Yj(k) = Y(ilow+k-1)end doc Obtain a q'th degree fit over currentc member of partitionc Set up "X" matrixdo i = 1,njXmat(i,1) = 1.0d0do k = 2,qqXmat(i,k) = Xj(i)**(k-1)end doend docall dqrdc(Xmat,n,nj,qq,qraux,0,work,0)info=0call dqrsl(Xmat,n,nj,qq,qraux,Yj,wk,wk,coef,wk,wk,+ 00100,info)do i = 1,njfiti = coef(1)ddm = 2*coef(3)ddddm = 24*coef(5)do k = 2,qqfiti = fiti + coef(k)*Xj(i)**(k-1)if (k.le.(q-1)) thenddm = ddm + k*(k+1)*coef(k+2)*Xj(i)**(k-1)if (k.le.(q-3)) thenddddm = ddddm ++ k*(k+1)*(k+2)*(k+3)*coef(k+4)*Xj(i)**(k-1)endifendifend doth22e = th22e + ddm**2th24e = th24e + ddm*ddddmRSS = RSS + (Yj(i)-fiti)**2end doend dosigsqe = RSS/(n-qq*Nval)th22e = th22e/nth24e = th24e/nreturnendcccccccccc End of blkest.f cccccccccc