Rev 4692 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c Part of R package KernSmoothc Copyright (C) 1995 M. P. Wandc Copyright (C) 2007 B. D. Ripleycc Unlimited use and distribution (see LICENCE).cccccccc FORTRAN subroutine cp.f ccccccccccc For computing Mallow's C_p values for ac set of "Nmax" blocked q'th degree fits.c Last changed: 09/05/95c remove unused 'q' 2007-07-10subroutine cp(X,Y,n,qq,Nmax,RSS,Xj,Yj,coef,Xmat,wk,qraux,Cpvals)integer Nmax,n,qq,Nval,nj,i,j,k,idiv,ilow,iuppdouble precision RSS(Nmax),X(n),Y(n),Xj(n),Yj(n),coef(qq),wk(n),+ Xmat(n,qq),qraux(qq),Cpvals(NMax),fiti,RSSj,+ work(1)c It is assumed that the (X,Y) data arec sorted with respect to the X's.c Compute vector of RSS valuesdo 10 i = 1,NmaxRSS(i) = dble(0)10 continuedo 20 Nval = 1,Nmaxc For each number of partitionsidiv = n/Nvaldo 30 j = 1,Nvalc For each member of the partitionilow = (j-1)*idiv + 1iupp = j*idivif (j.eq.Nval) iupp = nnj = iupp - ilow + 1do 40 k = 1,njXj(k) = X(ilow+k-1)Yj(k) = Y(ilow+k-1)40 continuec Obtain a q'th degree fit over currentc member of partitionc Set up "X" matrixdo 50 i = 1,njXmat(i,1) = 1.0d0do 60 k = 2,qqXmat(i,k) = Xj(i)**(k-1)60 continue50 continuecall 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)RSSj = dble(0)do 70 i = 1,njfiti = coef(1)do 80 k = 2,qqfiti = fiti + coef(k)*Xj(i)**(k-1)80 continueRSSj = RSSj + (Yj(i)-fiti)**270 continueRSS(Nval) = RSS(Nval) + RSSj30 continue20 continuec Now compute array of Mallow's C_p values.do 90 i = 1,NmaxCpvals(i) = ((n-qq*Nmax)*RSS(i)/RSS(Nmax)) + 2*qq*i - n90 continuereturnendcccccccccc End of cp.f cccccccccc