Hello,

The RBEST Fortran IMSL routine fails to give a best regression for some matrices. I attach one of them. I included inline the code that reads it, calls COV and then RBEST. The print set with IPRINT 1 gets truncated and the output arrays don't have the answer.

What's the recommended approach in this cases?

Thanks

Code:

program testrbest

!use msimsl

implicit real*8 (a-h,o-z)

INTEGER LDCOEF, LDCOV, LDX, NBEST, NGOOD, NSIZE, NTBEST, NVAR

PARAMETER (LDX=50, NBEST=1, NGOOD=10, NVAR=13, &

LDCOEF=NBEST*(NVAR-1)*NVAR/2, LDCOV=NVAR, &

NSIZE=NVAR-1, NTBEST=NBEST*(NVAR-1))

INTEGER ICOEFX(NTBEST+1), ICOPT, ICRIT, ICRITX(NSIZE+1), &

IFRQ, INCD(1,1), INDVAR(NGOOD*NSIZE*(NSIZE+1)/2), &

IPRINT, IVARX(NSIZE+1), IWT, MOPT, NMISS, NOBS, NROW, &

NVAR1

dimension COEF(LDCOEF,13), COV(LDCOV,NVAR), CRIT(NGOOD*NSIZE), &

X(LDX,NVAR), XMEAN(NVAR)

CHARACTER(LEN=500) :: file_path

integer file_id

NROW = LDX

! Open matrix file

file_id = 1

file_path="matrix.txt"

open(file_id,file=file_path)

! Read matrix

do i=1,NROW

read(file_id,*) (X(i,j), j = 1, NVAR)

end do

! Call to get covariance matrix

IFRQ = 0

IWT = 0

MOPT = 0

ICOPT = 1

CALL DCORVC (0, NROW, NVAR, X, LDX, IFRQ, IWT, MOPT, ICOPT, &

XMEAN, COV, LDCOV, INCD, 1, NOBS, NMISS, SUMWT)

ICRIT = 2

IPRINT = 1

! Call to get best regression

CALL DRBEST (NVAR, COV, LDCOV, NOBS, ICRIT, NBEST, NGOOD, IPRINT, &

ICRITX, CRIT, IVARX, INDVAR, ICOEFX, COEF, LDCOEF)

stop

END