SVD issues
by Allin Cottrell
Herewith some more detail regarding the warning I posted on the
users list
https://www.mail-archive.com/gretl-users@gretlml.univpm.it/msg14491.html
The business with VAR standard errors was due to a crucial
difference between the "old" lapack SVD solver, dgelss(), and the
"new", faster dgelsd (divide-and-conquer variant) that I failed to
notice at first. That is, dgelss leaves the right-hand singular
vectors in the input matrix X on successful exit -- which provides a
nice quick way of computing (X'X)^{-1} -- while dgelsd leaves
nothing but rubble in X. So our (X'X)^{-1} computed after dgelsd was
garbage. Solution: revert to dgelss if (X'X)^{-1} is needed.
I also found another SVD issue: the tall_SVD() function (SVD via
eigen-analysis) is much faster than regular lapack SVD for the case
where X has a lot more columns than rows, but as it's not accurate
for singular or near-singular input. It's therefore not suitable as
a back-end for rank determination or for computation of a
generalized inverse. I've therefore ensured that such functions call
regular lapack SVD internally.
In addition I've added a check on tall_SVD, plus redirection, for
other SVD uses: if we find any negative eigenvalues we get out and
call regular lapack SVD.
Allin
4 years, 10 months
R functions and string-valued series
by Allin Cottrell
Up till now there's been no support for sending string-valued series
to an R function (with R_functions on, that is). All you'd get in R
was the numeric codes.
New in git: string values are passed to R; and also you can return an
array of strings from R. Trivial example:
<hansl>
set R_functions on
foreign language=R
strvals <- function(s) {
cat("Hello from R\n")
print(s)
u <- unique(s)
print(u)
}
end foreign
nulldata 8
series s = {1,2,3,4,1,2,3,4}'
stringify(s, defarray("a", "b", "c", "d"))
print s
eval R.strvals(s)
</hansl>
Allin
4 years, 10 months