[R] Optimization algorithm to be applied to S4 classes - specifically sparse matrices
Avraham.Adler at guycarp.com
Avraham.Adler at guycarp.com
Thu May 14 00:21:07 CEST 2009
Hello.
I am trying to optimize a set of parameters using /optim/ in which the
actual function to be minimized contains matrix multiplication and is of
the form:
SUM ((A%*%X - B)^2)
where A is a matrix and X and B are vectors, with X as parameter vector.
This has worked well so far. Recently, I was given a data set A of size
360440 x 1173, which could not be handled as a normal matrix. I brought it
into 'R' as a sparse matrix (dgCMatrix - using sparseMatrix from the Matrix
package), and the formulæ and gradient work, but /optim/ returns an error
of the form "no method for coercing this S4 class to a vector".
After briefly looking into methods and classes, I realize I am in way over
my head. Is there any way I could use /optim/ or another optimization
algorithm, on sparse matrices?
Thank you very much,
--Avraham Adler
More information about the R-help
mailing list