On 12/13/12 11:12 AM, Tom Wallis wrote:
> Woops, right you are Ben, I forgot to include gamma. I've attached a new version of the data file with gamma included.
lambda ~ beta(2,50); # note that beta here refers to the beta CDF, not to the beta weights of the regression.
I didn't understand the comment here.
If you want to use the beta cdf you will eventually
be able to say:
lambda <- beta_cdf(outcome,2,50);
But as of now, we don't have the beta_cdf implemented.
Michael Betancourt's working on implementing all the
CDFs starting tomorrow (we needed a real math person
to work out all the crazy non-analytic derivatives
w.r.t. the distribution parameters).
> Could this be caused by a memory problem with my use of sequential fitting rather than something to do with the stan
> model code? I compared the times by fitting model 1, then fitting model 2. I also fit a 3rd model that was vectorised,
> as model 2, but altered to use the "matt trick" (file attached). This 3rd model took nearly 12 hours to do 100 samples
> in 4 chains. All models were sampled in the same script, in the same R session.
For performance comparisons, you should always try to
keep conditions equivalent. So that would mean rerunning
from a new R session without anything else going on in
the background (e.g., not watching a video or something).
> I've tried two things to clarify what's going on:
>
> 1. I ran the three models again, this time removing the fit objects from (R) memory using rm(fitObject). The time taken
> was 46, 251 and 663 seconds. So still an accumulating performance problem, but not nearly as bad as before.
The difference was 10 minutes vs. 12 hours? I wouldn't
expect a factory of 60+ unless you somehow ran out of
memory and started swapping. But then I'm not an R
expert, so maybe Jiqiang or Ben will have a better idea of
what might be going on.
> 2. I changed the order of sampling the models to 3, 2, 1 instead of 1, 2, 3. The time taken for models 1, 2, and 3 under
> this regime was 52, 150, and 1700 seconds. These were all run with the same seed.
> Should I be clearing the fit objects from R in between fits when comparing timing? Is there some way to clear stan's
> memory separately? In any case, I'm not seeing a speed improvement with vectorisation. Any ideas why not?
Always clear everything between speed tests. In fact,
I'd suggest restarting R from scratch.
Stan uses R's environment for memory, so you just need
to get rid of the fit object and anything you've attached.
I can't imagine a situation in which the vectorized
versions will be slower -- the vectorized code should
be both faster and consume less memory. As Ben said in a
previous note, you probably don't want to use col() for
optimal performance, but it should still be faster than
not vectorizing.
- Bob