RStan fails with many Cholesky factors

I’ve found that when using a model with many Cholesky factors, at least one chain will fail in RStan with:

Error in unserialize(socklist[[n]]) : error reading from connection
Error in serialize(data, node$con, xdr = FALSE) : 
  error writing to connection

Here’s a small model that fails:

parameters{
  cholesky_factor_corr[2] y_Lcorr[20];
}

model{
  for(c in 1:20)
    y_Lcorr[c] ~ lkj_corr_cholesky(1);
}


out = stan("CholRed.stan")

But this doesn’t occur with fewer cholesky parameters, e.g.:

parameters{
  cholesky_factor_corr[2] y_Lcorr[10];
}

model{
  for(c in 1:10)
    y_Lcorr[c] ~ lkj_corr_cholesky(1);
}

Never mind, looks like the problem spontaneously fixed itself somehow. Bizarre.

2 Likes