[英]Memory exhausted trying to extract from big mcmc.list
I have problem trying to extract a single variable from big mcmc.list
: 我在尝试从大
mcmc.list
提取单个变量时mcmc.list
:
> x <- outRJ$mcmc[,'avail_int']
Error: cannot allocate vector of size 146.8 Mb
The outRJ$mcmc
mcmc.list is big, 442 MB actually (contains data for 3 chains for like 960 variables, each 20000 iterations): outRJ$mcmc
mcmc.list很大,实际上为442 MB(包含3个链的数据,例如960个变量,每20000次迭代):
> object.size(outRJ$mcmc)/1024/1024
[1] 442.5508 #
But the single variable should have like 234 kB only! 但是单个变量应该只有234 kB! But the extraction of it seems to require much much more memory!
但是提取它似乎需要更多的内存!
I think this should work: 我认为这应该工作:
x <- as.mcmc.list(lapply(outRJ$mcmc, function(x) return(x[,'avail_int',drop=FALSE])))
Matt 马特
The current subsetting code (in the function [.mcmc.list) is making a copy of each element of the list before subsetting it. 当前的子设置代码(在[.mcmc.list函数中)正在对列表的每个元素进行复制,然后再进行子设置。 I have modified the code in the development version of coda.
我已经修改了Coda开发版中的代码。 In the meantime, Matt's workaround should do because it also avoids the redundant copy.
同时,Matt的变通办法应该这样做,因为它还避免了冗余副本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.