Skip to content

Commit 0b142cd

Browse files
committed
remove from fRegress.R and fRegress.numeric.R and put it its own file
1 parent 09e6161 commit 0b142cd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

R/eigchk.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
eigchk <- function(Cmat) {
2+
3+
# check Cmat for singularity
4+
5+
eigval <- eigen(Cmat)$values
6+
ncoef <- length(eigval)
7+
if (eigval[ncoef] < 0) {
8+
neig <- min(length(eigval),10)
9+
cat("\nSmallest eigenvalues:\n")
10+
print(eigval[(ncoef-neig+1):ncoef])
11+
cat("\nLargest eigenvalues:\n")
12+
print(eigval[1:neig])
13+
stop("Negative eigenvalue of coefficient matrix.")
14+
}
15+
if (eigval[ncoef] == 0) stop("Zero eigenvalue of coefficient matrix.")
16+
logcondition <- log10(eigval[1]) - log10(eigval[ncoef])
17+
if (logcondition > 12) {
18+
warning("Near singularity in coefficient matrix.")
19+
cat(paste("\nLog10 Eigenvalues range from\n",
20+
log10(eigval[ncoef])," to ",log10(eigval[1]),"\n"))
21+
}
22+
}

0 commit comments

Comments
 (0)