richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
131 stars 48 forks source link

recompute makes R crash #75

Open SanVerhavert opened 8 years ago

SanVerhavert commented 8 years ago

After running:

DC_BF <- anovaBF( DC_mean ~ Clusternummers, data = SchoolCultureAggr, whichRandom = "Clusternummers", rscaleRandom = "medium" ) DC_chains <- posterior( DC_BF, iterations = 10000 ) DC_chains <- recompute( DC_chains, iterations = 10000, thin = 3 )

R crashes with the following log entry (pulled from RStudio): ERROR system error 109 (pipe ended); OCCURRED AT: virtual void rstudio::session::NamedPipeHttpConnection::close() C:\Users\Administrator\rstudio\src\cpp\session\http\SessionNamedPipeHttpConnectionListener.hpp:198; LOGGED FROM: virtual void rstudio::session::NamedPipeHttpConnection::close() C:\Users\Administrator\rstudio\src\cpp\session\http\SessionNamedPipeHttpConnectionListener.hpp:198

R version 3.3.0 (2016-05-03) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

EDIT1: other attached packages: [1] BayesFactor_0.9.12-2 Matrix_1.2-6 coda_0.18-1
[4] plyr_1.8.3

loaded via a namespace (and not attached): [1] magrittr_1.5 tools_3.3.0 pbapply_1.2-1 MatrixModels_0.4-1 [5] Rcpp_0.12.5 mvtnorm_1.0-5 stringi_1.0-1 grid_3.3.0
[9] stringr_1.0.0 gtools_3.5.0 lattice_0.20-33

EDIT2: This issue appears to occur only (especially?) when posterior and/or recompute are ran several times. If the R session is restarted and every command is executed only once no problems occur. As an example: several BF's are computed and from that posteriors are sampled. Then calling recompute several times (i.e. to have different levels of thinning) the R session hangs/freezes until it aborts or is aborted by RStudio.

richarddmorey commented 8 years ago

Thanks for this. Do you have a reproducible example with a built-in or public data set?

SanVerhavert commented 8 years ago

Unfortunately it appears hard to reproduce. It appears to happen only when a large dataset is in the "BFBayesFactor" object. Only in that case the function posterior creates a "BFmcmc" object in stead of again a "BFBayesFactor" object. Saving the predictor and predicted variable that I will use in the anovaBF function in a separate data frame appears to solve the problem. I am thus unable to provide a reproducible example.

richarddmorey commented 8 years ago

hmmm, maybe a memory issue. I'll try to see if I can get it to happen. How many rows/columns is your dataset?

SanVerhavert commented 8 years ago

My dataset has 65 observations (rows) and 18 variables (columns).

It must be remarked that in the anovaBF function my formula only includes one predictor variable (factor) which is specified as a random effect (no nuisance variable). [As a side note: In this case, might it be more (memory) efficient to just include the data used in the formula in the "BFBayesFactor" object? Or is there a reason why the whole dataset is included in that object class?]