我正在尝试使用 betareg 包在 R 中运行 beta 回归模型。但是,我出乎意料地遇到了内存大小问题。让我解释一下为什么这让我感到惊讶。
我使用的是 Windows 7、64 位、R-64,并且有 32 GB 的 RAM。
我正在运行的 betareg 命令是::
br1 <- betareg(dfp ~ ago + evl + spe + low + poly(fpt, 4, raw = T), data = tt[tt$zero_one_ind == 1, ], model = T, y = F, x = F)
betareg模型的对象大小为:
print(object.size(br1), units = "Mb") 46 Mb
这是我收到的错误消息:
Error: cannot allocate vector of size 344.1 Gb
In addition: Warning messages:
1: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)
2: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)
3: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)
4: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)
betareg 模型在 R 中成功运行并估计了系数,据我所知所有槽都已填充,但看起来 R 无法构建方差协方差矩阵。有什么地方出了问题吗?
最佳答案
我遇到了同样的问题,解决方法很简单。
来自手册:
Note that the default residuals "sweighted2" might be burdensome to compute in large samples and hence might need modification in such applications.
例如,您可以使用摘要中的其他选项之一:
type = c(“pearson”, “deviance”, “response”, “weighted”, “sweighted”, “sweighted2”)
关于r - Betareg 导致内存分配问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26369099/