time series distributions

64 views
Skip to first unread message

Bob Carpenter

unread,
Jun 21, 2013, 4:18:12 PM6/21/13
to stan...@googlegroups.com

[new subject, moved to stan-dev]

On June 21, 2013 01:08:53 PM EDT, Peter Li <li.pe...@gmail.com> wrote:

>> Also along these lines would be things like time-series distributions

>> which have come up on the list from time to time.

> By time-series distributions, are you referring to circular
> distributions like von mises distribution, which I can add once the
> bessel functions pull request is merged?

I believe Ben and/or Marcus mentioned that for time series
model there are various kinds of speedups we can make analytically.
You'll have to ask them for details.

The circular distributions like von mises would be good, too :-)

- Bob

Peter Li

unread,
Jun 21, 2013, 11:21:36 PM6/21/13
to stan...@googlegroups.com, Li.Pe...@gmail.com
Alright. Von mises won't be bad since the bessel functions are already
implemented. On the wiki for directional statistics, they mention a few
circular distributions, but some of them don't have a closed form (or
they require some weird function that I'm not sure we can implement
effectively) so it might be hard to implement. However, they have a
circular uniform that's just uniform from 0 to 2pi, von mises, and a
wrapped cauchy distribution that we may be able to implement efficiently.


- Peter

Ben Goodrich

unread,
Jun 21, 2013, 11:56:53 PM6/21/13
to stan...@googlegroups.com, Li.Pe...@gmail.com
There is an ancient branch called circular where somebody implemented a couple of things. As I recall, there was a question as to whether to go with the convention that the circular distributions be defined on (0,2 * pi) or (-pi,pi). I think it would be best to follow the conventions of the circular R package(s) whatever those are.

Ben

Bob Carpenter

unread,
Jun 22, 2013, 11:14:34 AM6/22/13
to stan...@googlegroups.com
On 6/21/13 11:56 PM, Ben Goodrich wrote:
> There is an ancient branch called circular where somebody implemented a couple of things.

I think the issue there was that we needed tests and doc.
The implementations looked OK to me the last time I looked.
So you should definitely start from there, Peter.

> As I recall, there was a
> question as to whether to go with the convention that the circular distributions be defined on (0,2 * pi) or (-pi,pi). I
> think it would be best to follow the conventions of the circular R package(s) whatever those are.

Here's the doc for circular:

http://cran.r-project.org/web/packages/circular/circular.pdf

This package is hugely flexible and lets the user define
the units. e.g.,

x <- rvonmises(n=100, mu=circular(0), kappa=1)

where the circular() class is highly configurable. The default
is angle in radians, working modularly, so it's not constrained
to (0, 2*pi) or (-pi, pi) or whatever.

The nice part about working modulo 2*pi is that you get
2*pi == 0 instead of a discontinuity.

Even if we restrict the support of von_mises() to [0,2*pi),
we'll have an option to implement as:

parameters {
real<lower=0, upper=2 * pi()> theta;
}
model {
theta ~ von_mises(kappa);
}

or:

parameters {
real theta_raw;
}
transformed parameters {
real<lower=0,upper=2 * pi()> theta;
theta <- mod(theta_raw, 2 * pi());
}
model {
theta ~ von_mises(kappa);
}

Alternatively, we could have a new data type called "angle".
It could underlyingly be implemented one of the above two
ways.

- Bob

Bob Carpenter

unread,
Jun 22, 2013, 11:32:27 AM6/22/13
to stan...@googlegroups.com
We can handle the uniform one already with a constrained
parameter.

I would suggest just doing the von Mises, since we've had
requests for that on the list. Given the vast number of distributions
out there that we could implement, I'd rather be driven by:


1. new research ideas we're working on,

2. concrete user requests for applied modeling problems, and

3. good demonstrations of what Stan can do.

So having one reasonable circular distribution is good for both (2)
and (3).

- Bob

Peter Li

unread,
Jun 24, 2013, 11:05:41 AM6/24/13
to stan...@googlegroups.com, Li.Pe...@gmail.com
Alright. That'll have to wait for the bessel/pochhammer pull request though.


Peter

Peter Li

unread,
Jun 26, 2013, 6:32:05 PM6/26/13
to stan...@googlegroups.com, Li.Pe...@gmail.com
The way it was set up previously (in circular branch) is to restrict y
and mu to (-pi,pi), so should I change this to [0,2pi) or leave it as is?

Bob Carpenter

unread,
Jun 26, 2013, 8:20:47 PM6/26/13
to stan...@googlegroups.com
I think to match circular you want to evaluate the argument
as angle in radians modulo 2 * pi.

Is that OK with everyone else? It follows Ben's recommendation
to do what the R package circular does.

There's still the question of whether it would be better to
have an unconstrained varialbe that you took mod 2 * pi so that
it could circle around continuously rather than having 2 * pi
at the opposite end of a line from 0.

- Bob

Marcus Brubaker

unread,
Jun 26, 2013, 11:15:24 PM6/26/13
to stan...@googlegroups.com
I think it would be much better to have von_mises(kappa) defined on the whole line (mod 2pi) than restrict it's input to [0,2pi).  The (unconstrained) representation of real<lower=0,upper=2*pi> ends up (potentially) having an unnecessary multi-modality when the mode is anywhere near the end points.  This is going to make sampling much harder than it needs to be for no good reason that I can see.

Cheers,
Marcus



--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Bob Carpenter

unread,
Jun 27, 2013, 1:29:45 AM6/27/13
to stan...@googlegroups.com
I think we're all in agreement, so go ahead and do it
mod 2 * pi, Peter.

The convention will probably then be to define a generated
quantity defined as the parameter mod 2 * pi.

- Bob
> http://cran.r-project.org/web/__packages/circular/circular.pdf
> stan-dev+unsubscribe@__googlegroups.com <mailto:stan-dev%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/__groups/opt_out <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.

Peter Li

unread,
Jun 27, 2013, 10:17:50 AM6/27/13
to stan...@googlegroups.com, Li.Pe...@gmail.com
So should I put the von mises distribution in the unbounded continuous
section of the manual?
Reply all
Reply to author
Forward
0 new messages