简体   繁体   中英

Memory exhausted trying to extract from big mcmc.list

I have problem trying to extract a single variable from big 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):

> object.size(outRJ$mcmc)/1024/1024
[1] 442.5508 #

But the single variable should have like 234 kB only! But the extraction of it seems to require much much more memory!

How can I extract from a big mcmc.list without requiring too much 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. I have modified the code in the development version of coda. In the meantime, Matt's workaround should do because it also avoids the redundant copy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM