如何使稀疏矩阵例如dgCMatrix可由需要标准矩阵类格式的函数读取?

问题描述

我需要使用相当大的稀疏矩阵作为面板结构(基本上是 y〜x1 + x2 + ... | s 中的元素 s ) rqpd函数https://rdrr.io/rforge/rqpd/man/rqpd.html),通常需要使用标准矩阵形式或简单的id列。

rqpd(公式,panel = panel(),data = parent.frame(), na.action,子集,contrast = NULL,control = NULL,...)

正如预期的那样,rqpd不接受稀疏等效项,当然,标准矩阵太大,无法满足内存要求。这是我使用矩阵 fe 的稀疏等效项得到的结果:

## define the sparse equivalent of the matrix that identifies fixed effect structure in rqpd
fe <- sparse.model.matrix(~id_z.f:id_j.f-1)

## fit rqpd...
> rqpdfit <- rqpd(y  ~ x  | fe,control=list(tmpmax=1000000),panel(lambda = 1,taus=c(0.1,0.25,0.5,0.75,0.9),tauw=rep(1/5,5),method="pfe")) 
*Error in model.frame.default(terms(formula,lhs = lhs,rhs = rhs,data = data,: 
  invalid type (S4) for variable 'fe'*

是否可以让函数读取 fe 的dgCMatrix等效项(或其他稀疏形式)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)