2
$\begingroup$

I have a model that produces data given a set of parameters. Now, given data, I'ld like to find out which parameters of the model are likely. I have an implementation in Matlab that uses Delayed Rejection Adaptive Metropolis for fitting (DRAM toolbox). Basically, DRAM samples parameter values, and tries to minimize an objective function.

Not having used STAN before, I was wondering: (1) If and how such this could be implemented in STAN, and, in case it is possible, (2) if one could expect speed improvements as compared to using Matlab, since STAN code is compiled?

$\endgroup$
  • $\begingroup$ What do you mean by "finding which parameters of the model are likely"? Do you mean finding which values of parameters are likely? Or something else? $\endgroup$ – Sycorax Feb 5 '14 at 16:40
  • $\begingroup$ Yes, this is what I mean -- finding values for parameters that can explain the data $\endgroup$ – tiko Feb 5 '14 at 16:44
2
$\begingroup$

This is less an answer than an extended comment, so apologies to the reader.

  1. Yes, it is possible to implement a routine that will find optimal parameter values given data and a prior in STAN. However, in STAN, your objective function is assumed to be the log posterior probability. You don't specify your objective function in your question, but if you are indeed looking to find the most probable parameter values given your data and a prior, you're set. If not, then there may be clever ways to manipulate the log posterior probability to optimize alternative functions, but that is not STAN's manifest purpose -- and not my area of expertise. You might find a more informative answer by asking a more detailed question on STAN's (very helpful) Google group.

  2. I am uncertain whether STAN will be more efficient in your particular application. All things being equal, noncompiled code is probably (certainly? I'm not a computer science person) slower than compiled code. But all things are not equal here, as we are comparing one implementation of STAN (in R, C, or Python) to MATLAB. Additionally, major features of STAN's performance are determined by how well you code you model, define data transformations, and take additional steps to ensure that the way you go about defining your model are optimal for Hamiltonian Monte Carlo sampling, so it's not as simple as asking whether or not STAN is faster than an alternative program. The same model, coded in two different, equivalent ways, can converge very quickly or very slowly in STAN for reasons that are described extensively in its documentation.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks a lot for the answer. Regarding (1): The objective function is a custom function computing a -2LL given parameter values and data. It does not return a probability, just a function value for DRAM (or another method, possibly STAN), so that the log-likelihood can be maximised. As this is different from the log posterior probability I assume it is moving outside of STAN's manifest purpose? $\endgroup$ – tiko Feb 5 '14 at 17:05
  • $\begingroup$ I hope that I can answer this question by way of explanation. The log posterior probability is computed via the likelihood and the prior together. Omitting a prior causes STAN to assume a uniform prior over the parameters, which has the effect of not penalizing the log posterior probability (since a uniform prior effectively decrements log posterior probability by a constant). Depending on the model, this may mean that the log likelihood is the same as the value of the log posterior probability, but you will have to check for your particular application. $\endgroup$ – Sycorax Feb 5 '14 at 18:00
  • $\begingroup$ Alright, I will give implementation a try and see what happens then. Thanks a lot $\endgroup$ – tiko Feb 5 '14 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.