Subroutine regression(n,p,y)! !*************************************************************** ! A routine to calculate the regression coefficients from a !datamatrix specified in the calling program and held in a !module called test. The matrix is of dimensions n, p and the !response vector is y. This routine uses the standardized correlaion !matrices to calulate b (which also must be specified in the calling !program and held in test. ! Version 2/1/02 DH !**************************************************************** USE DFIMSLSS USE IMSLf90 use test implicit none integer, intent(in) :: n,p real, intent(in) :: y(n,1) real :: temp(n,1),X(n,p),bnew(p,1) real :: xt(p,n),zX(n,p),zy(n,1) real :: C(p,p),r(p,1),Cinv(p,p) real :: avg,var,vary integer :: i,j,k X=Xhat !standardize the data do i=1,p call average(n,X(:,i),avg) call varience(n,X(:,i),var) do j=1,n zX(j,i)=(X(j,i)-avg)/sqrt(var) end do enddo call average(n,y,avg) call varience(n,y,var) do j=1,n zy(j,1)=(y(j,1)-avg)/sqrt(var) end do do i=1,p do j=1,p call correlation(n,zX(:,i),zX(:,j),C(i,j)) end do call correlation(n,zy,zX(:,i),r(i,1)) !write(4,'(
(f7.2,1x))') (C(i,j),j=1,p) end do Cinv = .i. C bnew = Cinv .x. r ! now put betas back into non-standardized form! call varience(n,y,vary) do i=1,p call varience(n,X(:,i),var) b(i,1)=bnew(i,1)*(sqrt(vary)/sqrt(var)) end do return end subroutine regression