On 10/30/12 3:16 PM, terrance savitsky wrote:
> The attached monster model ran under stan - much faster than i'd thought, though I wasn't able to check for convergence
> because I received the following error in (64-bit) R: Error: cannot allocate vector of size 16 Kb.
Sounds like R's out of memory.
By dumping your data, you can run Stan from
the command line, which will stream out samples
rather than trying to keep them in memory.
I'd be curious as to hwo much of the memory is R
and how much is Stan's model execution.
You can try more thinning within R.
The profile should be gradually increasing memory
due to saving samples, plus spikes as the model
is evaluated every leapfrog step.
That should use as much memory the first time
being executed as any other time, so you can
probably watch whatever OS your using's system
monitor to watch memory.
> There are some
> things I may try in R, but I write to see if anyone has experience managing memory allocations to arrays in R. The
> model is generally a memory hog (what with so many covariance matrices) and consumes most of the available 16GB of RAM
> on my machine during the run. I know I may improve the speed from the attached script by directly augmenting lp__ in a
> fashion that composes the quadratic product without performing inverses of covariance matrices. Since I still need the
> cholesky decomposition and the inverse of that, I'm not clear that this approach would conserve RAM. Also, even if I
> could conserve RAM, I bet I'd still hit the vector allocation size limit.
>
> I also received a few warning statements (during 2000 iterations) that said this:
>
> Informational Message: The parameter state is about to be Metropolis rejected due to the following underlying, non-fatal
> (really) issue (and please ignore that what comes next might say 'error'): Error in function
> stan::prob::ordered_logistic(N4stan5agrad3varE): Cut points parameter is 1.#INF:0, but must be finite!
> If the problem persists across multiple draws, you might have a problem with an initial state or a gradient somewhere.
> If the problem does not persist, the resulting samples will still be drawn from the psoterior.
I was hoping that message would be less scary than
"(Non-fatal Warning)" followed by "Error in function..."
I'll fix the spelling of "posterior".
Any other suggestions for how to say this given that the "Error in function..
must be finite!" part is fixed.
> Cutpoints are generally notorious highly intracorrelated under ordered logistic models, but I do something that I want
> to check if you think it is a problem. I fix the first element of a vector of ordered cutpoints to 0 to achieve hard
> identifiability. the other elements are random.
It's not so much an identifiability problem as a problem
with the discretization in the Hamiltonian simulation.
For example, if you have a small value for a scale parameter
sigma bounded below at zero, and a gradient toward zero and
a large step size, it's possible to overshoot zero in one
leapfrog step inside the Hamiltonian simulation. Lower step
sizes can always be found (up to arithmetic issues), but we
can't get around the fact that we're using a first order
(derivative only) discretization of the Hamiltonian.
- Bob