RStan freezes for scenario with extremely narrow parameter distributions

86 views
Skip to first unread message

haeussle...@googlemail.com

unread,
Aug 20, 2015, 9:20:42 AM8/20/15
to Stan users mailing list

Dear Stan users,

as part of my research, I am comparing the results of a Bayesian ODE-based model implemented in RStan to the results of a Bayesian Markov model. I am investigating different scenarios with varying levels of parameter uncertainty. For a scenario including "realistic" parameter ranges, I could run my model without any problems. However, if I include extremely narrow distributions of the model parameters, RStan first compiles the code to C++, but freezes afterwards.
The distributions are so narrow that the parameters are almost deterministic. The idea behind this unrealistic scenario is to make it comparable to a deterministic ODE-based model since ODE-based models in the literature are mainly deterministic. Do you think these narrow parameter distributions could influence the performance of Stan? Also, my model includes an ODE system consisting of 20 equations including dynamic interactions, could this be a problem? If I reduce the number of equations to 5, the performance of RStan is ok.

I am attaching the model code.

I would appreciate your help very much.

All the best,

Katrin
VerySimple_lowerVar_new.stan
VerySimple.R
VerySimple.data

Bob Carpenter

unread,
Aug 20, 2015, 2:42:35 PM8/20/15
to stan-...@googlegroups.com
The thing to do is replace the narrowly constrained parameters
with constants declared in the data (and passed in), or defined
in teh transformed data block.

Stan currently has problems with its ODE solver in stiff regions.
So yes, if you need to move very small distances in one dimension compared
to others, there are going to be problems.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <VerySimple_lowerVar_new.stan><VerySimple.R><VerySimple.data>

Michael Betancourt

unread,
Aug 20, 2015, 4:56:10 PM8/20/15
to stan-...@googlegroups.com
Katrin,

In order to determine if the problem is the prior widths or the stiffness of your
ODE system you should try to run optimization, or treat the parameter values
as transformed data with known values and try to generate pseudo-data using
the ODE integrator in the generated quantities block with the fixed_param 
sampler.

It’s more likely that this is a stiffness issue, but the extreme magnitude of your
priors and their narrow widths may also be contributing to problems.

-Mike

Daniel Lakeland

unread,
Aug 21, 2015, 4:15:24 PM8/21/15
to Stan users mailing list
If the point is to compare how well the full uncertain model fits compared to how the ODE system behaves when the parameters are close to particular values, instead of running two stan models one with realistic priors, and one with extremely tight priors, you might just be able to give realistic priors for your coefficients, and then subset the posterior samples by the ones that are close to your values of interest and see how well they fit compared to the full set.

If you want to ensure you sample in those regions, you could always just use the generated quantities block to sample from those narrow priors and generate the y values you need. (assuming integrate_ode works in generated quantities, which I haven't checked).




haeussle...@googlemail.com

unread,
Aug 24, 2015, 7:40:56 AM8/24/15
to Stan users mailing list
Hi everyone,

thank you very much for your suggestions. I will have a closer look, try different things and come back to you.

Katrin


haeussle...@googlemail.com

unread,
Aug 24, 2015, 12:33:43 PM8/24/15
to Stan users mailing list


Thank you so much Bob, Michael and Daniel,

I've included all my parameters as well as the function call of integrate_ode in the generated quantities block and added the option algorithm="Fixed_Param" to the function call of stan(); now, the model runs perfectly and EXTREMELY fast.
Reply all
Reply to author
Forward
0 new messages