Can Jags be used to fit classical inference state space models (that is without using a Bayesian approach by specifying a prior)?

To be fully clear: can I estimate a state space model such as the following:

$y_t = \mu_t + \epsilon_t$

$\mu_{t+1} = \mu_t + \eta_t$

in Jags using classical inference?

I thought of using Jags as it has many options that other state space packages do not have (I am already familiar with those, so I am not looking for answers that suggest those).


1 Answer 1


The answer is no. JAGS is not designed for such models. However Stan provides such possibility.

Stan provides optimization algorithms which find modes of the density specified by a Stan program. Such modes may be used as parameter estimates or as the basis of approximations to a Bayesian posterior; see Chapter 52 for background on point estimation. Stan provides three different optimizers, a Newton optimizer, and two related quasi-Newton algorithms, BFGS and L-BFGS (...)

Notice that if uninformative prior is used then

the posterior mode corresponds to the maximum likelihood estimate (MLE) of the parameters. If the prior is not uniform, the posterior mode is sometimes called the maximum a posterior (MAP) estimate. If parameters (typically hierarchical) have been marginalized out, it’s sometimes called a maximum marginal likelihood (MML) estimate.

So with Stan you can use optimization algorithm rather then MCMC sampling and with using flat prior the results obtained are congruent with MLE estimates (see also this).

Source: Stan Development Team (2015). Stan Modeling Language User’s Guide and Reference Manual. Stan Version 2.6.2. pp. 22, 23, 458.

  • $\begingroup$ Great answer, thank you very much! Could you please tell me what exactly you mean with a 'flat prior' (how would you define it)? $\endgroup$
    – rbm
    Commented Apr 11, 2015 at 20:12
  • $\begingroup$ flat = uniform. In JAGS there is even dflat "distribution" as a synonym for uniform. In Stan you can even declare uniform in $[-\infty, \infty]$ range, what makes Stan to find out the proper range using its algorithms. (check the Stan manual, it has >500 pages and goes into many details) $\endgroup$
    – Tim
    Commented Apr 11, 2015 at 20:16
  • $\begingroup$ ...however I am not sure if it is the best way to use the software. There are optimization algorithms implemented in R, MATLAB and in other software that could be more suitable. $\endgroup$
    – Tim
    Commented Apr 11, 2015 at 20:18
  • $\begingroup$ I know, I tried out several ones of them. But the problem that I have with them is that most of them are only for Gaussian models and that I want to estimate state space models with other distributions. $\endgroup$
    – rbm
    Commented Apr 11, 2015 at 20:20
  • $\begingroup$ In R you can set up model with any possible distributions and use one of the multiple optimization algorithms, and probably the only advantage of Stan or JAGS are the sampling algorithms you are not interested in. $\endgroup$
    – Tim
    Commented Apr 11, 2015 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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