using spam package for sparse matrix