alashworth / test-issue-import

0 stars 0 forks source link

Option to not calculate generated quantities during warmup when warmup samples are not saved #81

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by gbiele Wednesday Oct 14, 2015 at 09:50 GMT Originally opened as https://github.com/stan-dev/stan/issues/1641


Feature Request

Category New option/function

Description Currently generated quantities are always calculated during warmup and sampling. The motivation for always calculating generated quantities is that they can be saved and examined during post-processing, which would crash if only parameters but not generated quantities would be saved during warmup. (see Bobs comments here: https://groups.google.com/d/msg/stan-users/Q-4MCXNGf54/2DEAWby8AwAJ)

However, calculating generated quantities can be computationally costly.

A "compromise" that insures no crashing when warmup samples are saved would be to selectively allow to not calculate generated quantities only when warmup samples are not saved.

Possible solutions

  1. Add an option to interface(s) that allows to specify if generated quantities are calculated during warmup or not.
  2. Expose a variable that tells the user if stan is currently in warmup or sampling "state". This would allow the user to write a program that only really calculates generated quantities during sampling.

for example assuming there would be a variable "sampling" that has the value 0 during warmup and 1 during sampling:

generated quantities {
  real posterior_prediction[N];
  if (sampling == 0) {
      // do not realy calculate anything, but instead put in a placeholder number
      posterior_prediction <- rep_array(1, N);
    } else {
      for (k in 1:N) posterior_prediction[n] <- normal_rng(alpha + beta * x, sigma);
    }  
}

Further information Related to this stan-users mailing list topic: https://groups.google.com/forum/#!topic/stan-users/Q-4MCXNGf54

alashworth commented 5 years ago

Comment by bob-carpenter Sunday Nov 27, 2016 at 23:36 GMT


alashworth commented 5 years ago

Comment by syclik Tuesday Nov 29, 2016 at 21:03 GMT


If someone wants to tackle this, start from branch: feature/issue-1751-service-methods. That's the refactor and this will be much easier to fix from that branch.

alashworth commented 5 years ago

Comment by martinmodrak Monday Jun 04, 2018 at 09:05 GMT


Probably superseded by #2459