7
$\begingroup$

I try to fit a population time-series model in stan/rstan(2.7.0) where the death rate depends on the generation before (n-1) but the reproduction depends on a unknown generation (n-x). I haven't found a way to estimate x since stan has no options for integer distributions and the floor function returns reals that cannot be used as indices to arrays. Does anyone know a good workaround to estimate integer time lags in stan?

$\endgroup$
2
  • $\begingroup$ (+1) The title could be edited to be more specific, such as 'Fit a time series model with unknown lag in Stan' - since for some integer parameters there exist workarounds and thus it would be useful to have a different question for each specific case instead of a general 'fit integer in Stan' question. $\endgroup$ Jul 28, 2015 at 14:37
  • $\begingroup$ @Julian I am tagging this post analysis since it concerns the analysis of a specific dataset. Please reformat your question in compliance with the suggested rules outlined in the wiki here $\endgroup$
    – AdamO
    Jul 28, 2015 at 18:42

1 Answer 1

4
$\begingroup$

Estimating integer parameters in STAN is impossible. HMC depends on gradient computations of the posterior density. Integer parameters aren't suitable for those computations. Rounding or truncating a real number to an integer won't help because the posterior surface will be flat in a region along that axis, so there will be no information for the sampler about where to go next.

Several alterntatives exist, though.

  1. Specify the number of lags as data for a range of plausible lags and compare the posterior probabilities of these models. Note that you will have to use the functions which compute the complete posterior probability, rather than the posterior probability up to a constant of proportionality. Please see the STAN manual for more deails.
  2. Use a standard Metropolis/Gibbs sampling routine.
$\endgroup$
3
  • 1
    $\begingroup$ For the second sollution; how would you perform something like this in jags? I can't find ways to sample integers there as well. $\endgroup$
    – Julian
    Jul 28, 2015 at 15:53
  • $\begingroup$ @Julian I'm not an expert in JAGS, but perhaps you could sample a real number and truncate it. $\endgroup$
    – Sycorax
    Jul 28, 2015 at 15:58
  • 2
    $\begingroup$ Another alternative is to estimate a mixture of autoregressive models with different lag lengths, including estimating the simplex vector of mixing weights. $\endgroup$ Jul 28, 2015 at 18:56

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.